Skip to content

Commit

Permalink
Fix test issues
Browse files Browse the repository at this point in the history
  • Loading branch information
talldan committed May 5, 2022
1 parent b3a4334 commit b14538e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export async function clickBlockOptionsMenuItem( this: Editor, label: string ) {
await this.clickBlockToolbarButton( 'Options' );
await this.page
.locator(
`role=menu[name="Options"i] >> role=menu-item[name="${ label }"i]`
`role=menu[name="Options"i] >> role=menuitem[name="${ label }"i]`
)
.click();
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type { Editor } from './index';
export async function clickBlockToolbarButton( this: Editor, label: string ) {
await this.showBlockToolbar();

const blockToolbar = this.canvas.locator(
const blockToolbar = this.page.locator(
'role=toolbar[name="Block tools"i]'
);
const button = blockToolbar.locator( `role=button[name="${ label }"]` );
Expand Down
2 changes: 1 addition & 1 deletion packages/e2e-test-utils-playwright/src/editor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { saveSiteEditorEntities } from './site-editor';

interface EditorConstructorParams {
page: Page;
hasIframe: boolean;
hasIframe?: boolean;
}

export class Editor {
Expand Down
12 changes: 7 additions & 5 deletions test/e2e/specs/site-editor/template-part.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,15 @@ test.describe( 'Template Part', () => {
const canvas = editor.canvas;

// Check that the header contains the paragraph added earlier.
const templatePartSelector = 'header[data-type="core/template-part"]';
const paragraphSelector = `p >> text="${ paragraphText }"`;
const paragraph = await canvas.locator( paragraphSelector );
const headerTemplatePart = await canvas.locator(
`header[data-type="core/template-part"] >> ${ paragraphSelector }`
const paragraphInTemplatePart = await canvas.locator(
`${ templatePartSelector } >> ${ paragraphSelector }`
);
await expect( paragraph ).toBeVisible();
await expect( paragraphInTemplatePart ).toBeVisible();

// Detach the blocks.
const headerTemplatePart = await canvas.locator( templatePartSelector );
const templatePartClientId = await headerTemplatePart.getAttribute(
'data-block'
);
Expand All @@ -103,7 +104,8 @@ test.describe( 'Template Part', () => {

// The paragraph should still be present, but the template part is no
// longer there.
await expect( paragraph ).toBeVisible();
const loneParagraph = await canvas.locator( paragraphSelector );
await expect( loneParagraph ).toBeVisible();
await expect( headerTemplatePart ).not.toBeVisible();
} );
} );

0 comments on commit b14538e

Please sign in to comment.