From ba01e5d7851d6211d020687b5ae927f47ea4683e Mon Sep 17 00:00:00 2001 From: Ramon Date: Wed, 19 Oct 2022 14:55:55 +1100 Subject: [PATCH] E2E tests: update button selector (#45087) * Update E2E test after Post editor: Rename view to Preview (#45074) * Follow ups * Mucho linto --- packages/e2e-test-utils-playwright/src/editor/preview.ts | 5 ++++- test/e2e/specs/editor/various/new-post.spec.js | 4 ++-- test/e2e/specs/editor/various/preview.spec.js | 6 +++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/packages/e2e-test-utils-playwright/src/editor/preview.ts b/packages/e2e-test-utils-playwright/src/editor/preview.ts index a71249d7bb62b6..e3aef98ca9c81e 100644 --- a/packages/e2e-test-utils-playwright/src/editor/preview.ts +++ b/packages/e2e-test-utils-playwright/src/editor/preview.ts @@ -19,7 +19,10 @@ export async function openPreviewPage( this: Editor ): Promise< Page > { const editorTopBar = this.page.locator( 'role=region[name="Editor top bar"i]' ); - const previewButton = editorTopBar.locator( 'role=button[name="View"i]' ); + const previewButton = editorTopBar.locator( + 'role=button[name="Preview"i]' + ); + await previewButton.click(); const [ previewPage ] = await Promise.all( [ diff --git a/test/e2e/specs/editor/various/new-post.spec.js b/test/e2e/specs/editor/various/new-post.spec.js index d9ffc0a4840cb0..e58e8ed94ffc56 100644 --- a/test/e2e/specs/editor/various/new-post.spec.js +++ b/test/e2e/specs/editor/various/new-post.spec.js @@ -30,9 +30,9 @@ test.describe( 'new editor state', () => { await expect( title ).toBeEditable(); await expect( title ).toHaveText( '' ); - // Should display the View button. + // Should display the Preview button. await expect( - page.locator( 'role=button[name="View"i]' ) + page.locator( 'role=button[name="Preview"i]' ) ).toBeVisible(); // Should display the Post Formats UI. diff --git a/test/e2e/specs/editor/various/preview.spec.js b/test/e2e/specs/editor/various/preview.spec.js index aaf816d1803a78..be2f4ddb65d27b 100644 --- a/test/e2e/specs/editor/various/preview.spec.js +++ b/test/e2e/specs/editor/various/preview.spec.js @@ -24,7 +24,7 @@ test.describe( 'Preview', () => { // Disabled until content present. await expect( - editorPage.locator( 'role=button[name="View"i]' ) + editorPage.locator( 'role=button[name="Preview"i]' ) ).toBeDisabled(); await editorPage.type( @@ -282,7 +282,7 @@ test.describe( 'Preview with private custom post type', () => { await admin.createNewPost( { postType: 'not_public', title: 'aaaaa' } ); // Open the view menu. - await page.click( 'role=button[name="View"i]' ); + await page.click( 'role=button[name="Preview"i]' ); await expect( page.locator( 'role=menuitem[name="Preview in new tab"i]' ) @@ -297,7 +297,7 @@ class PreviewUtils { async waitForPreviewNavigation( previewPage ) { const previewToggle = this.page.locator( - 'role=button[name="View"i][expanded=false]' + 'role=button[name="Preview"i][expanded=false]' ); const isDropdownClosed = await previewToggle.isVisible(); if ( isDropdownClosed ) {