Skip to content

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

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2174-1788452379
Open

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

Conversation

@stooit

@stooit stooit commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing tests and type errors in the multi-package monorepo. After these changes bun test && tsc --noEmit passes cleanly from the repo root (13 pass / 0 fail, tsc exit 0). No test files were modified and no dependencies were added.

Bugs fixed

# File Bug Fix
1 apps/web/src/lib/api.ts Imported/re-exported useThrottle, renamed to useDebounce in @e2e/utils (TS error + runtime crash) Import and re-export useDebounce; useSearchDebounce alias preserved
2 packages/utils/src/format/date.ts formatDate emitted a zero-padded day (01/03/2024); test expects unpadded (/^1/) Use dateStyle: 'short' with en-AU1/3/24
3 packages/ui/src/components/Button/Button.tsx aria-label destructured but never applied — icon-only buttons had no accessible name (WCAG 2.2 SC 4.1.2) Apply aria-label; dev-only warning + fallback label when omitted
4 packages/ui/src/components/DataTable/DataTable.tsx Stale-closure bug: second sort click didn't toggle direction Functional updater setSortDir(prev => ...)
5 bunfig.toml UI tests failed with document is not defined under a root bun test run Preload the happy-dom setup.ts at the root bunfig
6 tsconfig.json Cannot find module 'bun:test'bun-types not auto-included Add "types": ["bun-types"]

Notes / assumptions

  • DOM root cause differed from first hypothesis: Bun has no environment config option (Vitest concept) — the root bunfig's environment = "happy-dom" was inert. DOM comes solely from GlobalRegistrator in packages/ui/test/setup.ts, and Bun uses the bunfig nearest the cwd, so a root run never loaded the package-scoped preload. Fix: add the preload to the root bunfig. setup.ts (a test file) was not edited.
  • Date format: the defect was zero-padding, not field ordering — en-AU already orders day-first, but numeric fields always zero-pad. Only dateStyle: 'short' yields an unpadded day. This produces a 2-digit year (24); the test asserts nothing about the year.
  • Button a11y: test 3 requires an icon-only button with no aria-label to still expose a non-null accessible name, hence the fallback + dev warning.

Verification

$ bun test        → 13 pass, 0 fail
$ bunx tsc --noEmit → exit 0

No files under any test/ directory were modified.

…oggle

- api.ts: import/re-export useDebounce (was stale useThrottle after rename)
- date.ts: use dateStyle 'short' for en-AU so day is unpadded (D/M/YY)
- Button: apply aria-label for icon-only buttons (WCAG 2.2 SC 4.1.2), with
  dev-only warning + fallback label when omitted
- DataTable: use functional setState to fix stale-closure sort toggle
- bunfig.toml: preload happy-dom setup at root so document is defined for
  UI tests under a root `bun test` run (Bun has no `environment` option)
- tsconfig.json: add bun-types so `bun:test` module resolves

All 13 tests pass; tsc --noEmit is clean. No test files modified.
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