diff --git a/test/e2e/specs/classic-editor.test.js b/test/e2e/specs/classic-editor.test.js index e6664bcf098ea3..0d51c93e5b3420 100644 --- a/test/e2e/specs/classic-editor.test.js +++ b/test/e2e/specs/classic-editor.test.js @@ -10,14 +10,14 @@ describe( 'classic editor', () => { it( 'Should work properly', async () => { // Click visual editor - await page.click( '#content-tmce' ); - await page.click( '#content_ifr' ); + await expect( page ).toClick( '#content-tmce' ); + await expect( page ).toClick( '#content_ifr' ); // type some random text await page.keyboard.type( 'Typing in classic editor' ); // Switch to HTML mode - await page.click( '#content-html' ); + await expect( page ).toClick( '#content-html' ); const textEditorContent = await page.$eval( '.wp-editor-area', ( element ) => element.value ); expect( textEditorContent ).toEqual( 'Typing in classic editor' ); diff --git a/test/e2e/specs/undo.test.js b/test/e2e/specs/undo.test.js index 66e4dc941718c0..0c2eb1357695d1 100644 --- a/test/e2e/specs/undo.test.js +++ b/test/e2e/specs/undo.test.js @@ -14,7 +14,6 @@ describe( 'undo', () => { } ); it( 'Should undo to expected level intervals', async () => { - await page.waitForSelector( '.editor-default-block-appender__content' ); await clickBlockAppender(); await page.keyboard.type( 'This' ); diff --git a/test/e2e/support/setup-test-framework.js b/test/e2e/support/setup-test-framework.js index ad0b4a2996fc46..6651900f628769 100644 --- a/test/e2e/support/setup-test-framework.js +++ b/test/e2e/support/setup-test-framework.js @@ -22,6 +22,11 @@ const { PUPPETEER_TIMEOUT } = process.env; // The Jest timeout is increased because these tests are a bit slow jest.setTimeout( PUPPETEER_TIMEOUT || 100000 ); +async function setupBrowser() { + await clearLocalStorage(); + await setViewport( 'large' ); +} + // Before every test suite run, delete all content created by the test. This ensures // other posts/comments/etc. aren't dirtying tests and tests don't depend on // each other's side-effects. @@ -45,11 +50,11 @@ beforeAll( async () => { '//*[contains(@class, "updated notice")]/p[contains(text(), "moved to the Trash.")]' ); } + await setupBrowser(); } ); -beforeEach( async () => { - await clearLocalStorage(); - await setViewport( 'large' ); +afterEach( async () => { + await setupBrowser(); } ); afterAll( () => { diff --git a/test/e2e/support/utils.js b/test/e2e/support/utils.js index 6e8a646d67c5db..61fdba52b7ceb0 100644 --- a/test/e2e/support/utils.js +++ b/test/e2e/support/utils.js @@ -169,7 +169,7 @@ export async function ensureSidebarOpened() { * Clicks the default block appender. */ export async function clickBlockAppender() { - await page.click( '.editor-default-block-appender__content' ); + await expect( page ).toClick( '.editor-default-block-appender__content' ); } /** @@ -226,7 +226,7 @@ export async function pressWithModifier( modifier, key ) { * @param {string} buttonLabel The label to search the button for. */ export async function clickOnMoreMenuItem( buttonLabel ) { - await page.click( '.edit-post-more-menu [aria-label="More"]' ); + await expect( page ).toClick( '.edit-post-more-menu [aria-label="More"]' ); const itemButton = ( await page.$x( `//button[contains(text(), '${ buttonLabel }')]` ) )[ 0 ]; await itemButton.click( 'button' ); }