Skip to content

fix: repair cross-package test and type failures - #109

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

fix: repair cross-package test and type failures#109
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2174-1785947909

Conversation

@stooit

@stooit stooit commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing tests and type errors in the monorepo. bun test goes from 4 pass / 9 fail → 13 pass / 0 fail, and npx tsc --noEmit from 5 errors → 0. No test files were modified and no dependencies were added.

Fixes

# File Problem Fix
1 apps/web/src/lib/api.ts Imported the old hook name useThrottle, which no longer exists in @e2e/utils (renamed) Updated import to the current export (useSearchDebounce/useDebounce)
2 bunfig.toml (root) Root config used environment = "happy-dom" — a Vitest option Bun silently ignores — so document was undefined for UI tests run from root Registered the happy-dom preload the way Bun actually honours. packages/ui/bunfig.toml was verified as still required and left intact
3 packages/ui/.../Button.tsx Icon-only button had no accessible name; test asserts a non-null aria-label Wired aria-label with a fallback so the icon-only button always has an accessible name
4 packages/ui/.../DataTable.tsx Sort-direction toggle used a value captured from the render closure Switched to a functional setState update (correct, regression-hardening pattern)
5 packages/utils/.../date.ts formatDate emitted 01/03/2024 (leading zero); test expects /^1/ Used Intl { dateStyle: "short" } (en-AU), which yields day-first with no leading zero. Note: the source comment's suggested field-reorder does not fix this — Intl ignores option order
6 tsconfig.json Test files failed TS2307: Cannot find module 'bun:test' Added bun-types to types (alongside react) so bun:test resolves

Assumptions & notes

  • Fix 5 side effect: dateStyle: "short" produces a 2-digit year (1/3/24). This is the only Intl option satisfying both test assertions; documented in the source. External consumers of @e2e/utils relying on a 4-digit year would see a change — flagged for team confirmation.
  • Fix 3 (aria-label fallback): a generic fallback label satisfies the test but is weak for screen-reader users. A type-level fix (requiring aria-label when iconOnly) was rejected because it fails to compile against the existing (unmodifiable) test. Recommend a dev-only console.warn follow-up to surface the omission.
  • Fix 4: the functional-update fix is correct, but verification showed the DOM-preload fix (fix: resolve all failing tests across monorepo packages #2) alone already made the DataTable test pass — fireEvent flushes each click in its own render cycle, so this test doesn't actually discriminate the stale-closure bug. The fix is kept as it's the correct pattern.

Verification

bun test        → 13 pass / 0 fail
npx tsc --noEmit → exit 0

- api.ts: update import to renamed useSearchDebounce/useDebounce hook (was useThrottle)
- bunfig.toml: register happy-dom preload so document is defined under bun test from root
- Button: add aria-label wiring with fallback so icon-only buttons have an accessible name
- DataTable: use functional setState update to fix stale-closure sort direction toggle
- date.ts: use Intl dateStyle:short (en-AU) so formatDate emits day-first without leading zero
- tsconfig.json: add bun-types so bun:test resolves in test files
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