Skip to content

test(labeler): component a11y, keyboard, and RTL coverage for the operator console - #2032

Merged
ascorbic merged 2 commits into
feat/plugin-registry-labelling-servicefrom
feat/labeler-a11y-tests
Jul 14, 2026
Merged

ascorbic merged 2 commits into
feat/plugin-registry-labelling-servicefrom
feat/labeler-a11y-tests

Conversation

@ascorbic

@ascorbic ascorbic commented Jul 14, 2026 •

Copy link
Copy Markdown
Member

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):

  • axe (jsdom) — toHaveNoViolations on 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 the role=dialog/alertdialog panel rather than document.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.
  • keyboard/focus (user-event) — all six dialogs: opening moves focus into the panel; Escape closes, fires onOpenChange(false), and restores focus to the trigger. Dead-letter actions are shown operable end-to-end from the keyboard.
  • RTL safety — a source scan asserting every non-test .ts/.tsx under console/src uses 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 emits left-1/2, border-r, text-left that 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.
  • Cosmetic admin gating — reviewer sessions do not render admin-only controls (emergency actions, pause toggle, dead-letter retry/quarantine); admin sessions do. Each negative assertion first waits for a role-appropriate element to render, so it can't false-pass on an unrendered page. The server remains authoritative regardless of what the UI shows.

The setup file registers the vitest-axe matcher (with a declare module "vitest" augmentation — the shipped extend-expect augments the legacy Vi.Assertion namespace that vitest 4 ignores) and the jsdom polyfills Kumo needs to render: matchMedia, ResizeObserver, and Element.prototype.getAnimations.

Bug fixed by this coverage

  • NotFound route. console/src/routes/NotFound.tsx 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. 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)

  • Tab-cycle containment is not asserted. jsdom has no real sequential-focus/inert model, 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

  • Bug fix
  • Tests

Checklist

  • I have read CONTRIBUTING.md
  • pnpm typecheck passes
  • pnpm lint passes
  • pnpm test passes (or targeted tests for my change)
  • pnpm format has been run
  • I have added/updated tests for my changes (if applicable)
  • User-visible strings in the admin UI are wrapped for translation (if applicable)
  • I have added a changeset (if this PR changes a published package)
  • New features link to an approved Discussion

AI-generated code disclosure

  • This PR includes AI-generated code — model/tool: Claude Opus 4.8

Screenshots / test output

Test Files  11 passed (11)
     Tests  98 passed (98)

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.

…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
@github-actions

Copy link
Copy Markdown
Contributor

Scope check

This 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.

@github-actions github-actions Bot added size/XL review/needs-review No maintainer or bot review yet labels Jul 14, 2026
@changeset-bot

changeset-bot Bot commented Jul 14, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: bc946b7

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 14, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
emdash-demo-cache bc946b7 Jul 14 2026, 06:51 AM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 14, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
emdash-playground bc946b7 Jul 14 2026, 06:50 AM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 14, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

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

@emdashbot emdashbot 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.

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 the routeTree assembly matches router.tsx. The basepath: "/admin" + createMemoryHistory initial-entries produce the expected route matches; SubjectHistory correctly encodeURIComponents the URI so TanStack's $uri captures the full URI and matches the FIXTURE_SUBJECT_HISTORY key.
  • 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_LETTERS all resolve to what the assertions expect (e.g. fixture system status is not-paused → "Active"; a new dead letter exists → admin Retry/Quarantine render).
  • Mock plumbing: vi.mock("../api/client.js") spreads actual and swaps apiClient for createFixtureClient(); the per-file vi.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 PHYSICAL regexes target the right classes and don't false-positive on mt-/min-h-/border-kumo-*/start-/ms-/group-data-…; the console source is genuinely free of physical-direction classes, so the toEqual([]) per-file assertions are honest. SRC_ROOT = dirname(import.meta.dirname) correctly points at console/src, the test dir is skipped, and > 10 files 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 confirm vitest-axe/matchers resolves, 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/labeler is 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;

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.

[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.

@github-actions github-actions Bot added review/approved Approved; no new commits since and removed review/needs-review No maintainer or bot review yet labels Jul 14, 2026
@ascorbic ascorbic added the bot:review Trigger an emdashbot code review on this PR label Jul 14, 2026

@emdashbot emdashbot 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.

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.tsx now declares path: "$" under shellRoute; the routing test renders /no-such-page and asserts the Not found heading 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_VALUE only matches className="..." and className={`...`}, so className={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 in console/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 /admin basepath, DirectionProvider, QueryClientProvider, vitest-axe matcher registration + the three guarded jsdom polyfills).
  • Conventions: RTL-safe Tailwind enforced; changeset n/a (@emdash-cms/labeler is 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.

@github-actions

Copy link
Copy Markdown
Contributor

Overlapping PRs

This PR modifies files that are also changed by other open PRs:

This may cause merge conflicts or duplicated work. A maintainer will coordinate.

@ascorbic
ascorbic merged commit 4b350ae into feat/plugin-registry-labelling-service Jul 14, 2026
14 checks passed
@ascorbic
ascorbic deleted the feat/labeler-a11y-tests branch July 14, 2026 20:32
@ascorbic ascorbic mentioned this pull request Jul 14, 2026
60 of 81 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:review Trigger an emdashbot code review on this PR cla: signed review/approved Approved; no new commits since size/XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant