-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
migrate row block transforms e2e tests to playwright
- Loading branch information
1 parent
21d84ee
commit 7145fcd
Showing
6 changed files
with
262 additions
and
92 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
playwright/e2e/row/__snapshots__/columns-should-not-be-smaller-than-3-chromium.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<!-- wp:wp-bootstrap-blocks/row {"template":"custom"} --> | ||
<!-- wp:wp-bootstrap-blocks/column {"sizeMd":3} --> | ||
<!-- wp:heading --> | ||
<h2 class="wp-block-heading"></h2> | ||
<!-- /wp:heading --> | ||
<!-- /wp:wp-bootstrap-blocks/column --> | ||
|
||
<!-- wp:wp-bootstrap-blocks/column {"sizeMd":3} --> | ||
<!-- wp:heading --> | ||
<h2 class="wp-block-heading"></h2> | ||
<!-- /wp:heading --> | ||
<!-- /wp:wp-bootstrap-blocks/column --> | ||
|
||
<!-- wp:wp-bootstrap-blocks/column {"sizeMd":3} --> | ||
<!-- wp:heading --> | ||
<h2 class="wp-block-heading"></h2> | ||
<!-- /wp:heading --> | ||
<!-- /wp:wp-bootstrap-blocks/column --> | ||
|
||
<!-- wp:wp-bootstrap-blocks/column {"sizeMd":3} --> | ||
<!-- wp:heading --> | ||
<h2 class="wp-block-heading"></h2> | ||
<!-- /wp:heading --> | ||
<!-- /wp:wp-bootstrap-blocks/column --> | ||
|
||
<!-- wp:wp-bootstrap-blocks/column {"sizeMd":3} --> | ||
<!-- wp:heading --> | ||
<h2 class="wp-block-heading"></h2> | ||
<!-- /wp:heading --> | ||
<!-- /wp:wp-bootstrap-blocks/column --> | ||
<!-- /wp:wp-bootstrap-blocks/row --> |
13 changes: 13 additions & 0 deletions
13
playwright/e2e/row/__snapshots__/transform-2-blocks-to-row-block-chromium.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!-- wp:wp-bootstrap-blocks/row {"template":"custom"} --> | ||
<!-- wp:wp-bootstrap-blocks/column {"sizeMd":6} --> | ||
<!-- wp:heading --> | ||
<h2 class="wp-block-heading"></h2> | ||
<!-- /wp:heading --> | ||
<!-- /wp:wp-bootstrap-blocks/column --> | ||
|
||
<!-- wp:wp-bootstrap-blocks/column {"sizeMd":6} --> | ||
<!-- wp:heading --> | ||
<h2 class="wp-block-heading"></h2> | ||
<!-- /wp:heading --> | ||
<!-- /wp:wp-bootstrap-blocks/column --> | ||
<!-- /wp:wp-bootstrap-blocks/row --> |
19 changes: 19 additions & 0 deletions
19
playwright/e2e/row/__snapshots__/transform-3-blocks-to-row-block-chromium.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!-- wp:wp-bootstrap-blocks/row {"template":"custom"} --> | ||
<!-- wp:wp-bootstrap-blocks/column {"sizeMd":4} --> | ||
<!-- wp:heading --> | ||
<h2 class="wp-block-heading"></h2> | ||
<!-- /wp:heading --> | ||
<!-- /wp:wp-bootstrap-blocks/column --> | ||
|
||
<!-- wp:wp-bootstrap-blocks/column {"sizeMd":4} --> | ||
<!-- wp:heading --> | ||
<h2 class="wp-block-heading"></h2> | ||
<!-- /wp:heading --> | ||
<!-- /wp:wp-bootstrap-blocks/column --> | ||
|
||
<!-- wp:wp-bootstrap-blocks/column {"sizeMd":4} --> | ||
<!-- wp:heading --> | ||
<h2 class="wp-block-heading"></h2> | ||
<!-- /wp:heading --> | ||
<!-- /wp:wp-bootstrap-blocks/column --> | ||
<!-- /wp:wp-bootstrap-blocks/row --> |
25 changes: 25 additions & 0 deletions
25
playwright/e2e/row/__snapshots__/transform-4-blocks-to-row-block-chromium.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!-- wp:wp-bootstrap-blocks/row {"template":"custom"} --> | ||
<!-- wp:wp-bootstrap-blocks/column {"sizeMd":3} --> | ||
<!-- wp:heading --> | ||
<h2 class="wp-block-heading"></h2> | ||
<!-- /wp:heading --> | ||
<!-- /wp:wp-bootstrap-blocks/column --> | ||
|
||
<!-- wp:wp-bootstrap-blocks/column {"sizeMd":3} --> | ||
<!-- wp:heading --> | ||
<h2 class="wp-block-heading"></h2> | ||
<!-- /wp:heading --> | ||
<!-- /wp:wp-bootstrap-blocks/column --> | ||
|
||
<!-- wp:wp-bootstrap-blocks/column {"sizeMd":3} --> | ||
<!-- wp:heading --> | ||
<h2 class="wp-block-heading"></h2> | ||
<!-- /wp:heading --> | ||
<!-- /wp:wp-bootstrap-blocks/column --> | ||
|
||
<!-- wp:wp-bootstrap-blocks/column {"sizeMd":3} --> | ||
<!-- wp:heading --> | ||
<h2 class="wp-block-heading"></h2> | ||
<!-- /wp:heading --> | ||
<!-- /wp:wp-bootstrap-blocks/column --> | ||
<!-- /wp:wp-bootstrap-blocks/row --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); | ||
|
||
test.describe( 'Row Block Transforms - Custom template enabled', () => { | ||
test.beforeEach( async ( { admin, editor, page } ) => { | ||
await admin.createNewPost(); | ||
await editor.openDocumentSettingsSidebar(); | ||
} ); | ||
|
||
test( 'Transform two blocks to row block', async ( { editor, page } ) => { | ||
await editor.insertBlock( { | ||
name: 'core/heading', | ||
} ); | ||
await editor.insertBlock( { | ||
name: 'core/heading', | ||
} ); | ||
|
||
await editor.selectBlocks( | ||
page.getByLabel( 'Block: Heading' ).nth( 0 ), | ||
page.getByLabel( 'Block: Heading' ).nth( 1 ) | ||
); | ||
|
||
// Transform selected heading blocks to row | ||
await editor.transformBlockTo( 'wp-bootstrap-blocks/row' ); | ||
|
||
// One row block with 2 columns of size 6 should have been created | ||
expect( | ||
await page | ||
.getByLabel( 'Block: Column (Bootstrap)' ) | ||
.nth( 0 ) | ||
.getAttribute( 'data-size-md' ) | ||
).toBe( '6' ); | ||
expect( | ||
await page | ||
.getByLabel( 'Block: Column (Bootstrap)' ) | ||
.nth( 1 ) | ||
.getAttribute( 'data-size-md' ) | ||
).toBe( '6' ); | ||
|
||
expect( await editor.getEditedPostContent() ).toMatchSnapshot( | ||
'transform-2-blocks-to-row-block.txt' | ||
); | ||
} ); | ||
|
||
test( 'Transform 3 blocks to row block', async ( { editor, page } ) => { | ||
await editor.insertBlock( { | ||
name: 'core/heading', | ||
} ); | ||
await editor.insertBlock( { | ||
name: 'core/heading', | ||
} ); | ||
await editor.insertBlock( { | ||
name: 'core/heading', | ||
} ); | ||
|
||
await editor.selectBlocks( | ||
page.getByLabel( 'Block: Heading' ).nth( 0 ), | ||
page.getByLabel( 'Block: Heading' ).nth( 2 ) | ||
); | ||
|
||
// Transform selected heading blocks to row | ||
await editor.transformBlockTo( 'wp-bootstrap-blocks/row' ); | ||
|
||
// One row block with 3 columns of size 4 should have been created | ||
expect( await editor.getEditedPostContent() ).toMatchSnapshot( | ||
'transform-3-blocks-to-row-block.txt' | ||
); | ||
} ); | ||
|
||
test( 'Transform 4 blocks to row block', async ( { editor, page } ) => { | ||
await editor.insertBlock( { | ||
name: 'core/heading', | ||
} ); | ||
await editor.insertBlock( { | ||
name: 'core/heading', | ||
} ); | ||
await editor.insertBlock( { | ||
name: 'core/heading', | ||
} ); | ||
await editor.insertBlock( { | ||
name: 'core/heading', | ||
} ); | ||
|
||
await editor.selectBlocks( | ||
page.getByLabel( 'Block: Heading' ).nth( 0 ), | ||
page.getByLabel( 'Block: Heading' ).nth( 3 ) | ||
); | ||
|
||
// Transform selected heading blocks to row | ||
await editor.transformBlockTo( 'wp-bootstrap-blocks/row' ); | ||
|
||
// One row block with 4 columns of size 3 should have been created | ||
expect( await editor.getEditedPostContent() ).toMatchSnapshot( | ||
'transform-4-blocks-to-row-block.txt' | ||
); | ||
} ); | ||
|
||
test( 'Columns should not be smaller than 3', async ( { | ||
editor, | ||
page, | ||
} ) => { | ||
await editor.insertBlock( { | ||
name: 'core/heading', | ||
} ); | ||
await editor.insertBlock( { | ||
name: 'core/heading', | ||
} ); | ||
await editor.insertBlock( { | ||
name: 'core/heading', | ||
} ); | ||
await editor.insertBlock( { | ||
name: 'core/heading', | ||
} ); | ||
await editor.insertBlock( { | ||
name: 'core/heading', | ||
} ); | ||
|
||
await editor.selectBlocks( | ||
page.getByLabel( 'Block: Heading' ).nth( 0 ), | ||
page.getByLabel( 'Block: Heading' ).nth( 4 ) | ||
); | ||
|
||
// Transform selected heading blocks to row | ||
await editor.transformBlockTo( 'wp-bootstrap-blocks/row' ); | ||
|
||
// One row block with 4 columns of size 3 should have been created | ||
expect( await editor.getEditedPostContent() ).toMatchSnapshot( | ||
'columns-should-not-be-smaller-than-3.txt' | ||
); | ||
} ); | ||
} ); | ||
|
||
test.describe( 'Row Block Transforms - Custom template disabled', () => { | ||
test.beforeAll( async ( { requestUtils } ) => { | ||
await requestUtils.activatePlugin( | ||
'wp-bootstrap-blocks-test-row-filters' | ||
); | ||
} ); | ||
|
||
test.afterAll( async ( { requestUtils } ) => { | ||
await requestUtils.deactivatePlugin( | ||
'wp-bootstrap-blocks-test-row-filters' | ||
); | ||
} ); | ||
|
||
test.beforeEach( async ( { admin, editor, page } ) => { | ||
await admin.createNewPost(); | ||
await editor.openDocumentSettingsSidebar(); | ||
} ); | ||
|
||
test( 'Not able to transform blocks if custom template is disabled', async ( { | ||
editor, | ||
page, | ||
} ) => { | ||
await editor.insertBlock( { | ||
name: 'core/heading', | ||
} ); | ||
await editor.insertBlock( { | ||
name: 'core/heading', | ||
} ); | ||
|
||
await editor.selectBlocks( | ||
page.getByLabel( 'Block: Heading' ).nth( 0 ), | ||
page.getByLabel( 'Block: Heading' ).nth( 1 ) | ||
); | ||
|
||
// Transformation to row block should not be available | ||
await page.locator( '.block-editor-block-switcher__toggle' ).click(); | ||
await expect( | ||
await page.locator( | ||
'.editor-block-list-item-wp-bootstrap-blocks-row' | ||
) | ||
).not.toBeVisible(); | ||
} ); | ||
} ); |