Commit 443f459947 for woocommerce
commit 443f459947f5624fd5d8f625cb3efbd74d4c670c
Author: Adrian Moldovan <3854374+adimoldovan@users.noreply.github.com>
Date: Tue Jul 1 11:24:20 2025 +0300
[e2e tests] Fix flaky test - can add custom product attributes (#59275)
diff --git a/plugins/woocommerce/changelog/wooplug-4836-flaky-test-create-product-attributes-can-add-custom-product b/plugins/woocommerce/changelog/wooplug-4836-flaky-test-create-product-attributes-can-add-custom-product
new file mode 100644
index 0000000000..3c1c09d88c
--- /dev/null
+++ b/plugins/woocommerce/changelog/wooplug-4836-flaky-test-create-product-attributes-can-add-custom-product
@@ -0,0 +1,4 @@
+Significance: patch
+Type: dev
+
+E2E tests: fix flaky product attributes test
diff --git a/plugins/woocommerce/tests/e2e-pw/tests/product/create-product-attributes.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/product/create-product-attributes.spec.js
index ca1eb4175a..30e90f2d6f 100644
--- a/plugins/woocommerce/tests/e2e-pw/tests/product/create-product-attributes.spec.js
+++ b/plugins/woocommerce/tests/e2e-pw/tests/product/create-product-attributes.spec.js
@@ -119,20 +119,20 @@ async function addAttribute(
).toBeChecked();
} );
- await test.step( 'Click "Save attributes".', async () => {
+ await test.step( 'Save attributes', async () => {
+ const waitForSave = page.waitForResponse(
+ ( response ) =>
+ response.url().includes( '/post.php' ) &&
+ response.status() === 200
+ );
+
await page
.getByRole( 'button', {
name: 'Save attributes',
} )
.click();
- } );
- await test.step( "Wait for the tour's dismissal to be saved", async () => {
- await page.waitForResponse(
- ( response ) =>
- response.url().includes( '/post.php' ) &&
- response.status() === 200
- );
+ await waitForSave;
} );
await test.step( `Wait for the loading overlay to disappear.`, async () => {
@@ -158,23 +158,11 @@ test( 'can add custom product attributes', async ( { page, product } ) => {
}
await test.step( 'Update product', async () => {
- // "Update" triggers a lot of requests. Wait for the final one to complete before proceeding.
- // Otherwise, succeeding steps would be flaky.
- const finalRequestResolution = page.waitForResponse(
- ( response ) =>
- response.url().includes( 'options' ) &&
- response
- .url()
- .includes( 'woocommerce_task_list_reminder_bar_hidden' )
- );
-
await page
.locator( '#publishing-action' )
.getByRole( 'button', { name: 'Update' } )
.click();
- await finalRequestResolution;
-
await expect(
page.locator( '.notice-success', { name: 'Product updated' } )
).toBeVisible();