-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Migrate group block tests to Playwright #41150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
31f8d9d
Migrate group block tests to Playwright
JustinyAhin 74a6336
Inline the searchForBlock utils in the tests
JustinyAhin 5d86d80
Update group.spec.js
JustinyAhin 1fba0a0
Remove checking if the inserter is opened
JustinyAhin 28404d8
Update test/e2e/specs/editor/blocks/group.spec.js
JustinyAhin 4903b13
Update test/e2e/specs/editor/blocks/group.spec.js
JustinyAhin 63afaf3
Update test/e2e/specs/editor/blocks/group.spec.js
JustinyAhin fd3fd37
Update test/e2e/specs/editor/blocks/group.spec.js
JustinyAhin 6ee05fa
Update test/e2e/specs/editor/blocks/group.spec.js
JustinyAhin a25041c
Update test/e2e/specs/editor/blocks/group.spec.js
JustinyAhin 1280cbb
Misc fixes
JustinyAhin e8c3a7c
Update group.spec.js
JustinyAhin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
Migrate group block tests to Playwright
- Loading branch information
commit 31f8d9d9faa191a56c182e35836a641a4e6246fd
There are no files selected for viewing
This file contains hidden or 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
28 changes: 28 additions & 0 deletions
28
packages/e2e-test-utils-playwright/src/editor/search-for-block.ts
This file contains hidden or 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,28 @@ | ||
| /** | ||
| * Internal dependencies | ||
| */ | ||
| import type { Editor } from './index'; | ||
|
|
||
| /** | ||
| * Search for block in the global inserter | ||
| * | ||
| * @param {Editor} this | ||
| * @param {string} searchTerm The text to search the inserter for. | ||
| */ | ||
|
|
||
| export async function searchForBlock( this: Editor, searchTerm: string ) { | ||
| // If the inserter is not open, open it. | ||
| const inserterButton = this.page.locator( | ||
| 'role=button[name="Toggle block inserter"i]' | ||
| ); | ||
|
|
||
| if ( ( await inserterButton.getAttribute( 'aria-pressed' ) ) === 'false' ) { | ||
| await inserterButton.click(); | ||
| } | ||
|
|
||
| // Enter the search term into the search field. | ||
| const searchField = this.page.locator( | ||
| '.components-search-control__input' | ||
| ); | ||
| await searchField.type( searchTerm ); | ||
| } | ||
21 changes: 0 additions & 21 deletions
21
packages/e2e-tests/specs/editor/blocks/__snapshots__/group.test.js.snap
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
.../editor/blocks/__snapshots__/Group-can-be-created-using-the-block-inserter-1-chromium.txt
This file contains hidden or 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,3 @@ | ||
| <!-- wp:group --> | ||
| <div class="wp-block-group"></div> | ||
| <!-- /wp:group --> |
3 changes: 3 additions & 0 deletions
3
.../editor/blocks/__snapshots__/Group-can-be-created-using-the-slash-inserter-1-chromium.txt
This file contains hidden or 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,3 @@ | ||
| <!-- wp:group --> | ||
| <div class="wp-block-group"></div> | ||
| <!-- /wp:group --> |
5 changes: 5 additions & 0 deletions
5
...ots__/Group-can-have-other-blocks-appended-to-it-using-the-button-appender-1-chromium.txt
This file contains hidden or 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,5 @@ | ||
| <!-- wp:group --> | ||
| <div class="wp-block-group"><!-- wp:paragraph --> | ||
| <p>Group Block with a Paragraph</p> | ||
| <!-- /wp:paragraph --></div> | ||
| <!-- /wp:group --> |
This file contains hidden or 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,47 @@ | ||
| /** | ||
| * WordPress dependencies | ||
| */ | ||
| const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); | ||
|
|
||
| test.describe( 'Group', () => { | ||
| test.beforeEach( async ( { admin } ) => { | ||
| await admin.createNewPost(); | ||
| } ); | ||
|
|
||
| test( 'can be created using the block inserter', async ( { | ||
| editor, | ||
| page, | ||
| } ) => { | ||
| await editor.searchForBlock( 'Group' ); | ||
| await page.locator( '.editor-block-list-item-group' ).click(); | ||
JustinyAhin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| expect( await editor.getEditedPostContent() ).toMatchSnapshot(); | ||
| } ); | ||
|
|
||
| test( 'can be created using the slash inserter', async ( { | ||
| editor, | ||
| page, | ||
| } ) => { | ||
| await page.locator( 'role=button[name="Add default block"i]' ).click(); | ||
JustinyAhin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| await page.keyboard.type( '/group' ); | ||
| await page.waitForSelector( | ||
| `//*[contains(@class, "components-autocomplete__result") and contains(@class, "is-selected") and contains(text(), 'Group')]` | ||
| ); | ||
JustinyAhin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| await page.keyboard.press( 'Enter' ); | ||
|
|
||
| expect( await editor.getEditedPostContent() ).toMatchSnapshot(); | ||
| } ); | ||
|
|
||
| test( 'can have other blocks appended to it using the button appender', async ( { | ||
| editor, | ||
| page, | ||
| } ) => { | ||
| await editor.searchForBlock( 'Group' ); | ||
| await page.locator( '.editor-block-list-item-group' ).click(); | ||
| await page.locator( '.block-editor-button-block-appender' ).click(); | ||
JustinyAhin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| await page.locator( '.editor-block-list-item-paragraph' ).click(); | ||
JustinyAhin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| await page.keyboard.type( 'Group Block with a Paragraph' ); | ||
|
|
||
| expect( await editor.getEditedPostContent() ).toMatchSnapshot(); | ||
| } ); | ||
| } ); | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.