From f8b37f11c7a876f716332d81e5701e4ba5df99ff Mon Sep 17 00:00:00 2001 From: Ashar Fuadi Date: Tue, 24 Dec 2024 21:30:30 +0700 Subject: [PATCH] Gutenberg 19.9: Fix the Site Editor Smoke Test (#97763) --- .../full-side-editor-data-views-component.ts | 14 +------------- .../full-side-editor-nav-sidebar-component.ts | 14 ++++++++++---- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/packages/calypso-e2e/src/lib/components/full-side-editor-data-views-component.ts b/packages/calypso-e2e/src/lib/components/full-side-editor-data-views-component.ts index 72a5d3e8f30da..0427153ae9341 100644 --- a/packages/calypso-e2e/src/lib/components/full-side-editor-data-views-component.ts +++ b/packages/calypso-e2e/src/lib/components/full-side-editor-data-views-component.ts @@ -1,11 +1,6 @@ import { Page } from 'playwright'; import { EditorComponent } from './editor-component'; -const selectors = { - primaryFieldByText: ( tableOrGrid: string, primaryFieldText: string ) => - `.dataviews-view-${ tableOrGrid }__primary-field:has-text("${ primaryFieldText }") a`, -}; - /** * Represents an instance of the WordPress.com FSE Editor's DataViews. * This is used for data layouts (e.g. tables, grids, and lists). @@ -30,13 +25,6 @@ export class FullSiteEditorDataViewsComponent { */ async clickPrimaryFieldByExactText( primaryFieldText: string ): Promise< void > { const editorParent = await this.editor.parent(); - const primaryFieldInTable = editorParent.locator( - selectors.primaryFieldByText( 'table', primaryFieldText ) - ); - const primaryFieldInGrid = editorParent.locator( - selectors.primaryFieldByText( 'grid', primaryFieldText ) - ); - - await Promise.race( [ primaryFieldInTable.click(), primaryFieldInGrid.click() ] ); + await editorParent.getByRole( 'button', { name: primaryFieldText } ).first().click(); } } diff --git a/packages/calypso-e2e/src/lib/components/full-side-editor-nav-sidebar-component.ts b/packages/calypso-e2e/src/lib/components/full-side-editor-nav-sidebar-component.ts index 95b5c2b012ca2..cb3d7f2354f33 100644 --- a/packages/calypso-e2e/src/lib/components/full-side-editor-nav-sidebar-component.ts +++ b/packages/calypso-e2e/src/lib/components/full-side-editor-nav-sidebar-component.ts @@ -1,4 +1,5 @@ import { Page } from 'playwright'; +import envVariables from '../../env-variables'; import { EditorComponent } from './editor-component'; const selectors = { @@ -91,10 +92,15 @@ export class FullSiteEditorNavSidebarComponent { */ async clickNavButtonByExactText( text: string ): Promise< void > { const editorParent = await this.editor.parent(); - await editorParent - .getByLabel( 'Navigation' ) - .getByRole( 'button', { name: text, exact: true } ) - .click(); + + if ( envVariables.VIEWPORT_NAME === 'mobile' ) { + await editorParent.getByRole( 'button', { name: text, exact: true } ).click(); + } else { + await editorParent + .getByLabel( 'Navigation' ) + .getByRole( 'button', { name: text, exact: true } ) + .click(); + } } /**