Commit a6cf483aa84 for woocommerce
commit a6cf483aa843cfcdfc4ebab378ce7801d0e9d508
Author: Karol Manijak <20098064+kmanijak@users.noreply.github.com>
Date: Wed Jul 29 10:13:49 2026 +0200
Fix template search wait in Blocks E2E tests (#67091)
* Fix template search wait in Blocks E2E tests
* Add changelog entry for Blocks E2E template search fix
diff --git a/plugins/woocommerce/changelog/fix-blocks-e2e-template-search-race b/plugins/woocommerce/changelog/fix-blocks-e2e-template-search-race
new file mode 100644
index 00000000000..77172773148
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-blocks-e2e-template-search-race
@@ -0,0 +1,3 @@
+Significance: patch
+Type: dev
+Comment: Fix the Blocks E2E template search helper to wait for the requested result instead of comparing card counts; 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 573f427ee03..83f70fd5c59 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,24 +129,20 @@ 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'
- );
- 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();
-
- // 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 );
+ await expect(
+ this.page
+ .getByRole( 'button', {
+ name: templateName,
+ exact: true,
+ } )
+ .first()
+ ).toBeVisible();
}
/**