Skip to content

Commit

Permalink
Fix flaky template revert e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka committed May 22, 2023
1 parent 85ae2f8 commit 07067dc
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions test/e2e/specs/site-editor/template-revert.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' );

test.use( {
templateRevertUtils: async ( { page }, use ) => {
await use( new TemplateRevertUtils( { page } ) );
templateRevertUtils: async ( { editor, page }, use ) => {
await use( new TemplateRevertUtils( { editor, page } ) );
},
} );

Expand Down Expand Up @@ -39,7 +39,6 @@ test.describe( 'Template Revert', () => {
await templateRevertUtils.revertTemplate();
await editor.saveSiteEditorEntities();

await page.click( 'role=button[name="Settings"i]' );
const isTemplateTabVisible = await page
.locator(
'role=region[name="Editor settings"i] >> role=button[name="Template"i]'
Expand Down Expand Up @@ -286,12 +285,13 @@ test.describe( 'Template Revert', () => {
} );

class TemplateRevertUtils {
constructor( { page } ) {
constructor( { editor, page } ) {
this.editor = editor;
this.page = page;
}

async revertTemplate() {
await this.page.click( 'role=button[name="Settings"i]' );
await this.editor.openDocumentSettingsSidebar();
const isTemplateTabVisible = await this.page
.locator(
'role=region[name="Editor settings"i] >> role=button[name="Template"i]'
Expand All @@ -309,7 +309,6 @@ class TemplateRevertUtils {
await this.page.waitForSelector(
'role=button[name="Dismiss this notice"i] >> text="Template reverted."'
);
await this.page.click( 'role=button[name="Settings"i]' );
}

async getCurrentSiteEditorContent() {
Expand Down

0 comments on commit 07067dc

Please sign in to comment.