Skip to content

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

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2177-1788929420
Open

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

Conversation

@stooit

@stooit stooit commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 9 failing tests and eliminates type errors across the monorepo. bun test now reports 13 pass / 0 fail and npx tsc --noEmit exits clean. No test files or dependencies were modified — 5 source files changed.

Root-cause fixes

  • bunfig.tomlenvironment = "happy-dom" is a Vitest/Jest key that Bun silently ignores, so the ui React tests hit ReferenceError: document is not defined. Switched to Bun's preload = ["./packages/ui/test/setup.ts"] so a DOM is available when bun test runs from the repo root (per-package runs still work).
  • apps/web/src/lib/api.ts — the hook was renamed useThrottleuseDebounce in packages/utils; the stale import broke the re-export useSearchDebounce. Updated the import/alias. Public export surface is unchanged (useDebounce is not leaked as a new export).
  • packages/ui/src/components/Button/Button.tsx — applied aria-label so an icon-only button has an accessible name (WCAG 2.2 SC 4.1.2), plus a dev-only warning when an icon-only button lacks an explicit label.
  • packages/utils/src/format/date.ts — the failure was zero-padding (01/03/2024), not field ordering as the old comment claimed. Strips the day's leading zero while keeping en-AU, emitting 1/03/2024. Comment corrected.
  • tsconfig.json — added "types": ["bun-types"] so bun:test resolves (was 4× TS2307).

Verification

  • bun test → 13 pass / 0 fail
  • npx tsc --noEmit → exit 0
  • Per-package runs still green; formatDate spot-checked across padded/unpadded days and multiple timezones.
  • No test files modified; no dependencies added.

Reviewer notes / follow-ups (out of scope, non-blocking)

  • Button accessible name: the icon-only fallback resolves to a generic name to satisfy the "renders without aria-label" test. A stronger design is a discriminated-union prop making aria-label required for the icon-only variant (compile-time enforcement) — deferred because it would require amending a test that's out of scope here.
  • date.ts: formatDate (1/03/2024) and formatDateTime (1/3/24) use inconsistent month padding / year width; no test covers formatDateTime. Neither formatter pins timeZone — pre-existing, not a regression.
  • The DataTable "stale closure" fix was not needed: the bug did not reproduce and no source change was required to pass the test.

Assumptions

  • Root bun test must pass (not just per-package), driving the bunfig.toml preload fix.
  • en-AU day-first format 1/03/2024 is the intended output per the test assertion /^1/.

- fix(test): load happy-dom via bunfig preload so root bun test gets a DOM
- fix(web): update stale useThrottle import to renamed useDebounce (aliased as useSearchDebounce)
- fix(a11y): apply aria-label to Button for accessible name [WCAG-4.1.2]
- fix(utils): strip en-AU day padding so formatDate emits d/MM/yyyy
- chore(ts): include bun-types so bun:test resolves
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