-
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.
"Multiple use" block validation logic improvement [with Playwright] (#…
…57576) * Multiple use block validation logic improvement See: #38502 * Added playwright as the testing library * Moved 'validate-multiple-use' test to 'test/e2e/specs/editor/variou' dir * renamed test file * Fix: issues with block insertion for testing * Rewrite test cases by playwright role api * Fix iframe locator issue * Update playwright locators by 'getByRole' * Using 'clickBlockOptionsMenuItem' function * Apply comment wording improvements Co-authored-by: Ben Dwyer <ben@scruffian.com> --------- Co-authored-by: Delowar Hossain <delowardev@gmail.com> Co-authored-by: Dave Smith <getdavemail@gmail.com> Co-authored-by: Ben Dwyer <ben@scruffian.com>
- Loading branch information
1 parent
eb143a8
commit 9ea082b
Showing
2 changed files
with
64 additions
and
3 deletions.
There are no files selected for viewing
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
36 changes: 36 additions & 0 deletions
36
test/e2e/specs/editor/various/validate-multiple-use.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,36 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
|
||
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); | ||
|
||
test.describe( 'Validate multiple use', () => { | ||
test.beforeEach( async ( { admin } ) => { | ||
await admin.createNewPost(); | ||
} ); | ||
|
||
test( 'should display correct number of warning messages', async ( { | ||
editor, | ||
pageUtils, | ||
} ) => { | ||
// Insert a block with the `multiple` feature enabled, such as `core/more` | ||
await editor.insertBlock( { | ||
name: 'core/more', | ||
} ); | ||
|
||
// Group the block | ||
await pageUtils.pressKeys( 'primary+a' ); | ||
await editor.clickBlockOptionsMenuItem( 'Group' ); | ||
|
||
// Duplicate the block | ||
await pageUtils.pressKeys( 'primary+a' ); | ||
await editor.clickBlockOptionsMenuItem( 'Duplicate' ); | ||
|
||
// Check if warning is visible | ||
await expect( | ||
editor.canvas.getByRole( 'button', { | ||
name: 'Find original', | ||
} ) | ||
).toBeVisible(); | ||
} ); | ||
} ); |