Skip to content

Commit

Permalink
Performance: Fix first block locator's page reference (#54188)
Browse files Browse the repository at this point in the history
  • Loading branch information
WunderBart committed Sep 5, 2023
1 parent b7f4ef5 commit bcaac56
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
10 changes: 6 additions & 4 deletions test/performance/specs/post-editor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,19 @@ test.describe( 'Post Editor Performance', () => {
// Get canvas (handles both legacy and iframed canvas).
const canvas = await Promise.any( [
( async () => {
const legacyCanvasLocator = page.locator(
const legacyCanvasLocator = testPage.locator(
'.wp-block-post-content'
);
await legacyCanvasLocator.waitFor();
await legacyCanvasLocator.waitFor( { timeout: 120_000 } );
return legacyCanvasLocator;
} )(),
( async () => {
const iframedCanvasLocator = page.frameLocator(
const iframedCanvasLocator = testPage.frameLocator(
'[name=editor-canvas]'
);
await iframedCanvasLocator.locator( 'body' ).waitFor();
await iframedCanvasLocator
.locator( 'body' )
.waitFor( { timeout: 120_000 } );
return iframedCanvasLocator;
} )(),
] );
Expand Down
11 changes: 2 additions & 9 deletions test/performance/specs/site-editor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,7 @@ test.describe( 'Site Editor Performance', () => {
).toBeDisabled();

// Get the ID of the saved page.
testPageId = await page.evaluate( () =>
new URL( document.location ).searchParams.get( 'post' )
);
testPageId = new URL( page.url() ).searchParams.get( 'post' );

// Open the test page in Site Editor.
await admin.visitSiteEditor( {
Expand All @@ -109,17 +107,12 @@ test.describe( 'Site Editor Performance', () => {
// Go to the test page URL.
await testPage.goto( draftURL );

// Wait for the canvas to appear.
await testPage
.locator( '.edit-site-canvas-loader' )
.waitFor( { state: 'hidden', timeout: 60_000 } );

// Wait for the first block.
await testPage
.frameLocator( 'iframe[name="editor-canvas"]' )
.locator( '.wp-block' )
.first()
.waitFor( { timeout: 60_000 } );
.waitFor( { timeout: 120_000 } );

// Save the results.
if ( i >= throwaway ) {
Expand Down

0 comments on commit bcaac56

Please sign in to comment.