Skip to content

fix: repair cross-package test failures and type errors#66

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2459-1783268941
Open

fix: repair cross-package test failures and type errors#66
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2459-1783268941

Conversation

@stooit

@stooit stooit commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing tests and eliminates all type errors across the monorepo. bun test now reports 13 pass / 0 fail and npx tsc --noEmit is clean. The bugs spanned all three packages and their interdependencies.

Fixes

  1. apps/web/src/lib/api.ts — renamed-hook import. useThrottle was renamed to useDebounce in @e2e/utils, but the old name was still imported/re-exported. Updated both while preserving the useSearchDebounce alias a test depends on.

  2. packages/ui/.../Button.tsx — missing accessibility attribute. The aria-label prop was destructured but never forwarded to the <button>, so icon-only buttons had no accessible name. Now forwarded (WCAG 4.1.2).

  3. packages/ui/.../DataTable.tsx — stale-closure bug. handleSort read sortDir from the render scope, going stale across re-renders. Switched to the functional setSortDir(prev => ...) updater — caught by the controlled re-render test.

  4. packages/utils/src/format/date.ts — date formatting. Replaced fragile explicit Intl.DateTimeFormat options with a locale-aware format for en-AU, giving portable day-first output.

  5. Test environment wiring — bunfig.toml (root + packages/ui). happy-dom environment/preload wasn't fully configured, so React Testing Library renders failed with document is not defined. Added the complementary environment = "happy-dom" and preload entries.

  6. tsconfig.jsonbun:test types. Added "types": ["bun-types"] (already installed) so bun:test/Bun globals resolve under tsc. strict unchanged — no relaxation of type checking.

Constraints honoured

  • No test specs modified (only source + setup/config files).
  • No new dependencies added (bun-types, happy-dom were already present).
  • Each change is minimal and traceable to a specific failing test.

Verification

  • bun test → 13 pass / 0 fail
  • npx tsc --noEmit → clean
  • Independent code review: approved, no blocking concerns.

- api.ts: import renamed useDebounce (was useThrottle), keep useSearchDebounce alias
- Button: forward aria-label so icon-only buttons have an accessible name
- DataTable: use functional setState updater in handleSort to fix stale-closure sort direction
- date.ts: use locale-aware dateStyle for en-AU day-first formatting
- bunfig.toml (root + ui): wire happy-dom environment + preload for RTL component tests
- tsconfig.json: add bun-types so bun:test / Bun globals resolve
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