Skip to content

fix: resolve failing tests across ui, utils, and web packages - #142

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2166-1788106609
Open

fix: resolve failing tests across ui, utils, and web packages#142
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2166-1788106609

Conversation

@stooit

@stooit stooit commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing tests and type errors in the monorepo. Baseline (via bun run test) was 5 fail / 8 pass plus 5 tsc errors; now 13 pass / 0 fail and tsc --noEmit is clean.

Root causes & fixes

  1. Hook rename mismatch (packages/utils/src/index.ts, apps/web/src/lib/api.ts)
    The debounce hook is consumed as useSearchDebounce, but api.ts still imported the old useThrottle name (TS2305). Exported the hook as useSearchDebounce and updated the import.

  2. Button missing accessible name (packages/ui/src/components/Button/Button.tsx)
    Icon-only buttons rendered no aria-label (WCAG 4.1.2). Now applies a caller-provided label when present, with a safe fallback so the attribute is never null, plus a dev-only console.warn when an icon-only button has no explicit label.

  3. DataTable stale-closure sort bug (packages/ui/src/components/DataTable/DataTable.tsx)
    The sort handler read sortDir captured at handler-creation time, so batched clicks never toggled to descending. Collapsed the separate key/dir useState into one atomic sort object updated via a functional setSort(prev => ...) updater.

  4. formatDate padded the day (packages/utils/src/format/date.ts)
    en-AU pads the day to two digits even with day: "numeric". Switched to en-GB (same day-first ordering, unpadded day) so 2024-03-01 -> 1/03/2024 as the test expects.

  5. bun:test type resolution (tsconfig.json)
    Added "types": ["bun-types"] so import ... from "bun:test" resolves under tsc --noEmit. No dependency added (bun-types was already present).

Assumptions

  • Tests are run via bun run test (the npm script adds the required happy-dom preload); raw bun test fails with document is not defined and is not the intended invocation.
  • No test files were modified and no dependencies were added, per task constraints.
  • The aria-label fallback satisfies WCAG 4.1.2 at the attribute level; a stronger type-level requirement was intentionally not applied because a test renders an icon-only button without a label and test files must not change.

Verification

  • bun run test -> 13 pass, 0 fail
  • npx tsc --noEmit -> exit 0, no output

Reviewed by the review subagent: approved, no blockers.

- utils: export debounce hook as useSearchDebounce (was renamed) and
  update apps/web/src/lib/api.ts to import the current name
- ui/Button: apply aria-label on icon-only buttons (WCAG 4.1.2), with a
  safe fallback and a dev-only warning when no explicit label is given
- ui/DataTable: fix stale-closure sort bug by collapsing sort key/dir
  into one atomic state updated via a functional setState updater
- utils/formatDate: use en-GB day-first format so the day is unpadded
  (1/03/2024) as the test expects
- tsconfig: add "types": ["bun-types"] so bun:test resolves under tsc
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