fix(test): use JWT-first auth and HTMX-aware waits to eliminate Playwright flakiness#3210
Merged
crivetimihai merged 1 commit intomainfrom Feb 28, 2026
Merged
Conversation
5 tasks
Contributor
|
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>
48adaa6 to
e72cea1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔗 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
🧪 Verification
make lintmake testmake coverage✅ Checklist
make black isort pre-commit)📓 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.