-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate 'meta-attribute-block' e2e tests to Playwright (#55830)
* Migrate 'meta-attribute-block' e2e tests to Playwright * Remove old test files * Fix plugin name
- Loading branch information
Showing
3 changed files
with
104 additions
and
109 deletions.
There are no files selected for viewing
9 changes: 0 additions & 9 deletions
9
packages/e2e-tests/specs/editor/plugins/__snapshots__/meta-attribute-block.test.js.snap
This file was deleted.
Oops, something went wrong.
100 changes: 0 additions & 100 deletions
100
packages/e2e-tests/specs/editor/plugins/meta-attribute-block.test.js
This file was deleted.
Oops, something went wrong.
104 changes: 104 additions & 0 deletions
104
test/e2e/specs/editor/plugins/meta-attribute-block.spec.js
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,104 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); | ||
|
||
const VARIATIONS = [ | ||
[ 'Early Registration', 'test/test-meta-attribute-block-early' ], | ||
[ 'Late Registration', 'test/test-meta-attribute-block-late' ], | ||
]; | ||
|
||
test.describe( 'Block with a meta attribute', () => { | ||
test.beforeAll( async ( { requestUtils } ) => { | ||
await requestUtils.activatePlugin( | ||
'gutenberg-test-meta-attribute-block' | ||
); | ||
} ); | ||
|
||
test.afterAll( async ( { requestUtils } ) => { | ||
await requestUtils.deactivatePlugin( | ||
'gutenberg-test-meta-attribute-block' | ||
); | ||
} ); | ||
|
||
for ( const [ title, blockName ] of VARIATIONS ) { | ||
test.describe( title, () => { | ||
test( 'Should persist the meta attribute properly', async ( { | ||
admin, | ||
editor, | ||
page, | ||
pageUtils, | ||
} ) => { | ||
await admin.createNewPost(); | ||
await editor.insertBlock( { name: blockName } ); | ||
await page.keyboard.type( 'Value' ); | ||
|
||
// Regression Test: Previously the caret would wrongly reset to the end | ||
// of any input for meta-sourced attributes, due to syncing behavior of | ||
// meta attribute updates. | ||
// | ||
// See: https://github.com/WordPress/gutenberg/issues/15739 | ||
await pageUtils.pressKeys( 'ArrowLeft', { times: 5 } ); | ||
await page.keyboard.type( 'Meta ' ); | ||
|
||
await editor.saveDraft(); | ||
await page.reload(); | ||
|
||
const block = page.getByRole( 'document', { | ||
name: `Block: Test Meta Attribute Block (${ title })`, | ||
} ); | ||
await expect( block ).toBeVisible(); | ||
await expect( block.locator( '.my-meta-input' ) ).toHaveValue( | ||
'Meta Value' | ||
); | ||
} ); | ||
|
||
test( 'Should use the same value in all the blocks', async ( { | ||
admin, | ||
editor, | ||
page, | ||
} ) => { | ||
await admin.createNewPost(); | ||
await editor.insertBlock( { name: blockName } ); | ||
await editor.insertBlock( { name: blockName } ); | ||
await editor.insertBlock( { name: blockName } ); | ||
await page.keyboard.type( 'Meta Value' ); | ||
|
||
const inputs = await page.locator( '.my-meta-input' ).all(); | ||
for ( const input of inputs ) { | ||
await expect( input ).toHaveValue( 'Meta Value' ); | ||
} | ||
} ); | ||
|
||
test( 'Should persist the meta attribute properly in a different post type', async ( { | ||
admin, | ||
editor, | ||
page, | ||
pageUtils, | ||
} ) => { | ||
await admin.createNewPost( { postType: 'page' } ); | ||
await editor.insertBlock( { name: blockName } ); | ||
await page.keyboard.type( 'Value' ); | ||
|
||
// Regression Test: Previously the caret would wrongly reset to the end | ||
// of any input for meta-sourced attributes, due to syncing behavior of | ||
// meta attribute updates. | ||
// | ||
// See: https://github.com/WordPress/gutenberg/issues/15739 | ||
await pageUtils.pressKeys( 'ArrowLeft', { times: 5 } ); | ||
await page.keyboard.type( 'Meta ' ); | ||
|
||
await editor.saveDraft(); | ||
await page.reload(); | ||
|
||
const block = page.getByRole( 'document', { | ||
name: `Block: Test Meta Attribute Block (${ title })`, | ||
} ); | ||
await expect( block ).toBeVisible(); | ||
await expect( block.locator( '.my-meta-input' ) ).toHaveValue( | ||
'Meta Value' | ||
); | ||
} ); | ||
} ); | ||
} | ||
} ); |
ce3ef3e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flaky tests detected in ce3ef3e.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.
🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6768411708
📝 Reported issues:
/test/e2e/specs/editor/various/multi-block-selection.spec.js