diff --git a/test/e2e/specs/editor/various/post-editor-template-mode.spec.js b/test/e2e/specs/editor/various/post-editor-template-mode.spec.js index 414f81a85215fd..64b0278d5e8593 100644 --- a/test/e2e/specs/editor/various/post-editor-template-mode.spec.js +++ b/test/e2e/specs/editor/various/post-editor-template-mode.spec.js @@ -253,12 +253,14 @@ class PostEditorTemplateMode { ) ).toBeVisible(); - // Wait for the editor to be loaded and ready before making changes. - // Without this, the editor will move focus to body while still typing. - // And the save states will not be counted as dirty. - // There is likely a bug in the code, waiting for the snackbar above should be enough. - // eslint-disable-next-line playwright/no-networkidle - await this.page.waitForLoadState( 'networkidle' ); + // Wait for the editor to be fully loaded and ready before making changes. + // Without this, the editor may move focus to body while still typing, + // and save states will not be counted as dirty. + await this.page.waitForFunction( + () => + window.wp?.data?.select( 'core/block-editor' )?.getBlocks() + ?.length > 0 + ); } async saveTemplateWithoutPublishing() { diff --git a/test/e2e/specs/site-editor/site-editor-url-navigation.spec.js b/test/e2e/specs/site-editor/site-editor-url-navigation.spec.js index 3c8ff9f7e14771..aa7a76f29ecb39 100644 --- a/test/e2e/specs/site-editor/site-editor-url-navigation.spec.js +++ b/test/e2e/specs/site-editor/site-editor-url-navigation.spec.js @@ -44,14 +44,11 @@ test.describe( 'Site editor url navigation', () => { await admin.visitSiteEditor(); await page.click( 'role=button[name="Templates"]' ); await page.click( 'role=button[name="Add Template"i]' ); - // Wait for network idle to avoid flaky tests. - // eslint-disable-next-line playwright/no-networkidle - await page.waitForLoadState( 'networkidle' ); - await page - .getByRole( 'button', { - name: 'Single item: Post', - } ) - .click(); + const singleItemPost = page.getByRole( 'button', { + name: 'Single item: Post', + } ); + await expect( singleItemPost ).toBeEnabled(); + await singleItemPost.click(); await page .getByRole( 'button', { name: 'For a specific item' } ) .click();