Skip to content

Gsn ocom coverage staff user#304

Open
nikithaguduru wants to merge 2 commits into
mainfrom
gsn_ocom_coverage_staff_user
Open

Gsn ocom coverage staff user#304
nikithaguduru wants to merge 2 commits into
mainfrom
gsn_ocom_coverage_staff_user

Conversation

@nikithaguduru

@nikithaguduru nikithaguduru commented Jul 23, 2026

Copy link
Copy Markdown

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:

  • Introduce shared page objects for staff users list and staff user detail screens used by DOM and Playwright adapters.
  • Add staff portal abilities to open and interact with the staff users list and detail pages in browser-based tests.

Enhancements:

  • Expand staff verification scenarios to cover staff user lifecycle, role assignment, and permission enforcement for administrators and restricted users.
  • Add Serenity tasks and notes to model staff user provisioning, role changes, access results, and viewing of user lists and details in acceptance API, UI, and e2e contexts.
  • Provide a mock staff user backend and UI renderer to drive staff user management flows in component acceptance tests.

Tests:

  • Add BDD feature and step definitions for staff user management, including provisioning, role changes, access control, activity logging, and viewing list and details.
  • Add unit tests for staff user list and detail page objects to validate table parsing and activity log inspection behavior.

@nikithaguduru
nikithaguduru requested a review from a team July 23, 2026 19:21
@sourcery-ai

sourcery-ai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Adds 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 tasks

sequenceDiagram
    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
Loading

File-Level Changes

Change Details Files
Introduce shared page objects and tests for staff users list and detail screens to support DOM and Playwright adapters.
  • Export new StaffUserDetailPage and StaffUsersListPage from shared pages index for reuse across test layers.
  • Implement StaffUsersListPage with helpers to read table rows, check for users by name, and click into a user row (preferring an Edit button when present).
  • Implement StaffUserDetailPage with helpers to read current role, save button, activity log table, and check for activity log entries.
  • Add unit tests using a FakeElementHandle adapter to validate StaffUsersListPage and StaffUserDetailPage behaviours.
packages/ocom-verification/verification-shared/src/pages/index.ts
packages/ocom-verification/verification-shared/src/pages/staff-users-list.page.ts
packages/ocom-verification/verification-shared/src/pages/staff-user-detail.page.ts
packages/ocom-verification/verification-shared/src/pages/staff-user-page-object.test.ts
Add a mock staff-user backend and UI task for rendering the staff users screen, wired into existing staff-role auth state and Apollo mocks.
  • Create mock-staff-user-backend with in-memory staff users, role catalog, helpers to set/reset state, and Apollo MockedResponse builders for list, detail, current user, roles, and assign-role mutations.
  • Integrate staff user mocks with staff-role mock auth via currentStaffAuth and recordCurrentMockPath when rendering StaffUsersPage.
  • Implement RenderStaffUsersScreen task plus utility flushUi/waitUntilUi and listPageFor/detailPageFor helpers to drive the staff users screen in acceptance UI tests.
packages/ocom-verification/acceptance-ui/src/contexts/staff/abilities/mock-staff-user-backend.ts
packages/ocom-verification/acceptance-ui/src/contexts/staff/tasks/staff-user-screen.ts
Define staff portal Playwright ability helpers for navigating to staff users list and detail pages in E2E tests.
  • Add staff-portal-page helpers to resolve Playwright Page based on StaffE2ENotes businessRole via staffPortalPageFor.
  • Implement waitUntil polling helper for E2E waits and openUsersList to navigate to USERS_LIST_PATH and wait until table rows render.
  • Provide listPageOn and detailPageOn helpers to construct shared page objects over PlaywrightPageAdapter.
