test(ui): add Playwright tests for Users page#2988
Conversation
crivetimihai
left a comment
There was a problem hiding this comment.
Clean, well-structured PR. The page object pattern (UsersPage) follows existing conventions (ServersPage, TeamPage, etc.) and the CRUD test coverage is solid — create, edit, delete, deactivate, activate, and force password change are all covered.
A few observations:
-
reload_and_navigate_to_usershas a 4-second sleep (wait_for_timeout(4000)atusers_page.py:521). The comment says HTMX in-place refresh isn't reliable, which justifies the full reload, but 4 seconds is generous. Consider reducing or replacing withwait_for_load_state("networkidle")to avoid slowing down the test suite. -
find_userretry loop usescache_bustquery param (admin_utils.py:285). This is a creative workaround for cache staleness, but the actual admin API endpoint likely ignores this parameter — it works by being a different URL that bypasses the browser cache. Worth a comment explaining why this trick works. -
_click_action_with_confirmusespage.once("dialog")which is the correct approach for hx-confirm dialogs. Good pattern. -
Test cleanup is thorough — each test creates its own user and cleans up. The
cleanup_userutility is a good addition to admin_utils.
LGTM overall.
|
Thanks for reviewing the PR, @crivetimihai I'll address your suggestion and update the tests accordingly after the PR #3011 is merged to |
Signed-off-by: Marek Dano <mk.dano@gmail.com>
- Fix user_has_badge() to use exact text matching (get_by_text with exact=True) instead of substring matching that could match "Active" within "Inactive" - Fix pydocstyle D205/D400 in module docstrings - Handle nullable text_content() return in test_edit_user - Assert deactivate response status in test_activate_user setup step - Apply black formatting Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
dd3eaf5 to
8e5985d
Compare
Review ChangesRebased onto Triage
Fixes
Notes
@marekdano — please review the changes and let me know if anything looks off. |
crivetimihai
left a comment
There was a problem hiding this comment.
Reviewed, rebased, and applied fixes. LGTM.
* feat: add playwright tests for Users page Signed-off-by: Marek Dano <mk.dano@gmail.com> * fix: address review findings in Playwright Users page tests - Fix user_has_badge() to use exact text matching (get_by_text with exact=True) instead of substring matching that could match "Active" within "Inactive" - Fix pydocstyle D205/D400 in module docstrings - Handle nullable text_content() return in test_edit_user - Assert deactivate response status in test_activate_user setup step - Apply black formatting Signed-off-by: Mihai Criveti <crivetimihai@gmail.com> --------- Signed-off-by: Marek Dano <mk.dano@gmail.com> Signed-off-by: Mihai Criveti <crivetimihai@gmail.com> Co-authored-by: Mihai Criveti <crivetimihai@gmail.com>
✨ Feature / Enhancement PR
🔗 Epic / Issue
Related #2519
🚀 Summary
Add e2e tests for the
Userspage🧪 Checks
make lintpassesmake testpasses📓 Notes (optional)
The HTMX in-place refresh triggered by
HX-Trigger: userCreated(and adminUserAction with refreshUsersList) does not reliably update the user list in the UI. To work around this, the tests wait for any pending JS activity to settle, then perform an explicitpage.reload()and re-navigate to the users tab to get a fresh user list. Action buttons (activate, deactivate, delete, force password change) usehx-swap="outerHTML"on the closest.user-cardand update reliably in-place without requiring a reload.