Skip to content

Commit 4631b99

Browse files
authored
Fix various E2E tests for recent Gutenberg changes (#86070)
* WordPress/gutenberg#56921 changed the label of the preview button from "Preview" to "View". * WordPress/gutenberg#56904 removed the setting of an `is-xxx-preview` class when using the in-page preview. Targeting the parent element (that has a static class) instead. * #86033 attempted to fix a test for another Gutenberg change, but the selector used there matches multiple elements in one of our tests and so causes it to fail. Adding `[role="tab"]` into the selector fixes that.
1 parent e307b3d commit 4631b99

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

packages/calypso-e2e/src/lib/components/editor-settings-sidebar-component.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ const panel = '[aria-label="Editor settings"]';
77

88
const selectors = {
99
// Tab
10-
tabButton: ( tabName: EditorSidebarTab ) => `${ panel } button:has-text("${ tabName }")`,
10+
tabButton: ( tabName: EditorSidebarTab ) =>
11+
`${ panel } button[role="tab"]:has-text("${ tabName }")`,
1112
activeTabButton: ( tabName: EditorSidebarTab ) =>
12-
`${ panel } button[aria-selected="true"]:has-text("${ tabName }")`,
13+
`${ panel } button[aria-selected="true"][role="tab"]:has-text("${ tabName }")`,
1314

1415
// General section-related
1516
section: ( name: string ) =>

packages/calypso-e2e/src/lib/components/editor-toolbar-component.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ const selectors = {
1515
switchToDraftButton: `${ panel } button.editor-post-switch-to-draft`,
1616

1717
// Preview
18-
previewButton: `${ panel } :text("Preview"):visible, [aria-label="Preview"]:visible`,
18+
previewButton: `${ panel } :text("Preview"):visible, [aria-label="View"]:visible`,
1919
desktopPreviewMenuItem: ( target: EditorPreviewOptions ) =>
2020
`button[role="menuitem"] span:text("${ target }")`,
21-
previewPane: ( target: EditorPreviewOptions ) => `.is-${ target.toLowerCase() }-preview`,
21+
previewPane: `.edit-post-visual-editor`,
2222

2323
// Publish
2424
publishButton: ( state: 'disabled' | 'enabled' ) => {
@@ -199,7 +199,7 @@ export class EditorToolbarComponent {
199199
await desktopPreviewMenuItemLocator.click();
200200

201201
// Verify the editor panel is resized and stable.
202-
const desktopPreviewPaneLocator = editorParent.locator( selectors.previewPane( target ) );
202+
const desktopPreviewPaneLocator = editorParent.locator( selectors.previewPane );
203203
await desktopPreviewPaneLocator.waitFor();
204204
const elementHandle = await desktopPreviewPaneLocator.elementHandle();
205205
await elementHandle?.waitForElementState( 'stable' );
@@ -214,7 +214,7 @@ export class EditorToolbarComponent {
214214
async openDesktopPreviewMenu(): Promise< void > {
215215
const editorParent = await this.editor.parent();
216216

217-
const translatedButtonName = await this.translateFromPage( 'Preview' );
217+
const translatedButtonName = await this.translateFromPage( 'View' );
218218
const previewButton = editorParent.getByRole( 'button', {
219219
name: translatedButtonName,
220220
exact: true,
@@ -233,7 +233,7 @@ export class EditorToolbarComponent {
233233
async closeDesktopPreviewMenu(): Promise< void > {
234234
const editorParent = await this.editor.parent();
235235

236-
const translatedButtonName = await this.translateFromPage( 'Preview' );
236+
const translatedButtonName = await this.translateFromPage( 'View' );
237237
const previewButton = editorParent.getByRole( 'button', {
238238
name: translatedButtonName,
239239
exact: true,

0 commit comments

Comments
 (0)