Skip to content

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

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2123-1787859477
Open

fix: repair failing tests and type errors across the monorepo#137
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2123-1787859477

Conversation

@stooit

@stooit stooit commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing tests and eliminates all type errors in the monorepo. bun test now reports 13 pass / 0 fail and tsc --noEmit exits clean.

Six root causes across three packages, plus one test-config cleanup:

File Fix Bug
apps/web/src/lib/api.ts useThrottleuseDebounce (public useSearchDebounce name preserved) Stale import of a renamed hook — @e2e/utils no longer exported the old name
bunfig.toml Replaced unsupported environment = "happy-dom" key with preload = ["./packages/ui/test/setup.ts"] document is not defined — happy-dom was never actually registered, so all React Testing Library render() calls crashed
tsconfig.json Added "types": ["bun-types"] Cannot find module 'bun:test' under tsc --noEmit
packages/utils/src/format/date.ts en-AUen-GB (day:"numeric", month:"2-digit") en-AU silently upgrades day:"numeric" to 2-digit, producing 01/03/2024; test expects 1/03/2024
packages/ui/.../Button.tsx Apply aria-label for icon-only buttons (string-child derivation, honest "icon button" fallback, dev-time warning) [WCAG 2.2 SC 4.1.2] Icon-only button had no accessible name
packages/ui/.../DataTable.tsx Functional setSortDir(prev => ...) in the sort handler Robustness fix — see assumption below
package.json Dropped the duplicate --preload flag now covered by bunfig.toml Avoided double GlobalRegistrator.register()

Verification

  • bun test from repo root: 13/13 pass
  • bun run test (npm script): 13/13 pass
  • bunx tsc --noEmit: clean (exit 0)

Assumptions & notes

  • No test files were modified and no dependencies were added (happy-dom and bun-types were already in devDependencies).
  • DataTable "stale closure": investigation found the sort handler was not actually stale — handleSort is recreated each render, so those tests were red purely because of the happy-dom setup, not a closure bug. The functional-setState change is retained as a defensive, idiomatic improvement (no behaviour change, no regression), but it was not strictly required by the tests.
  • Button accessible name: the test only asserts the aria-label is non-null, and test files cannot be changed, so a synthesised fallback is unavoidable. The fallback is an honest "icon button" and a dev-time console.warn nudges developers to supply a real label. Consider promoting that warning to a hard error in CI in a follow-up so meaningless names can't ship silently.
  • date.ts locale: en-GB was chosen to satisfy the day-first / no-leading-zero assertion. An en-AU-preserving alternative (dateStyle: "short") also passes but changes the year to 2 digits; formatDateTime was intentionally left on en-AU to avoid scope creep beyond what the tests require.

…te locale

- api.ts: correct stale import (useThrottle -> useDebounce backing useSearchDebounce)
- bunfig.toml: register happy-dom via preload so DOM is available for ui tests
- tsconfig.json: add bun-types so 'bun:test' resolves for tsc --noEmit
- date.ts: use en-GB so day is not zero-padded (1/03/2024, not 01/03/2024)
- Button.tsx: apply aria-label for icon-only buttons with honest fallback [WCAG-4.1.2]
- DataTable.tsx: functional setState in sort handler (robust under batching)
- package.json: drop duplicate --preload flag now provided by bunfig.toml
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