Skip to content

fix: resolve four cross-package test failures in monorepo - #130

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2214-1787242332
Open

fix: resolve four cross-package test failures in monorepo#130
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2214-1787242332

Conversation

@stooit

@stooit stooit commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing tests and the type error in the monorepo. bun run test13 pass, 0 fail; npx tsc --noEmit → only pre-existing bun:test module errors in test files remain (unrelated, in test files that must not be modified). No test files changed, no dependencies added.

Bugs fixed (one per package area)

  1. packages/utils / apps/web — renamed hook mismatch. The debounce hook was referenced under stale names (useSearchDebounce missing at runtime, useThrottle at type-check). Exported useSearchDebounce (alias of the genuine useDebounce) from @e2e/utils and reconciled the duplicate imports/re-export in apps/web/src/lib/api.ts. api.ts only re-exports the hook, so no call-site behaviour changed.

  2. packages/ui/Button — missing accessible name (WCAG 2.2 SC 4.1.2). aria-label was destructured but never applied. Now forwarded; icon-only buttons always get an accessible name (explicit label, else a dev-warned fallback). The icon wrapper is marked aria-hidden only when other accessible text exists — so <Button icon={…} /> (icon, no children, not iconOnly) keeps the icon's text as its name.

  3. packages/ui/DataTable — stale-closure sort. The sort handler read sortDir from a stale render closure, so a second click didn't toggle to descending. Merged sortKey/sortDir into a single object updated via one functional setState, making the key+direction update atomic. Render body and aria-sort output are unchanged.

  4. packages/utils/formatDate — format string. Returned 01/03/2024 (zero-padded day) instead of the expected day-first 1/03/2024. Uses Intl.DateTimeFormat('en-AU') via formatToParts, stripping padding from the day part only (2-digit month, 4-digit year retained). Satisfies all date test assertions.

Assumptions

  • The expected date format is day-first, un-padded day, 2-digit month, 4-digit year (1/03/2024), inferred from the test assertions.
  • useSearchDebounce is the canonical hook name; kept useDebounce exported too so existing consumers are unaffected.
  • Pre-existing Cannot find module 'bun:test' tsc errors are out of scope (they live in test files, which were not modified).

Testing

  • bun run test — 13 passed, 0 failed
  • npx tsc --noEmit — no new type errors (the useThrottle error is resolved)

Follow-ups (non-blocking)

  • Consider a discriminated union making aria-label compile-time required for iconOnly buttons instead of a runtime fallback.
  • The <Button icon={…} /> (non-iconOnly) case has no committed test; adding one would prevent regressing the a11y fix.

- utils: export useSearchDebounce (was renamed); reconcile api.ts import
- ui/Button: forward aria-label; guarantee accessible name for icon-only
  buttons and only mark icon decorative when other name exists (WCAG 4.1.2)
- ui/DataTable: fix stale-closure sort by merging key+dir into one atomic
  functional state update so second click toggles descending
- utils/formatDate: day-first en-AU format without zero-padded day (1/03/2024)
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