Skip to content

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

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2168-1788625022
Open

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

Conversation

@stooit

@stooit stooit commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing tests and eliminates all tsc --noEmit type errors across the monorepo. The bugs spanned four packages plus test-harness and build config.

Before: 4 pass / 9 fail · tsc --noEmit exit 2 (4 errors)
After: 13 pass / 0 fail · tsc --noEmit exit 0

Root causes & fixes

File Bug Fix
bunfig.toml environment = "happy-dom" is a Jest/Vitest key that Bun silently ignores, so @testing-library/react ran with no DOM → document is not defined (6 failures). Replaced with preload = ["./packages/ui/test/setup.ts"], which actually registers the happy-dom global.
apps/web/src/lib/api.ts Imported useThrottle from @e2e/utils, but the hook was renamed to useDebounceSyntaxError: export not found. Point the import at useDebounce. The public useSearchDebounce name is unchanged, so no consumer breakage.
packages/ui/.../Button.tsx Icon-only buttons had no accessible name; aria-label was never rendered onto the element. Render aria-label on the element, falling back to string children before a generic "Button"; dev-only console.warn when an icon-only button lacks a label. [WCAG 2.2 SC 4.1.2]
packages/utils/.../date.ts en-AU Intl.DateTimeFormat zero-pads the day (01/03/2024); test expects day-first, unpadded. Use formatToParts and Number() the day → 1/03/2024 (D/MM/YYYY). Hardcoded en-AU, locale-proof.
tsconfig.json bun-types (already a devDependency) wasn't wired in, so bun:test was unresolvable → 4× TS2307. Added "types": ["bun-types"] to compilerOptions. No new dependency.

Verification

  • bun test13 pass / 0 fail
  • ./node_modules/.bin/tsc --noEmitexit 0, no errors

Assumptions / notes

  • No test files were modified and no dependencies were added (bun-types was already declared and installed — only the tsconfig wiring was missing).
  • The formatDate output 1/03/2024 has asymmetric padding (unpadded day, zero-padded month) — this is forced by the un-editable test assertion /^1/. It diverges slightly from formatDateTime's format; a follow-up could align them, but that would require changing behaviour the tests pin.
  • The Button children-string fallback improves on a naive hardcoded "Button" (which would have masked real accessible names), but full node-tree name recovery is out of scope — passing an explicit aria-label remains the intended API, and the dev warning steers callers there.
  • Setting types in tsconfig disables automatic @types/* inclusion; harmless today (React types resolve via explicit import), but a future @types/node etc. would need appending to that array.

🤖 Generated autonomously.

…, bun-types

- bunfig.toml: replace unsupported `environment` key with `preload` so the
  happy-dom global registrator loads (fixes `document is not defined`)
- api.ts: useThrottle -> useDebounce after the hook was renamed in @e2e/utils
  (public useSearchDebounce name preserved)
- Button: apply aria-label to the element and fall back to string children
  before "Button"; dev-only warn when icon-only lacks a label [WCAG 4.1.2]
- date.ts: strip en-AU locale zero-padding via formatToParts -> D/MM/YYYY
- tsconfig.json: wire already-installed bun-types so `bun:test` resolves

bun test: 13 pass / 0 fail. tsc --noEmit: exit 0.
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