Blocks E2E: Fix template revert tests (#46373)

This commit is contained in:
Bart Kalisz 2024-04-09 17:03:00 +02:00 committed by GitHub
parent 24bed48bb8
commit 7f6d21395e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 13 deletions

View File

@ -2,7 +2,7 @@
* External dependencies * External dependencies
*/ */
import { Page } from '@playwright/test'; import { Page } from '@playwright/test';
import { Editor } from '@wordpress/e2e-test-utils-playwright'; import { Editor, expect } from '@wordpress/e2e-test-utils-playwright';
import { BlockRepresentation } from '@wordpress/e2e-test-utils-playwright/build-types/editor/insert-block'; import { BlockRepresentation } from '@wordpress/e2e-test-utils-playwright/build-types/editor/insert-block';
/** /**
@ -425,27 +425,24 @@ export class EditorUtils {
} }
async revertTemplateCustomizations( templateName: string ) { async revertTemplateCustomizations( templateName: string ) {
await this.page.getByPlaceholder( 'Search' ).fill( templateName );
const templateRow = this.page.getByRole( 'row' ).filter( { const templateRow = this.page.getByRole( 'row' ).filter( {
has: this.page.getByRole( 'link', { has: this.page.getByRole( 'link', {
name: templateName, name: templateName,
exact: true, exact: true,
} ), } ),
} ); } );
const resetButton = templateRow.getByRole( 'button', { const resetButton = templateRow.getByLabel( 'Reset', { exact: true } );
name: 'Reset', const revertedNotice = this.page
} );
const waitForReset = this.page
.getByLabel( 'Dismiss this notice' ) .getByLabel( 'Dismiss this notice' )
.getByText( `"${ templateName }" reverted.` ) .getByText( `"${ templateName }" reverted.` );
.waitFor(); const savedButton = this.page.getByRole( 'button', { name: 'Saved' } );
const waitForSavedLabel = this.page
.getByRole( 'button', { name: 'Saved' } )
.waitFor();
await resetButton.click(); await resetButton.click();
await waitForSavedLabel;
await waitForReset; await expect( revertedNotice ).toBeVisible();
await expect( savedButton ).toBeVisible();
} }
async updatePost() { async updatePost() {

View File

@ -0,0 +1,4 @@
Significance: patch
Type: dev
Fix template revert tests where the template is unreachable due to pagination.