Commit ca418b829af for woocommerce
commit ca418b829af2618400008f932d544cb709efb58e
Author: Rostislav Wolný <1082140+costasovo@users.noreply.github.com>
Date: Wed Sep 9 09:04:33 2026 +0200
Fix leaked dialog listener in the brands E2E test (#68465)
Fix leaked dialog listener in brands E2E delete flow
WordPress binds the delete confirm on the term edit page from a footer
script on DOM ready. On a slow runner the Delete link is clickable before
that happens, so the click follows the link with no confirm. The
page.once( 'dialog' ) listener registered for it stays behind, and when the
next delete does raise a confirm both listeners call accept(), which fails
with "Cannot accept dialog which is already handled!".
Wait for the term edit page to finish loading before clicking Delete, so
the confirm always fires and each listener is consumed by its own dialog.
diff --git a/plugins/woocommerce/tests/e2e/tests/brands/create-product-brand.spec.ts b/plugins/woocommerce/tests/e2e/tests/brands/create-product-brand.spec.ts
index 03c04b9f764..9b90d59bfea 100644
--- a/plugins/woocommerce/tests/e2e/tests/brands/create-product-brand.spec.ts
+++ b/plugins/woocommerce/tests/e2e/tests/brands/create-product-brand.spec.ts
@@ -144,6 +144,11 @@ test( 'Merchant can add brands', async ( { page } ) => {
.first()
.click();
+ // The delete confirm is bound by a footer script on DOM ready. Clicking
+ // "Delete" before the page has loaded follows the link with no dialog and
+ // leaves the listener below to fire on the next delete.
+ await page.waitForURL( /term\.php/ );
+
// After clicking the "Delete" button, there will be a confirmation dialog.
page.once( 'dialog', ( dialog ) => {
// Click "OK" to confirm the deletion.