Skip to content
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

[Experiment] Try Playwright #34089

Closed
wants to merge 44 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
c933d8c
Try running our e2e tests using playwright
youknowriad Jun 17, 2020
1aa6346
Migrate to Playwright API
WunderBart Aug 4, 2021
f65086d
Update jest.playwright.config.js
WunderBart Aug 16, 2021
acca37d
Add --runInBand for serial running
WunderBart Aug 16, 2021
998a812
Update playwright setup
WunderBart Aug 16, 2021
415e94d
Refactor saveDraft util
WunderBart Aug 16, 2021
c4bfa47
Simplify "moved to trash" selector
WunderBart Aug 16, 2021
4c43789
Classic block: skip cache-based test
WunderBart Aug 16, 2021
a2be9ec
Classic block test: demo refactor
WunderBart Aug 16, 2021
354af20
Gallery block test: demo refactor
WunderBart Aug 16, 2021
6c52f4c
Group block test: demo refactor
WunderBart Aug 16, 2021
c137146
Heading block test: demo refactor
WunderBart Aug 16, 2021
1a67562
HTML block test: demo refactor
WunderBart Aug 16, 2021
a5cf071
Image block test: demo refactor
WunderBart Aug 16, 2021
d95ca24
List block test: demo refactor
WunderBart Aug 16, 2021
26f8ae8
Missing block test: demo refactor
WunderBart Aug 16, 2021
37a49fc
Post Title block test: demo refactor
WunderBart Aug 16, 2021
4a063aa
Query block test: demo refactor
WunderBart Aug 16, 2021
f6824d0
Quote block test: demo refactor
WunderBart Aug 16, 2021
4d8daa7
Site Title block test: demo refactor
WunderBart Aug 16, 2021
b95bec8
Spacer block test: demo refactor
WunderBart Aug 16, 2021
cba116d
Rich Text test: demo refactor
WunderBart Aug 16, 2021
953a867
Columns block test: demo refactor
WunderBart Aug 16, 2021
b957a10
Cover block test: demo refactor
WunderBart Aug 16, 2021
0c99d34
See if the CI catches
WunderBart Aug 16, 2021
8ccbd3d
Use test-e2e script for running the specs locally
WunderBart Aug 17, 2021
6cc0bbf
Refactor insertBlock utility
WunderBart Aug 18, 2021
51787bf
Refactor clickBlockToolbarButton util
WunderBart Aug 18, 2021
355c807
Refactor clickMenuItem util
WunderBart Aug 18, 2021
36146d0
Fix accidental selector nesting
WunderBart Aug 18, 2021
2cba1a8
Remove hello.test.js
WunderBart Aug 25, 2021
d20e558
Remove obsolete waitForSelector
WunderBart Aug 25, 2021
913de3e
Update confusing parts copypasted from Puppeteer setup
WunderBart Aug 25, 2021
61cec23
Make devtools/headless/sloMo args usable
WunderBart Aug 25, 2021
5da8b94
Remove obsolete visibility check
WunderBart Aug 25, 2021
6c69a32
Remove unrelated note
WunderBart Aug 25, 2021
193d26c
Restore the increased jest timeout
WunderBart Aug 25, 2021
8f29a9a
Explicitly close the inserter before focusing block
WunderBart Aug 27, 2021
3dc4cea
Simplify transformBlockTo util
WunderBart Aug 27, 2021
f6812eb
Bring focus back to image block to hide the caption toolbar
WunderBart Aug 27, 2021
b6258f8
Update packages to see if it fixes the npm issues
WunderBart Aug 27, 2021
15eff88
Activate TwentyTwentyOne to align with trunk
WunderBart Sep 7, 2021
8b9a566
Restore `focus` call for the Classic block
WunderBart Sep 7, 2021
3cdb35f
Press ArrowLeft instead of Home key
WunderBart Sep 7, 2021
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
Prev Previous commit
Next Next commit
Refactor insertBlock utility
- Type in directly when searching for block.
- Wait for the block to be stable when focused as the layout shifts when the Inserter closes.
- Remove unnecessary waitForInserterCloseAndContentFocus call because Playwright's auto-waiting does that automagically.
  • Loading branch information
WunderBart committed Sep 28, 2021
commit 6cc0bbf2d32cfd03bc2afba1dfe3f5763867865f
35 changes: 14 additions & 21 deletions packages/e2e-test-utils/src/inserter.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,17 @@ export async function toggleGlobalBlockInserter() {
* Moves focus to the selected block.
*/
async function focusSelectedBlock() {
// Ideally there shouuld be a UI way to do this. (Focus the selected block)
await page.evaluate( () => {
wp.data
.dispatch( 'core/block-editor' )
.selectBlock(
wp.data
.select( 'core/block-editor' )
.getSelectedBlockClientId(),
0
);
} );
// Do a waitForFunction and wait until block is really focused
const blockId = await page.evaluate( () =>
wp.data.select( 'core/block-editor' ).getSelectedBlockClientId()
);
const blockElement = await page.waitForSelector(
`[data-block="${ blockId }"]`
);
await page.evaluate( ( id ) => {
wp.data.dispatch( 'core/block-editor' ).selectBlock( id, 0 );
}, blockId );
await blockElement.waitForElementState( 'stable' );
}

/**
Expand All @@ -94,10 +94,8 @@ async function waitForInserterCloseAndContentFocus() {
*/
export async function searchForBlock( searchTerm ) {
await openGlobalBlockInserter();
await page.waitForSelector( INSERTER_SEARCH_SELECTOR );
await page.focus( INSERTER_SEARCH_SELECTOR );
await pressKeyWithModifier( 'primary', 'a' );
await page.keyboard.type( searchTerm );
await page.fill( INSERTER_SEARCH_SELECTOR, '' );
await page.type( INSERTER_SEARCH_SELECTOR, searchTerm );
}

/**
Expand Down Expand Up @@ -152,13 +150,8 @@ export async function searchForReusableBlock( searchTerm ) {
*/
export async function insertBlock( searchTerm ) {
await searchForBlock( searchTerm );
const insertButton = await page.waitForXPath(
`//button//span[contains(text(), '${ searchTerm }')]`
);
await insertButton.click();
await page.click( `button :text("${ searchTerm }")` );
await focusSelectedBlock();
// We should wait until the inserter closes and the focus moves to the content.
await waitForInserterCloseAndContentFocus();
}

/**
Expand Down