Skip to content

fix(test): use JWT-first auth and HTMX-aware waits to eliminate Playwright flakiness#3210

Merged
crivetimihai merged 1 commit intomainfrom
fix/playwright-flaky-login-htmx-sync
Feb 28, 2026
Merged

fix(test): use JWT-first auth and HTMX-aware waits to eliminate Playwright flakiness#3210
crivetimihai merged 1 commit intomainfrom
fix/playwright-flaky-login-htmx-sync

Conversation

@crivetimihai
Copy link
Copy Markdown
Member

Note: This PR was re-created from #3112 due to repository maintenance. Your code and branch are intact. @omorros please verify everything looks good.

🔗 Related Issue
Closes #3105


📝 Summary

Playwright E2E tests fail intermittently when run together due to shared mutable login state (ADMIN_ACTIVE_PASSWORD) and a hard-coded 4-second sleep for HTMX synchronization. This PR promotes the existing JWT cookie injection path to the default login strategy (eliminating shared password state and multi-worker routing issues) and replaces the fixed sleep with a DOM query that waits for in-flight HTMX requests to settle.


🏷️ Type of Change

  • Bug fix

🧪 Verification

Check Command Status
Lint suite make lint
Unit tests make test
Coverage ≥ 80% make coverage N/A (test infra only, no app code changed)

✅ Checklist

  • Code formatted (make black isort pre-commit)
  • Tests added/updated for changes
  • Documentation updated (if applicable)
  • No secrets or credentials committed

📓 Notes (optional)

Files changed: tests/playwright/conftest.py, tests/playwright/pages/users_page.py

Root cause 1 & 3 fix (conftest.py): _ensure_admin_logged_in now injects a fresh JWT cookie per fixture by default, bypassing
the form login flow that depended on ADMIN_ACTIVE_PASSWORD shared state. The form login path is preserved behind
PLAYWRIGHT_DISABLE_JWT_FALLBACK=true for environments that require it.

Root cause 2 fix (users_page.py): reload_and_navigate_to_users replaces wait_for_timeout(4000) with wait_for_function("() =>
!document.querySelector('.htmx-request')"), making the wait adaptive to actual server speed.

@crivetimihai crivetimihai added this to the Release 1.0.0-GA milestone Feb 24, 2026
@crivetimihai crivetimihai added bug Something isn't working testing Testing (unit, e2e, manual, automated, etc) SHOULD P2: Important but not vital; high-value items that are not crucial for the immediate release labels Feb 24, 2026
@omorros
Copy link
Copy Markdown
Contributor

omorros commented Feb 24, 2026

Hi @crivetimihai thanks for reopening this! I've verified the code, everything looks good, intact and matching my original changes. Ready for review whenever you get the chance. Thanks!

…right flakiness

Closes #3105

Signed-off-by: Oriol Morros Vilaseca <OM368@student.aru.ac.uk>
@crivetimihai crivetimihai force-pushed the fix/playwright-flaky-login-htmx-sync branch from 48adaa6 to e72cea1 Compare February 28, 2026 18:31
@crivetimihai crivetimihai merged commit 181990f into main Feb 28, 2026
4 checks passed
@crivetimihai crivetimihai deleted the fix/playwright-flaky-login-htmx-sync branch February 28, 2026 18:32
@crivetimihai crivetimihai self-assigned this Mar 9, 2026
MohanLaksh pushed a commit that referenced this pull request Mar 12, 2026
…right flakiness (#3210)

Closes #3105

Signed-off-by: Oriol Morros Vilaseca <OM368@student.aru.ac.uk>
Co-authored-by: Oriol Morros Vilaseca <OM368@student.aru.ac.uk>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working SHOULD P2: Important but not vital; high-value items that are not crucial for the immediate release testing Testing (unit, e2e, manual, automated, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG][TESTING]: Playwright UI tests flaky due to shared login state and HTMX sync races

2 participants