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
*/
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';
/**
@ -425,27 +425,24 @@ export class EditorUtils {
}
async revertTemplateCustomizations( templateName: string ) {
await this.page.getByPlaceholder( 'Search' ).fill( templateName );
const templateRow = this.page.getByRole( 'row' ).filter( {
has: this.page.getByRole( 'link', {
name: templateName,
exact: true,
} ),
} );
const resetButton = templateRow.getByRole( 'button', {
name: 'Reset',
} );
const waitForReset = this.page
const resetButton = templateRow.getByLabel( 'Reset', { exact: true } );
const revertedNotice = this.page
.getByLabel( 'Dismiss this notice' )
.getByText( `"${ templateName }" reverted.` )
.waitFor();
const waitForSavedLabel = this.page
.getByRole( 'button', { name: 'Saved' } )
.waitFor();
.getByText( `"${ templateName }" reverted.` );
const savedButton = this.page.getByRole( 'button', { name: 'Saved' } );
await resetButton.click();
await waitForSavedLabel;
await waitForReset;
await expect( revertedNotice ).toBeVisible();
await expect( savedButton ).toBeVisible();
}
async updatePost() {

View File

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