Commit bca9935936e for woocommerce
commit bca9935936ee70f30860e491d1bfec1def66161b
Author: Karol Manijak <20098064+kmanijak@users.noreply.github.com>
Date: Tue Aug 11 11:48:39 2026 +0200
Make template cards stricter to avoid tests flakiness (#67098)
* Scope template revert action to requested card
* Add changelog comment for template revert action
* Restore template search grid synchronization
diff --git a/plugins/woocommerce/changelog/fix-blocks-e2e-template-revert-action b/plugins/woocommerce/changelog/fix-blocks-e2e-template-revert-action
new file mode 100644
index 00000000000..9006cf2dc20
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-blocks-e2e-template-revert-action
@@ -0,0 +1,3 @@
+Significance: patch
+Type: dev
+Comment: Scope the Blocks E2E template revert action to the requested template card; test-only, no merchant-facing change.
diff --git a/plugins/woocommerce/tests/e2e/utils/blocks/editor/editor-utils.page.ts b/plugins/woocommerce/tests/e2e/utils/blocks/editor/editor-utils.page.ts
index 83f70fd5c59..09446fb3829 100644
--- a/plugins/woocommerce/tests/e2e/utils/blocks/editor/editor-utils.page.ts
+++ b/plugins/woocommerce/tests/e2e/utils/blocks/editor/editor-utils.page.ts
@@ -129,20 +129,26 @@ export class Editor extends CoreEditor {
* Search for a template or template part in the Site Editor.
*/
async searchTemplate( { templateName }: { templateName: string } ) {
+ const templateCards = this.page.locator(
+ '.dataviews-view-grid .dataviews-view-grid__card'
+ );
+
+ await expect( templateCards.first() ).toBeVisible();
+ const templatesBeforeSearch = await templateCards.count();
+
await this.page.getByPlaceholder( 'Search' ).fill( templateName );
await expect(
this.page.getByRole( 'button', { name: 'Reset Search' } )
).toBeVisible();
await expect( this.page.getByLabel( 'No results' ) ).toBeHidden();
- await expect(
- this.page
- .getByRole( 'button', {
- name: templateName,
- exact: true,
- } )
- .first()
- ).toBeVisible();
+
+ // Wait for the grid to update with fewer items than before.
+ // Using expect.poll() for a retrying assertion since toHaveCount
+ // requires an exact number.
+ await expect
+ .poll( () => templateCards.count(), { timeout: 5000 } )
+ .toBeLessThan( templatesBeforeSearch );
}
/**
@@ -171,8 +177,14 @@ export class Editor extends CoreEditor {
await this.searchTemplate( { templateName } );
await this.page
+ .locator( '.dataviews-view-grid .dataviews-view-grid__card' )
+ .filter( {
+ has: this.page.getByRole( 'button', {
+ name: templateName,
+ exact: true,
+ } ),
+ } )
.getByRole( 'button', { name: 'Actions' } )
- .first()
.click();
await this.page
.getByRole( 'menuitem', { name: /Reset|Delete/ } )