Commit ca59a74738 for woocommerce
commit ca59a74738f3531e531cbb24700a43f4f61c5ecf
Author: Thomas Roberts <5656702+opr@users.noreply.github.com>
Date: Thu Dec 11 22:41:19 2025 +0000
Attempt to wait for template search to update before resetting templates (#62350)
* Attempt to wait for template search to update before resetting templates
* Reduce timeout for polling for updated search results
diff --git a/plugins/woocommerce/client/blocks/tests/e2e/utils/editor/editor-utils.page.ts b/plugins/woocommerce/client/blocks/tests/e2e/utils/editor/editor-utils.page.ts
index d5a90b7181..79245e4a2d 100644
--- a/plugins/woocommerce/client/blocks/tests/e2e/utils/editor/editor-utils.page.ts
+++ b/plugins/woocommerce/client/blocks/tests/e2e/utils/editor/editor-utils.page.ts
@@ -118,12 +118,24 @@ 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: 3000 } )
+ .toBeLessThan( templatesBeforeSearch );
}
/**