Repository navigation
test(labeler): component a11y, keyboard, and RTL coverage for the operator console - #2032
Conversation
…rator console Add component-level accessibility and layout regression tests for the labeler operator console: - axe checks (jsdom) on every route container and every dialog panel - keyboard/focus behaviour for all six dialogs: focus moves into the panel on open, Escape closes and restores focus to the trigger - an RTL-safety source scan asserting console source uses logical Tailwind classes, never physical-direction ones - cosmetic admin-gating checks confirming reviewer sessions do not see admin-only controls (the server stays authoritative) Adds a vitest setup file registering the vitest-axe matcher and the jsdom polyfills Kumo needs to render (matchMedia, ResizeObserver, Element.prototype.getAnimations), plus vitest-axe and @testing-library/user-event as devDependencies. Claude-Session: https://claude.ai/code/session_014rikrGMh25h1rJczUQyTMM
Scope checkThis PR changes 651 lines across 10 files. Large PRs are harder to review and more likely to be closed without review. If this scope is intentional, no action needed. A maintainer will review it. If not, please consider splitting this into smaller PRs. See CONTRIBUTING.md for contribution guidelines. |
|
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
emdash-demo-cache | bc946b7 | Jul 14 2026, 06:51 AM |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
emdash-playground | bc946b7 | Jul 14 2026, 06:50 AM |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
emdash-demo-do | bc946b7 | Jul 14 2026, 06:52 AM |
The console catch-all route declared `path: "*"`, but TanStack Router's splat segment is `$` — so `*` matched literally and unknown URLs fell through to the router's default "Not Found" instead of the console's styled NotFoundPage inside the shell. Switch to the splat token and cover it with a routing test plus an axe check. Claude-Session: https://claude.ai/code/session_014rikrGMh25h1rJczUQyTMM
There was a problem hiding this comment.
Approach judgment: This is the right change — test-only accessibility and layout-regression coverage for the labeler operator console (an internal, non-published app). It adds no production code, only tests + a vitest setup file + two devDependencies. The approach fits EmDash's conventions: it leans on Kumo's a11y, scopes axe to console-owned dialog panels (deliberately avoiding Base UI's framework-owned focus-guard sentinel), and enforces the AGENTS.md RTL-safe-Tailwind rule via a source scan. The PR description honestly documents its gaps (no Tab-trap containment in jsdom, pre-existing NotFound splat issue deferred). Stacking this on the in-progress feat/plugin-registry-labelling-service base is appropriate.
What I checked:
- Harness wiring: all imported route exports (
dashboardRoute,assessmentDetailRoute,subjectHistoryRoute,notFoundRoute,shellRoute,rootRoute, …) exist and therouteTreeassembly matchesrouter.tsx. Thebasepath: "/admin"+createMemoryHistoryinitial-entries produce the expected route matches;SubjectHistorycorrectlyencodeURIComponents the URI so TanStack's$uricaptures the full URI and matches theFIXTURE_SUBJECT_HISTORYkey. - Fixtures/props: every dialog/component prop the tests pass (
EmergencyActionDialog,OverrideDialog,AssessmentActionDialog,LabelActionDialog,AutomationControl,DeadLetterActions) matches the real component signatures;ADMIN_IDENTITY/REVIEWER_IDENTITY,ASSESSMENT_GAMMA,SUBJECT_ALPHA,RELEASE_ISSUABLE_LABELS,FIXTURE_SYSTEM_STATUS,FIXTURE_DEAD_LETTERSall resolve to what the assertions expect (e.g. fixture system status is not-paused → "Active"; anewdead letter exists → adminRetry/Quarantinerender). - Mock plumbing:
vi.mock("../api/client.js")spreadsactualand swapsapiClientforcreateFixtureClient(); the per-filevi.spyOn(apiClient, "whoami")controls cosmetic gating and is restored each test. Components import the same mocked instance. - Negative assertions: the reviewer gating tests wait on a role-appropriate element before the
queryBy*().toBeNull()check (e.g.findByText("Active"),findByRole("table"),findByRole("button", { name: "Issue record label" })), so they can't false-pass on an unrendered page — exactly as the PR claims. - RTL scan: the
PHYSICALregexes target the right classes and don't false-positive onmt-/min-h-/border-kumo-*/start-/ms-/group-data-…; the console source is genuinely free of physical-direction classes, so thetoEqual([])per-file assertions are honest.SRC_ROOT = dirname(import.meta.dirname)correctly points atconsole/src, thetestdir is skipped, and> 10files are scanned. - Setup: the vitest-axe manual
expect.extend(matchers)+declare module "vitest"augmentation is the documented fix for the vitest-4 matcher-registration issue; the jsdom polyfills (matchMedia,ResizeObserver,getAnimations) are guarded so they only patch when missing. (I could not install/run to confirmvitest-axe/matchersresolves, but it matches the package's documented API and the lockfile pins 0.1.0.) - Conventions: RTL-safe Tailwind is enforced; changeset is n/a (
@emdash-cms/labeleris private and this is test-only); i18n is n/a (no strings changed); no production code touched, so no SQL/locale/auth/changeset concerns apply.
Conclusion: No bugs or regressions found. One minor suggestion below about the RTL scan's expression-form coverage gap; otherwise this is clean and ready to merge.
| /^(float-left|float-right)$/, | ||
| ]; | ||
|
|
||
| const CLASS_VALUE = /className=(?:"([^"]*)"|\{`([^`]*)`\})/g; |
There was a problem hiding this comment.
[suggestion] The CLASS_VALUE regex only scans className="..." static strings and className={...} template literals. Expression-form classNames are not scanned — e.g. className={cond ? "ml-2" : "ms-2"}, className={clsx(...)}, or className={someVar} would slip through unflagged. The console source currently uses only static/template forms, so the guard is effective today, but the test's own docstring advertises it as a general RTL guard, and a future contributor could introduce a physical class via a ternary without this catching it. Worth a one-line note in the test (or extending the regex) so the persisted artifact documents the scope — the PR description's rationale doesn't live in the repo.
There was a problem hiding this comment.
Re-review (no changes since prior APPROVED review).
The diff is byte-identical to the version I reviewed previously — no commits landed between reviews, so there is nothing new to verify. Re-affirming the prior conclusion.
Approach judgment: This is the right change — test-only accessibility and layout-regression coverage for the labeler operator console (a private, non-published internal app), plus the one production fix the coverage surfaced (the NotFound splat token). It adds no production logic beyond path: "*" → path: "$", which is the correct TanStack Router splat segment (the old "*" matched literally, so unknown URLs fell through to the router's default Not Found rather than the console's styled page inside the shell). The approach fits EmDash's conventions: axe is scoped to console-owned dialog panels (avoiding Base UI's framework-owned focus-guard sentinel), keyboard/focus coverage uses user-event, RTL-safe Tailwind is enforced via a source scan, and cosmetic admin gating waits on a role-appropriate element before each negative assertion so it can't false-pass. Stacking on feat/plugin-registry-labelling-service is appropriate.
What I re-verified this pass:
- NotFound fix:
NotFound.tsxnow declarespath: "$"undershellRoute; the routing test renders/no-such-pageand asserts theNot foundheading appears — the reproducing test that the PR description says failed before and passes after. - RTL scan expression-form gap (prior suggestion): I flagged last time that
CLASS_VALUEonly matchesclassName="..."andclassName={`...`}, soclassName={expr}would be missed. I checked the actual console source this pass: there are zero expression-form classNames (every className is a plain string or template literal) and zero physical-direction classes anywhere inconsole/src(42 source files, no/test/). The gap is therefore purely theoretical for the current codebase and can't hide a misuse. I'm dropping that suggestion as moot rather than re-posting it. - Harness/setup: unchanged and correct (memory history with
/adminbasepath,DirectionProvider,QueryClientProvider, vitest-axe matcher registration + the three guarded jsdom polyfills). - Conventions: RTL-safe Tailwind enforced; changeset n/a (
@emdash-cms/labeleris private, test-only); i18n n/a (no strings changed); no production code touched so no SQL/locale/auth concerns.
Conclusion: No bugs or regressions. Clean and ready to merge.
Overlapping PRsThis PR modifies files that are also changed by other open PRs:
This may cause merge conflicts or duplicated work. A maintainer will coordinate. |
4b350ae
into
feat/plugin-registry-labelling-service
What does this PR do?
Adds component-level accessibility and layout-regression tests for the labeler operator console (W9.7), plus the one production fix the coverage surfaced (the NotFound route). Otherwise: tests, a vitest setup file, and two devDependencies.
Coverage added (console suite 35 → 98 tests):
toHaveNoViolationson every route container (Dashboard, AssessmentList, AssessmentDetail, SubjectHistory, AuditLog, DeadLetterQueue) and every dialog panel (emergency action, override, assessment action, label action, automation control, dead-letter actions). Dialog checks are scoped to therole=dialog/alertdialogpanel rather thandocument.body, because Base UI portals a focus-guard sentinel as a sibling of the panel that is Kumo/Base UI internal markup, not console markup.onOpenChange(false), and restores focus to the trigger. Dead-letter actions are shown operable end-to-end from the keyboard..ts/.tsxunderconsole/srcuses logical Tailwind classes, never physical-direction ones (ml/mr,left/right,text-left/text-right,border-l/r,rounded-l/r,float-left/right). This is implemented as a source scan rather than a rendered-DOM walk deliberately: a DOM walk conflates console classes with Kumo's framework-owned physical classes (Base UI emitsleft-1/2,border-r,text-leftthat we do not control), so it would either false-positive or need an allowlist that also masks our own misuse. The source scan tests exactly the code we own, with zero false positives. Console source is clean.The setup file registers the vitest-axe matcher (with a
declare module "vitest"augmentation — the shippedextend-expectaugments the legacyVi.Assertionnamespace that vitest 4 ignores) and the jsdom polyfills Kumo needs to render:matchMedia,ResizeObserver, andElement.prototype.getAnimations.Bug fixed by this coverage
console/src/routes/NotFound.tsxdeclaredpath: "*", but TanStack Router's splat segment is$— so*matched literally and unknown URLs fell through to the router's defaultNot Foundinstead of the console's styled NotFoundPage inside the shell. Fixed by switching to the splat token, with a reproducing routing test and an axe check on the now-reachable page.Known gap (out of scope, intentional)
inertmodel, so a "Tab N times, stays inside" assertion flaps. The parts jsdom can verify faithfully (focus-in on open, Escape-close, focus-restore) are covered; real trap containment needs Playwright, which is deferred with the rest of browser-e2e.Type of change
Checklist
pnpm typecheckpassespnpm lintpassespnpm testpasses (or targeted tests for my change)pnpm formathas been runAI-generated code disclosure
Screenshots / test output
Try this PR
Open a fresh playground →
A full working EmDash site, deployed from this branch. Each visit gets its own session-scoped sandbox: no login needed and no shared state. Try the admin, edit content, hit the public site.
Tracks
feat/labeler-a11y-tests. Updated automatically when the playground redeploys.