Skip to content

tests(e2e): improve activation test flakiness on ci#13

Merged
justlevine merged 1 commit intomainfrom
tests/e2e-waitfor
Mar 20, 2026
Merged

tests(e2e): improve activation test flakiness on ci#13
justlevine merged 1 commit intomainfrom
tests/e2e-waitfor

Conversation

@justlevine
Copy link
Copy Markdown
Collaborator

@justlevine justlevine commented Mar 20, 2026

What

Fix race condition in E2E activation test (tests/e2e/settings/activation.spec.ts) that caused flaky failures in CI environments.

Why

The test used Promise.all([page.waitForURL(/plugins.php/), click()]) which created a race condition:

  1. The regex /plugins.php/ matches the current URL (we're already on plugins.php)
  2. waitForURL resolves immediately, before navigation completes
  3. Promise.all resolves before the DOM updates
  4. On slower CI environments, the "Deactivate" link hasn't appeared yet, causing test failures

Related Issue(s):

  • Fixes flaky E2E test in CI

How

Replaced Promise.all pattern with sequential execution:

  • Removed Promise.all([waitForURL(), click()]) for both activate and deactivate actions
  • Added await page.waitForLoadState('domcontentloaded') after each click to ensure DOM has updated
  • Kept existing 10000ms timeout on visibility assertions for CI tolerance

Why this works:

  • Playwright's click() already auto-waits for the element to be clickable
  • waitForLoadState('domcontentloaded') waits for the page to parse the new HTML
  • The subsequent expect().toBeVisible() assertion has auto-retry built-in

Testing Instructions

  1. Start the wp-env environment: npm run wp-env start
  2. Install dependencies: npm ci
  3. Run the E2E test multiple times to verify consistency:
    npm run test:e2e -- --grep "should activate and deactivate"
  4. Expected: Test passes consistently (5/5 runs should succeed)

Additional Info

PR description authored by AI, as well as what recommended the suggestion.

Open WordPress Playground Preview

@justlevine justlevine merged commit 9032da5 into main Mar 20, 2026
14 checks passed
@justlevine justlevine deleted the tests/e2e-waitfor branch March 20, 2026 00:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant