Skip to content

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

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2175-1788927519
Open

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

Conversation

@stooit

@stooit stooit commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing bun test tests and tsc --noEmit type errors across the monorepo. Final gate: 13 pass / 0 fail, tsc --noEmit exit 0. No test files, package.json, or lockfiles were modified; no dependencies added.

Bugs fixed

File Bug Fix
bunfig.toml environment = "happy-dom" is a Jest key that Bun silently ignores → all render tests threw document is not defined Replaced with preload = ["./packages/ui/test/setup.ts"] so happy-dom actually registers DOM globals
tsconfig.json bun:test unresolved → TS2307 ×4 Added "types": ["bun-types"] (already installed)
apps/web/src/lib/api.ts Imported useThrottle which no longer exists in @e2e/utils → TS2305 Renamed to the current useDebounce export (import + re-export); collapsed duplicate imports
packages/utils/src/format/date.ts formatDate produced 01/03/2024; test expects day-first with no leading zero (1/03/2024) Used formatToParts and strip the day's leading zero
packages/ui/src/components/Button/Button.tsx Icon-only button lacked an accessible name (WCAG 2.2 SC 4.1.2) Apply aria-label from explicit label or string children; dev warning when missing
packages/ui/src/components/DataTable/DataTable.tsx Sort-direction toggle read state via closure Functional state updater (setSortDir(prev => ...))

Notes & assumptions

  • Date format contract: the test comments state the literal expected output (1/03/2024, 15/06/2024) — 4-digit year, day-first, no leading zero on day. Implemented to match that exactly rather than dateStyle: "short" (which would give a 2-digit year). formatDateTime was left untouched.
  • Button hardening (from review): guarded process.env with typeof process !== "undefined" since @e2e/ui ships raw TS and a consumer bundler could otherwise throw ReferenceError: process is not defined. The no-label fallback is "" (not a bogus "Button") so a11y scanners still flag a genuinely unlabelled button.

Known limitations (out of scope)

  • formatDate uses the ambient system timezone; tests use T12:00:00Z (±12h headroom), only break at UTC+13/+14. Pre-existing, not a regression.
  • formatDate vs formatDateTime render years inconsistently (4-digit vs 2-digit).
  • The Button test asserts the aria-label attribute is present rather than non-empty.

- bunfig.toml: replace invalid 'environment' key with 'preload' so happy-dom
  registers and DOM globals exist under bun test (fixes 'document is not defined')
- tsconfig.json: add 'bun-types' to types so 'bun:test' resolves (fixes TS2307)
- utils/date.ts: format day-first with no leading zero on day via formatToParts
- web/api.ts: rename removed useThrottle import to the current useDebounce export
- ui/Button.tsx: apply aria-label for icon-only buttons; guard process.env and
  avoid masking the a11y defect with a bogus fallback label
- ui/DataTable.tsx: use functional state updater for sort direction toggle
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