Gsn ocom coverage staff user#304
Conversation
Reviewer's GuideAdds full BDD-style coverage for staff user management (provisioning, role assignment, access control, activity logs, list and detail views) across acceptance UI, acceptance API, and E2E layers, backed by shared page objects and a mock staff-user backend integrated with the existing staff-role mock/auth plumbing. Sequence diagram for viewing a staff user’s details via the new UI taskssequenceDiagram
actor StaffAdmin
participant ViewStaffUserDetails as ViewStaffUserDetails.performAs
participant RenderStaffUsersScreen as RenderStaffUsersScreen
participant StaffUsersListPage as StaffUsersListPage
participant StaffUserDetailPage as StaffUserDetailPage
participant StaffUserMocks as buildStaffUserMocks
StaffAdmin->>ViewStaffUserDetails: performAs(actor)
activate ViewStaffUserDetails
ViewStaffUserDetails->>StaffAdmin: attemptsTo(RenderStaffUsersScreen())
activate RenderStaffUsersScreen
RenderStaffUsersScreen->>StaffUserMocks: resetStaffUserUiState()
RenderStaffUsersScreen->>StaffUserMocks: setCurrentStaffUser(Alice, finance)
RenderStaffUsersScreen->>StaffUserMocks: setStaffUserUiState(Bob, finance)
RenderStaffUsersScreen->>StaffUserMocks: buildStaffUserMocks()
RenderStaffUsersScreen-->>StaffAdmin: UI rendered with StaffUsersPage
deactivate RenderStaffUsersScreen
ViewStaffUserDetails->>StaffUsersListPage: listedUserNames()
StaffUsersListPage-->>ViewStaffUserDetails: [Alice, Bob]
ViewStaffUserDetails->>StaffUsersListPage: clickRowForUser(Bob)
StaffUsersListPage-->>ViewStaffUserDetails: row clicked
ViewStaffUserDetails->>StaffUserDetailPage: heading.isVisible()
StaffUserDetailPage-->>ViewStaffUserDetails: true
ViewStaffUserDetails->>StaffAdmin: attemptsTo(notes.set(staffUserName, Bob))
ViewStaffUserDetails->>StaffAdmin: attemptsTo(notes.set(result, details-visible))
deactivate ViewStaffUserDetails
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="packages/ocom-verification/acceptance-ui/src/contexts/staff/abilities/mock-staff-user-backend.ts" line_range="158" />
<code_context>
+ {
+ request: { query: StaffUserAssignRoleDocument },
</code_context>
<issue_to_address>
**issue (testing):** The StaffUserAssignRole mock reports success but doesn’t update the in‑memory user state, so subsequent queries will still return the old role.
This mock returns success but never updates `uiStaffUsers` (or `activityLog`), so later queries via `StaffUsersListDocument`/`StaffUserDetailDocument` will still show the old role. Please update the relevant `MockStaffUser` (and optionally `activityLog`) so the mock state matches the assigned role and better reflects real backend behavior.
</issue_to_address>
### Comment 2
<location path="packages/ocom-verification/e2e-tests/src/contexts/staff/step-definitions/staff-user-management.steps.ts" line_range="10-11" />
<code_context>
+import { ViewStaffUserDetails } from '../tasks/view-staff-user-details.ts';
+import { ViewStaffUsersList } from '../tasks/view-staff-users-list.ts';
+
+const userState = new Map<string, { role: string; activityLog: string[] }>();
+let currentActorName = '';
+
+const ensureUser = (name: string, role: string) => {
</code_context>
<issue_to_address>
**issue (bug_risk):** Shared `userState` map is never reset between scenarios, which can cause cross-scenario pollution in E2E tests.
Since `userState` and `currentActorName` are module-level and never cleared, data (e.g. users created in one scenario) can persist into later scenarios, making tests order-dependent and flaky. Add a `Before`/`After` hook in this file to reset `userState.clear()` and `currentActorName = ''` for each scenario, or move this state into a Cucumber World/Serenity-scoped object so it’s naturally isolated per scenario.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| { | ||
| request: { query: StaffUserAssignRoleDocument }, | ||
| variableMatcher: () => true, | ||
| result: () => ({ |
There was a problem hiding this comment.
issue (testing): The StaffUserAssignRole mock reports success but doesn’t update the in‑memory user state, so subsequent queries will still return the old role.
This mock returns success but never updates uiStaffUsers (or activityLog), so later queries via StaffUsersListDocument/StaffUserDetailDocument will still show the old role. Please update the relevant MockStaffUser (and optionally activityLog) so the mock state matches the assigned role and better reflects real backend behavior.
| const userState = new Map<string, { role: string; activityLog: string[] }>(); | ||
| let currentActorName = ''; |
There was a problem hiding this comment.
issue (bug_risk): Shared userState map is never reset between scenarios, which can cause cross-scenario pollution in E2E tests.
Since userState and currentActorName are module-level and never cleared, data (e.g. users created in one scenario) can persist into later scenarios, making tests order-dependent and flaky. Add a Before/After hook in this file to reset userState.clear() and currentActorName = '' for each scenario, or move this state into a Cucumber World/Serenity-scoped object so it’s naturally isolated per scenario.
Summary by Sourcery
Add staff user management coverage across verification layers, including list and detail views, provisioning, role updates, and access control rules.
New Features:
Enhancements:
Tests: