Skip to content

Commit cfacffd

Browse files
committed
Resort to waiting for canvas after editor is open
1 parent 1ea3bc3 commit cfacffd

10 files changed

Lines changed: 20 additions & 8 deletions

File tree

‎packages/e2e-test-utils-playwright/src/admin/create-new-post.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,6 @@ export async function createNewPost(
3535
welcomeGuide: options.showWelcomeGuide ?? false,
3636
fullscreenMode: false,
3737
} );
38+
39+
await this.editor.canvas.locator( 'body' ).waitFor( { state: 'visible' } );
3840
}

‎packages/e2e-test-utils-playwright/src/admin/edit-post.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,6 @@ export async function editPost( this: Admin, postId: string | number ) {
2121
welcomeGuide: false,
2222
fullscreenMode: false,
2323
} );
24+
25+
await this.editor.canvas.locator( 'body' ).waitFor( { state: 'visible' } );
2426
}

‎packages/e2e-test-utils-playwright/src/editor/get-blocks.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ export async function getBlocks(
2323
this: Editor,
2424
{ clientId, full = false }: { clientId?: string; full?: boolean } = {}
2525
) {
26-
await this.canvas.locator( 'body' ).waitFor( { state: 'visible' } );
26+
await this.page.waitForFunction(
27+
() => window?.wp?.blocks && window?.wp?.data
28+
);
2729

2830
return await this.page.evaluate(
2931
( [ _full, _clientId ] ) => {

‎packages/e2e-test-utils-playwright/src/editor/get-edited-post-content.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import type { Editor } from './index';
1111
* @return Promise resolving with post content markup.
1212
*/
1313
export async function getEditedPostContent( this: Editor ) {
14-
await this.canvas.locator( 'body' ).waitFor( { state: 'visible' } );
14+
await this.page.waitForFunction( () => window?.wp?.data );
1515

1616
return await this.page.evaluate( () =>
1717
window.wp.data.select( 'core/editor' ).getEditedPostContent()

‎packages/e2e-test-utils-playwright/src/editor/insert-block.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ async function insertBlock(
2222
blockRepresentation: BlockRepresentation,
2323
{ clientId }: { clientId?: string } = {}
2424
) {
25-
await this.canvas.locator( 'body' ).waitFor( { state: 'visible' } );
25+
await this.page.waitForFunction(
26+
() => window?.wp?.blocks && window?.wp?.data
27+
);
2628

2729
await this.page.evaluate(
2830
( [ _blockRepresentation, _clientId ] ) => {

‎packages/e2e-test-utils-playwright/src/editor/set-content.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ import type { Editor } from './index';
1010
* @param html Serialized block HTML.
1111
*/
1212
async function setContent( this: Editor, html: string ) {
13-
await this.canvas.locator( 'body' ).waitFor( { state: 'visible' } );
13+
await this.page.waitForFunction(
14+
() => window?.wp?.blocks && window?.wp?.data
15+
);
1416

1517
await this.page.evaluate( ( _html ) => {
1618
const blocks = window.wp.blocks.parse( _html );

‎packages/e2e-test-utils-playwright/src/editor/set-is-fixed-toolbar.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type { Editor } from './index';
1010
* @param isFixed Boolean value true/false for on/off.
1111
*/
1212
export async function setIsFixedToolbar( this: Editor, isFixed: boolean ) {
13-
await this.canvas.locator( 'body' ).waitFor( { state: 'visible' } );
13+
await this.page.waitForFunction( () => window?.wp?.data );
1414

1515
await this.page.evaluate( ( _isFixed ) => {
1616
window.wp.data

‎packages/e2e-test-utils-playwright/src/editor/set-preferences.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export async function setPreferences(
2020
context: PreferencesContext,
2121
preferences: Record< string, any >
2222
) {
23-
await this.canvas.locator( 'body' ).waitFor( { state: 'visible' } );
23+
await this.page.waitForFunction( () => window?.wp?.data );
2424

2525
await this.page.evaluate(
2626
async ( props ) => {

‎packages/e2e-test-utils-playwright/src/editor/switch-to-legacy-canvas.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type { Editor } from './index';
99
* @param this
1010
*/
1111
export async function switchToLegacyCanvas( this: Editor ) {
12-
await this.canvas.locator( 'body' ).waitFor( { state: 'visible' } );
12+
await this.page.waitForFunction( () => window?.wp?.blocks );
1313

1414
await this.page.evaluate( () => {
1515
window.wp.blocks.registerBlockType( 'test/v2', {

‎packages/e2e-test-utils-playwright/src/editor/transform-block-to.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ import type { Editor } from './index';
1010
* @param name Block name.
1111
*/
1212
export async function transformBlockTo( this: Editor, name: string ) {
13-
await this.canvas.locator( 'body' ).waitFor( { state: 'visible' } );
13+
await this.page.waitForFunction(
14+
() => window?.wp?.blocks && window?.wp?.data
15+
);
1416

1517
await this.page.evaluate(
1618
( [ blockName ] ) => {

0 commit comments

Comments
 (0)