You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implements e2e coverage for the "manage user" functionality (Assign Roles and Districts page), tracked by #1410 and its sub-issues #1421-#1424, following the same pattern already established for Manage Clients (#1409).
What was implemented
playwright/e2e/support/manageUsersRuntime.ts — seed a user with role_id NULL, ensure/revoke role_permissions for permission id 11 ("Assign users a role"), look up the ref_district "TST" fixture by code, UI selectors, and API verification helpers.
empty states (before user selection; a freshly seeded no-role user)
assign role + district(s) round trip, verified via GET /v1/user/:id and /v1/user/:id/districts, then updated to a different role/district combination
Range Agreement Holder + districts is blocked in the UI (disabled Assign button + inline error) — also documents the current server-side response (500) when the guard is bypassed directly via the API
a forced-failure error state (via route interception) asserts the assigningError message renders
Bug fix found and fixed along the way
All three MUI Autocomplete fields on assignRolesAndDistrictsPage/index.tsx shared the same hardcoded id="user-autocomplete-select", which corrupted each field's accessible name (labels bled across fields, making the fields impossible to target reliably by role/label — a real, pre-existing accessibility bug, not just a test issue). Fixed by giving each field a unique id (assign-roles-select-user, assign-roles-select-role, assign-roles-select-districts).
Verification
Ran npx playwright test playwright/e2e/assign-roles-and-districts.spec.ts twice back-to-back against a local dev API/DB/web stack: 5/5 passing both times.
Confirmed no residual seed rows (user_account, user_districts) after each run.
npx eslint / npx prettier --check pass on all changed/added files.
No new env vars or CI config changes needed — .github/workflows/e2e.yml's PLAYWRIGHT_TEST_SPEC defaults to running all specs, and the existing PLAYWRIGHT_TEST_DISTRICT_CODE/PLAYWRIGHT_DB_* vars are reused.
- New playwright/e2e/support/manageUsersRuntime.ts: seed user (role_id NULL),
ensure/revoke role_permissions for permission id 11 ("Assign users a role"),
district lookup by code, UI selectors, and API verification helpers, mirroring
manageClientsRuntime.ts conventions.
- New playwright/e2e/assign-roles-and-districts.spec.ts covering:
- nav-link permission gate (grant/revoke permission 11)
- empty states (before user selection, and a no-role seeded user)
- assign role + districts round trip, verified via GET /v1/user/:id and
/v1/user/:id/districts, then updated to a different role/district combo
- Range Agreement Holder + districts is blocked in the UI (disabled button +
error text) and documents the current server-side 500 response when the
guard is bypassed directly via the API
- a forced-failure error state renders the assigningError message
- Fixed a real accessibility bug found while wiring up selectors: all three MUI
Autocomplete fields on the Assign Roles/Districts page shared the same
hardcoded id="user-autocomplete-select", corrupting each field's accessible
name. Gave each field a unique id.
Verified twice in a row against a local dev API/DB/web stack (5/5 passing, no
DB residue). Tracked via #1410, with sub-issues #1421-#1424 documenting
preconditions, implementation, and verification status.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Wait for the selected user's district request here before choosing TST. pullRoleAndDistrict asynchronously replaces selectedDistricts when /v1/district/:userId resolves, so the current sequence can clear the just-selected district and make the disabled-button/error assertions flaky. The round-trip test already uses this synchronization option.
test.describe('Assign Roles and Districts', () => {
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
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.
Summary
Implements e2e coverage for the "manage user" functionality (Assign Roles and Districts page), tracked by #1410 and its sub-issues #1421-#1424, following the same pattern already established for Manage Clients (#1409).
What was implemented
playwright/e2e/support/manageUsersRuntime.ts— seed a user withrole_id NULL, ensure/revokerole_permissionsfor permission id 11 ("Assign users a role"), look up theref_district"TST" fixture by code, UI selectors, and API verification helpers.playwright/e2e/assign-roles-and-districts.spec.ts:GET /v1/user/:idand/v1/user/:id/districts, then updated to a different role/district combinationassigningErrormessage rendersBug fix found and fixed along the way
All three MUI
Autocompletefields onassignRolesAndDistrictsPage/index.tsxshared the same hardcodedid="user-autocomplete-select", which corrupted each field's accessible name (labels bled across fields, making the fields impossible to target reliably by role/label — a real, pre-existing accessibility bug, not just a test issue). Fixed by giving each field a unique id (assign-roles-select-user,assign-roles-select-role,assign-roles-select-districts).Verification
npx playwright test playwright/e2e/assign-roles-and-districts.spec.tstwice back-to-back against a local dev API/DB/web stack: 5/5 passing both times.user_account,user_districts) after each run.npx eslint/npx prettier --checkpass on all changed/added files..github/workflows/e2e.yml'sPLAYWRIGHT_TEST_SPECdefaults to running all specs, and the existingPLAYWRIGHT_TEST_DISTRICT_CODE/PLAYWRIGHT_DB_*vars are reused.Follow-up
workflow_dispatch) once this branch is available there.Closes #1410.
Closes #1421.
Closes #1422.
Closes #1423.