Skip to content

test(ui): add Playwright tests for Users page#2988

Merged
crivetimihai merged 2 commits intomainfrom
add-playwright-tests-for-users-page
Feb 20, 2026
Merged

test(ui): add Playwright tests for Users page#2988
crivetimihai merged 2 commits intomainfrom
add-playwright-tests-for-users-page

Conversation

@marekdano
Copy link
Copy Markdown
Collaborator

✨ Feature / Enhancement PR

🔗 Epic / Issue

Related #2519


🚀 Summary

Add e2e tests for the Users page

  • Add UsersPage page object (tests/playwright/pages/users_page.py) encapsulating all user management UI elements and interactions (create, edit, delete, activate/deactivate, force password change, unlock)
  • Add browser-driven CRUD tests (tests/playwright/entities/test_users.py) with 6 tests: create, edit, delete, deactivate, activate, and force password change
  • Add users_page and test_user_data fixtures to tests/playwright/conftest.py
  • Add find_user, delete_user, and cleanup_user helpers to tests/playwright/pages/admin_utils.py
  • Export UsersPage from tests/playwright/pages/init.py

🧪 Checks

  • make lint passes
  • make test passes
  • `make test-ui-headless
  • CHANGELOG updated (if user-facing)

📓 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 explicit page.reload() and re-navigate to the users tab to get a fresh user list. Action buttons (activate, deactivate, delete, force password change) use hx-swap="outerHTML" on the closest .user-card and update reliably in-place without requiring a reload.

crivetimihai
crivetimihai previously approved these changes Feb 19, 2026
Copy link
Copy Markdown
Member

@crivetimihai crivetimihai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. reload_and_navigate_to_users has a 4-second sleep (wait_for_timeout(4000) at users_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 with wait_for_load_state("networkidle") to avoid slowing down the test suite.

  2. find_user retry loop uses cache_bust query 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.

  3. _click_action_with_confirm uses page.once("dialog") which is the correct approach for hx-confirm dialogs. Good pattern.

  4. Test cleanup is thorough — each test creates its own user and cleans up. The cleanup_user utility is a good addition to admin_utils.

LGTM overall.

@marekdano
Copy link
Copy Markdown
Collaborator Author

Thanks for reviewing the PR, @crivetimihai

I'll address your suggestion and update the tests accordingly after the PR #3011 is merged to main. The PR relates to these playwright tests.

@crivetimihai crivetimihai added this to the Release 1.1.0 milestone Feb 20, 2026
@crivetimihai crivetimihai changed the title feat: add playwright tests for Users page test(ui): add Playwright tests for Users page Feb 20, 2026
@crivetimihai crivetimihai added SHOULD P2: Important but not vital; high-value items that are not crucial for the immediate release testing Testing (unit, e2e, manual, automated, etc) ui User Interface labels Feb 20, 2026
marekdano and others added 2 commits February 20, 2026 18:15
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>
@crivetimihai crivetimihai force-pushed the add-playwright-tests-for-users-page branch from dd3eaf5 to 8e5985d Compare February 20, 2026 18:23
@crivetimihai
Copy link
Copy Markdown
Member

Review Changes

Rebased onto main and made the following changes:

Triage

  • Title: renamed from feat: add playwright tests for Users pagetest(ui): add Playwright tests for Users page
  • Labels: added SHOULD, testing, ui
  • Milestone: set to Release 1.1.0

Fixes

  • users_page.py:user_has_badge(): Changed from span:has-text('...') (substring match) to get_by_text(..., exact=True). The previous implementation would match "Active" within "Inactive", causing test_activate_user to pass falsely when the user was still inactive.
  • users_page.py docstring: Fixed pydocstyle D205/D400 — summary line must be first and end with a period.
  • test_users.py:test_edit_user: Added or "" fallback for card.text_content() which can return None (pyrefly type safety).
  • test_users.py:test_activate_user: The deactivate setup step now asserts the response status, so failures in the prerequisite deactivation are diagnosed immediately rather than silently passing through to the activate assertion.
  • test_users.py docstring: Same pydocstyle fix as above.
  • Applied black formatting to match project standards (line length 200).

Notes

  • Rebase was clean, no conflicts.
  • Bandit B101 (assert_used) warnings are expected in test files — consistent with all other Playwright tests in the suite.
  • Vulture warnings are all false positives at 60% confidence (page object methods used dynamically from test files).

@marekdano — please review the changes and let me know if anything looks off.

Copy link
Copy Markdown
Member

@crivetimihai crivetimihai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed, rebased, and applied fixes. LGTM.

@crivetimihai crivetimihai merged commit 586fe26 into main Feb 20, 2026
38 of 39 checks passed
@crivetimihai crivetimihai deleted the add-playwright-tests-for-users-page branch February 20, 2026 18:43
vishu-bh pushed a commit that referenced this pull request Feb 24, 2026
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

SHOULD P2: Important but not vital; high-value items that are not crucial for the immediate release testing Testing (unit, e2e, manual, automated, etc) ui User Interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants