Skip to content

fix: repair cross-package bugs breaking tests and typecheck - #165

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2172-1788970779
Open

fix: repair cross-package bugs breaking tests and typecheck#165
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2172-1788970779

Conversation

@stooit

@stooit stooit commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Repairs all failing tests and type errors in the monorepo. bun test13 pass / 0 fail; bunx tsc --noEmitclean (exit 0). Bugs spanned all three packages (packages/ui, packages/utils, apps/web) plus build config.

Fixes

# File Bug Fix
1 apps/web/src/lib/api.ts Imported/re-exported a hook by a stale name (useThrottle); the real export in packages/utils is useDebounce, causing SyntaxError: export 'useSearchDebounce' not found Import useDebounce, keep the public useSearchDebounce alias so no caller breaks
2 bunfig.toml Root config used [test].environmentnot a real bun option, so it silently did nothing and DOM globals were missing → ReferenceError: document is not defined in all UI tests Use the supported preload mechanism to load the happy-dom setup so bare bun test from the repo root has a DOM
3 packages/ui/.../Button.tsx Icon-only button rendered no accessible name; test expects a non-null aria-label Resolve an aria-label (explicit prop → string children → "Button" floor) with a dev-only warning when an icon-only button has no explicit label
4 packages/ui/.../DataTable.tsx Stale closure in the sort handler — setSortDir(sortDir === ...) reads the render-time captured value; two toggles in one batch produce the wrong direction and wrong aria-sort Functional updater: setSortDir(prev => prev === "asc" ? "desc" : "asc")
5 packages/utils/.../date.ts formatDate emitted a zero-padded day (01/03/2024); test requires an unpadded, day-first en-AU format Use Intl.DateTimeFormat("en-AU").formatToParts to strip the day's leading zero → 1/03/2024
6 tsconfig.json Four TS2307 errors resolving bun:test etc. Add bun-types (+react) to compilerOptions.types

Constraints honoured

  • No test files modified, no dependencies added (verified: git diff touches no *.test.* or package.json).
  • Fixed only what the tests require; stale BUG: diagnostic comments removed from edited files for consistency.

Assumptions / notes

  • aria-label="Button" fallback is a compliance floor to satisfy the test (Button.test.tsx:24 renders an icon-only button with no label and expects it to still render). A type-level "require aria-label for iconOnly" was rejected because it would make the test file itself a type error. The dev warning mitigates the weak label.
  • DataTable stale-closure fix is confirmed correct on inspection but not directly exercised by the current suite (no test clicks a sortable header twice) — it prevents a real defect the task brief flagged and removes flakiness risk under future React versions / userEvent.
  • Out-of-scope defects noted, not changed (would require behavioural/test changes): DataTable sort headers are mouse-only (no keyboard handler/role — WCAG 2.1.1/4.1.2); formatDate and formatDateTime disagree on year width (pre-existing).

- api.ts: import/re-export renamed useDebounce hook (was stale useThrottle)
- bunfig.toml: preload happy-dom setup so bare 'bun test' has DOM globals
- Button: provide accessible aria-label for icon-only buttons + dev warning
- DataTable: fix sort-direction stale closure via functional state updater
- date.ts: format en-AU date with unpadded day via Intl.formatToParts
- tsconfig: add bun-types/react to resolve module type errors
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