Skip to content

Commit

Permalink
Gutenberg 19.9: Fix the Site Editor Smoke Test (#97763)
Browse files Browse the repository at this point in the history
  • Loading branch information
fushar authored Dec 24, 2024
1 parent 7c98dc2 commit f8b37f1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -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).
Expand All @@ -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();
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Page } from 'playwright';
import envVariables from '../../env-variables';
import { EditorComponent } from './editor-component';

const selectors = {
Expand Down Expand Up @@ -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();
}
}

/**
Expand Down

0 comments on commit f8b37f1

Please sign in to comment.