packages/ocom-verification/e2e-tests/src/contexts/staff/abilities/staff-portal-page.ts
Introduce Cucumber feature and step definitions for staff user management spanning provisioning, role updates, access control, activity logging, and list/detail viewing for UI, API, and E2E contexts.
  • Add staff-user-management.feature capturing scenarios for provisioning, admin role assignment, self-role-change prevention, restricted-user access denial, activity log recording, and viewing staff list/details.
  • Create staff-user-management step-definition modules for acceptance UI, acceptance API, and E2E, each maintaining an in-memory userState map and currentActorName and delegating actions to ProvisionStaffUser, UpdateStaffUserRole, ViewStaffUsersList, ViewStaffUserDetails, and RecordAccessResult.
  • Wire new staff-user-management step definition files into existing staff context index.ts files for acceptance-ui, acceptance-api, and e2e-tests.
packages/ocom-verification/verification-shared/src/scenarios/staff/staff-user-management.feature
packages/ocom-verification/acceptance-api/src/contexts/staff/step-definitions/staff-user-management.steps.ts
packages/ocom-verification/acceptance-ui/src/contexts/staff/step-definitions/staff-user-management.steps.tsx
packages/ocom-verification/e2e-tests/src/contexts/staff/step-definitions/staff-user-management.steps.ts
packages/ocom-verification/acceptance-api/src/contexts/staff/step-definitions/index.ts
packages/ocom-verification/acceptance-ui/src/contexts/staff/step-definitions/index.ts
packages/ocom-verification/e2e-tests/src/contexts/staff/step-definitions/index.ts
Add Serenity tasks and notes types to model staff user provisioning, role updates, access results, and list/detail viewing across UI, API, and E2E layers.
  • Define StaffUserManagement*Notes interfaces for UI, API, and E2E contexts to capture staffUserName, role, result, and activityLog where needed.
  • Implement ProvisionStaffUser, UpdateStaffUserRole, RecordAccessResult, ViewStaffUsersList, and ViewStaffUserDetails tasks in acceptance-api, acceptance-ui, and e2e-tests, storing outcomes in notes objects rather than calling real backends.
  • Ensure cross-layer consistency of task names, semantics, and note keys to align with the staff-user-management.feature expectations.
packages/ocom-verification/acceptance-api/src/contexts/staff/notes/staff-user-management-notes.ts
packages/ocom-verification/acceptance-ui/src/contexts/staff/notes/staff-user-management-notes.ts
packages/ocom-verification/e2e-tests/src/contexts/staff/notes/staff-user-management-notes.ts
packages/ocom-verification/acceptance-api/src/contexts/staff/tasks/provision-staff-user.ts
packages/ocom-verification/acceptance-api/src/contexts/staff/tasks/update-staff-user-role.ts
packages/ocom-verification/acceptance-api/src/contexts/staff/tasks/record-access-result.ts
packages/ocom-verification/acceptance-api/src/contexts/staff/tasks/view-staff-user-details.ts
packages/ocom-verification/acceptance-api/src/contexts/staff/tasks/view-staff-users-list.ts
packages/ocom-verification/acceptance-ui/src/contexts/staff/tasks/provision-staff-user.ts
packages/ocom-verification/acceptance-ui/src/contexts/staff/tasks/update-staff-user-role.ts
packages/ocom-verification/acceptance-ui/src/contexts/staff/tasks/record-access-result.ts
packages/ocom-verification/acceptance-ui/src/contexts/staff/tasks/view-staff-user-details.ts
packages/ocom-verification/acceptance-ui/src/contexts/staff/tasks/view-staff-users-list.ts
packages/ocom-verification/e2e-tests/src/contexts/staff/tasks/provision-staff-user.ts
packages/ocom-verification/e2e-tests/src/contexts/staff/tasks/update-staff-user-role.ts
packages/ocom-verification/e2e-tests/src/contexts/staff/tasks/record-access-result.ts
packages/ocom-verification/e2e-tests/src/contexts/staff/tasks/view-staff-user-details.ts
packages/ocom-verification/e2e-tests/src/contexts/staff/tasks/view-staff-users-list.ts

Possibly linked issues

  • #: PR delivers shared scenarios plus API, UI, and E2E steps for staff provisioning, roles, and activity logs, matching issue scope.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
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: () => ({

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment on lines +10 to +11
const userState = new Map<string, { role: string; activityLog: string[] }>();
let currentActorName = '';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant