Commit 3049f0860a for woocommerce
commit 3049f0860a34b798853d184c86368103f249092c
Author: Seghir Nadir <nadir.seghir@gmail.com>
Date: Tue Dec 16 13:41:41 2025 +0100
Fix flaky 'Can connect to WooCommerce.com' E2E test (#62235)
* Fix flaky 'Can connect to WooCommerce.com' E2E test
- Move waitForResponse setup before page.goto() to avoid race condition
- Add explicit timeouts for critical waits (30s)
- Use expect.poll() for URL assertion since page.url() doesn't auto-retry
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* Trigger CI with updated PR body
---------
Co-authored-by: Claude <noreply@anthropic.com>
diff --git a/plugins/woocommerce/tests/e2e-pw/tests/onboarding/setup-checklist.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/onboarding/setup-checklist.spec.js
index ef05a4b360..0d4331f9ff 100644
--- a/plugins/woocommerce/tests/e2e-pw/tests/onboarding/setup-checklist.spec.js
+++ b/plugins/woocommerce/tests/e2e-pw/tests/onboarding/setup-checklist.spec.js
@@ -119,16 +119,15 @@ test( 'Can connect to WooCommerce.com', async ( { page } ) => {
await test.step( 'Go to WC Home and make sure the total sales is visible', async () => {
await page
.getByRole( 'menuitem', { name: 'Total sales' } )
- .waitFor( { state: 'visible' } );
+ .waitFor( { state: 'visible', timeout: 30000 } );
} );
await test.step( 'Go to the extensions tab and connect store', async () => {
const connectButton = page.getByRole( 'link', {
name: 'Connect',
} );
- await page.goto(
- 'wp-admin/admin.php?page=wc-admin&tab=my-subscriptions&path=%2Fextensions'
- );
+
+ // Set up response waiter BEFORE navigation to avoid race condition
const waitForSubscriptionsResponse = page.waitForResponse(
( response ) =>
response
@@ -136,16 +135,24 @@ test( 'Can connect to WooCommerce.com', async ( { page } ) => {
.includes( '/wp-json/wc/v3/marketplace/subscriptions' ) &&
response.status() === 200
);
+
+ await page.goto(
+ 'wp-admin/admin.php?page=wc-admin&tab=my-subscriptions&path=%2Fextensions'
+ );
+
await expect(
page.getByText(
'Hundreds of vetted products and services. Unlimited potential.'
)
- ).toBeVisible();
+ ).toBeVisible( { timeout: 30000 } );
await expect(
page.getByRole( 'button', { name: 'My Subscriptions' } )
).toBeVisible();
await expect( connectButton ).toBeVisible();
+
+ // Wait for the API response before checking button attributes
await waitForSubscriptionsResponse;
+
await expect( connectButton ).toHaveAttribute(
'href',
/my-subscriptions/
@@ -154,7 +161,10 @@ test( 'Can connect to WooCommerce.com', async ( { page } ) => {
} );
await test.step( 'Check that we are sent to wp.com', async () => {
- await expect( page.url() ).toContain( 'wordpress.com/log-in' );
+ // Use polling assertion for URL check since page.url() is not auto-retrying
+ await expect
+ .poll( () => page.url(), { timeout: 30000 } )
+ .toContain( 'wordpress.com/log-in' );
await expect(
page.getByRole( 'heading', {
name: 'Log in to Woo with WordPress.com',