Skip to content

Commit

Permalink
Fix E2E test that opens page template (#89057)
Browse files Browse the repository at this point in the history
  • Loading branch information
tbradsha authored Mar 29, 2024
1 parent 5c53689 commit 8ec240a
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { Page } from 'playwright';
import { EditorComponent } from './editor-component';

const selectors = {
primaryFieldByText: ( primaryFieldText: string ) =>
`.dataviews-view-table__primary-field:has-text("${ primaryFieldText }")`,
};

/**
* Represents an instance of the WordPress.com FSE Editor's DataViews.
* This is used for data layouts (e.g. tables, grids, and lists).
*/
export class FullSiteEditorDataViewsComponent {
private page: Page;
private editor: EditorComponent;

/**
* Constructs an instance of the component.
*
* @param {Page} page The underlying page.
* @param {EditorComponent} editor The EditorComponent instance.
*/
constructor( page: Page, editor: EditorComponent ) {
this.page = page;
this.editor = editor;
}

/**
* Clicks on a button with the exact name.
*/
async clickPrimaryFieldByExactText( primaryFieldText: string ): Promise< void > {
const editorParent = await this.editor.parent();
await editorParent.locator( selectors.primaryFieldByText( primaryFieldText ) ).click();
}
}
1 change: 1 addition & 0 deletions packages/calypso-e2e/src/lib/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export * from './editor-block-toolbar-component';
export * from './template-part-list-component';
export * from './template-part-modal-component';
export * from './full-side-editor-nav-sidebar-component';
export * from './full-side-editor-data-views-component';
export * from './editor-dimensions-component';
export * from './jetpack-instant-search-modal-component';

Expand Down
13 changes: 13 additions & 0 deletions packages/calypso-e2e/src/lib/pages/full-site-editor-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
BlockToolbarButtonIdentifier,
TemplatePartListComponent,
FullSiteEditorNavSidebarComponent,
FullSiteEditorDataViewsComponent,
TemplatePartModalComponent,
OpenInlineInserter,
EditorInlineBlockInserterComponent,
Expand Down Expand Up @@ -56,6 +57,7 @@ export class FullSiteEditorPage {
private editorBlockToolbarComponent: EditorBlockToolbarComponent;
private fullSiteEditorSavePanelComponent: FullSiteEditorSavePanelComponent;
private fullSiteEditorNavSidebarComponent: FullSiteEditorNavSidebarComponent;
private fullSiteEditorDataViewsComponent: FullSiteEditorDataViewsComponent;
private templatePartModalComponent: TemplatePartModalComponent;
private templatePartListComponent: TemplatePartListComponent;
private cookieBannerComponent: CookieBannerComponent;
Expand All @@ -79,6 +81,10 @@ export class FullSiteEditorPage {
page,
this.editor
);
this.fullSiteEditorDataViewsComponent = new FullSiteEditorDataViewsComponent(
page,
this.editor
);
this.editorSidebarBlockInserterComponent = new EditorSidebarBlockInserterComponent(
page,
this.editor
Expand Down Expand Up @@ -167,6 +173,13 @@ export class FullSiteEditorPage {
await this.fullSiteEditorNavSidebarComponent.clickNavButtonByExactText( text );
}

/**
* Clicks DataViews primary field to open editor.
*/
async openTemplateEditor( text: string ): Promise< void > {
await this.fullSiteEditorDataViewsComponent.clickPrimaryFieldByExactText( text );
}

/**
* Ensures the nav sidebar is at the top level ("Design")
*/
Expand Down
3 changes: 1 addition & 2 deletions test/e2e/specs/fse/fse__temp-smoke-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ describe( DataHelper.createSuiteTitle( 'Site Editor Smoke Test' ), function () {

await fullSiteEditorPage.ensureNavigationTopLevel();
await fullSiteEditorPage.clickFullSiteNavigatorButton( 'Templates' );
await fullSiteEditorPage.clickFullSiteNavigatorButton( 'Index' );
await fullSiteEditorPage.clickFullSiteNavigatorButton( 'Edit' );
await fullSiteEditorPage.openTemplateEditor( 'Index' );
} );

it( 'Editor canvas loads', async function () {
Expand Down

0 comments on commit 8ec240a

Please sign in to comment.