Skip to content

fix: repair failing tests and type errors across monorepo - #114

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-3098-1786465352
Open

fix: repair failing tests and type errors across monorepo#114
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-3098-1786465352

Conversation

@stooit

@stooit stooit commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing tests and type errors in the monorepo. bun test now reports 13/13 pass (was 4/13) and tsc --noEmit exits clean (was 5 errors). No test files were modified and no dependencies were added.

Root causes & fixes

# File Problem Fix
1 bunfig.toml environment = "happy-dom" is not a real Bun config key — silently ignored, so bare bun test had no DOM (9 x document is not defined). Preload the existing packages/ui/test/setup.ts happy-dom registrator from the repo root.
2 apps/web/src/lib/api.ts Hook renamed useThrottle -> useDebounce in @e2e/utils; stale import broke tsc and the useSearchDebounce export test. Import/re-export useDebounce.
3 packages/utils/src/format/date.ts formatDate used en-AU, which hard zero-pads the day (01/03/2024); test expects 1/03/2024. Switch to en-GB with { day: "numeric", month: "2-digit", year: "numeric" }.
4 tsconfig.json Cannot find module 'bun:test'. Add "types": ["bun-types"] (already installed).
5 packages/ui/.../Button.tsx Icon-only button lacked an accessible name (WCAG 4.1.2). Always emit aria-label; dev-only console.warn when an icon-only button is given no label.
6 packages/ui/.../DataTable.tsx Stale-closure bug: sort direction toggle read stale state. Unify sortKey/sortDir into one state object driven by a single functional updater.

Verification

  • bun test -> 13 pass, 0 fail
  • npx tsc --noEmit -> exit 0
  • Reviewed by the review agent: no blockers. Fixes target root causes.

Assumptions & follow-up notes (out of scope, driven by "don't modify tests / fix only what tests require")

  • date.ts locale: No en-AU option set can satisfy the test (en-AU always zero-pads the day), so en-GB was required. Leaves formatDate (en-GB) and formatDateTime (en-AU) inconsistent — flagged for the test owner.
  • Button fallback label: Making aria-label type-required when iconOnly would break tsc on an unmodifiable test; runtime fallback + dev warning is the correct trade-off here.
  • tsconfig types: an allowlist; future consumers relying on ambient @types/* may need them re-added.

…nd sort closure

- bunfig.toml: preload happy-dom setup from repo root (the 'environment'
  key is not a real Bun option and was silently ignored, so bare
  'bun test' had no DOM). Fixes 9 'document is not defined' failures.
- apps/web/src/lib/api.ts: hook renamed useThrottle -> useDebounce in
  @e2e/utils; fix import and useSearchDebounce re-export.
- packages/utils/src/format/date.ts: formatDate used en-AU which hard-pads
  the day (01/03/2024); switch to en-GB numeric day (1/03/2024).
- tsconfig.json: add bun-types to compilerOptions.types to resolve
  'Cannot find module bun:test'.
- Button.tsx: always emit an accessible name via aria-label for icon-only
  buttons, with a dev warning when none is supplied (WCAG 4.1.2).
- DataTable.tsx: unify sortKey/sortDir into one state object updated via a
  single functional updater, fixing the stale-closure sort toggle.

No test files or dependencies changed. bun test: 13/13 pass; tsc --noEmit clean.
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