Skip to content

Expand frontend test coverage for role-based admin routing and shared UI primitives - #51

Merged
countercheck merged 2 commits into
mainfrom
copilot/analyze-test-coverage
Jun 5, 2026
Merged

Expand frontend test coverage for role-based admin routing and shared UI primitives#51
countercheck merged 2 commits into
mainfrom
copilot/analyze-test-coverage

Conversation

Copilot AI commented May 30, 2026

Copy link
Copy Markdown
Contributor

This PR addresses coverage gaps in the frontend by adding tests for previously untested route-selection logic and reusable presentation components. It improves confidence in role-gated navigation and shared UI behavior without changing production code.

  • Admin entry routing coverage

    • Added frontend/src/admin/AdminApp.test.tsx to exercise /admin landing behavior by role:
      • author roles (researcher/admin) render survey list
      • reviewer redirects to PII review
      • analyst redirects to My DB access
      • unknown role sets hit the fallback path
    • Added explicit coverage for the open login route (/admin/login).
  • Respondent shell coverage

    • Added frontend/src/RespondentLayout.test.tsx to verify branded shell rendering (header + content slot).
  • Shared UI primitive coverage

    • Added frontend/src/ui/Primitives.test.tsx covering:
      • Alert ARIA role behavior across tones (alert vs status)
      • Card/CardBody content and class passthrough
      • Field label-input association and hint rendering
      • PageHeader title/subtitle/actions rendering contract
it('redirects reviewers to the pii review queue', async () => {
  setRoles(['reviewer']);
  renderAt('/admin');
  expect(await screen.findByText('PII review view')).toBeInTheDocument();
});

Copilot AI 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.

Pull request overview

This PR expands Vitest/Testing Library coverage for the frontend’s role-gated /admin entry routing and a handful of shared UI primitives, improving confidence in navigation and accessibility behavior without changing production components.

Changes:

  • Add AdminApp route-selection tests covering /admin landing behavior for author/reviewer/analyst/unknown roles, plus /admin/login.
  • Add a RespondentLayout shell rendering test (header + content slot).
  • Add UI primitive tests for Alert, Card/CardBody, Field, and PageHeader (including ARIA roles and label association).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
frontend/src/admin/AdminApp.test.tsx Adds routing/redirect coverage for /admin and the open /admin/login route based on user roles.
frontend/src/RespondentLayout.test.tsx Verifies the respondent-facing layout renders the branded header and children content.
frontend/src/ui/Primitives.test.tsx Adds focused tests for shared UI components, including ARIA role expectations and label↔input association.

@countercheck
countercheck merged commit 91037b6 into main Jun 5, 2026
16 checks passed
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.

3 participants