Skip to content

fix: repair cross-package bugs causing test and type failures#74

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2299-1783961642
Open

fix: repair cross-package bugs causing test and type failures#74
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2299-1783961642

Conversation

@stooit

@stooit stooit commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 9 failing tests and all tsc --noEmit type errors across the monorepo. After these changes: bun test → 13 pass, 0 fail and tsc --noEmit → clean. No test files were modified and no dependencies were added.

Bugs fixed

Five distinct cross-package bugs (plus a config blocker that hid three of them):

  1. DOM not available in UI tests (bunfig.toml) — the root bunfig set environment = "happy-dom" but did not apply the packages/ui preload, so @testing-library/react render() threw document is not defined when tests ran from the repo root. Added preload = ["./packages/ui/test/setup.ts"]. This unblocked the Button and DataTable suites.

  2. Renamed hook (apps/web/src/lib/api.ts) — useThrottle was renamed to useDebounce in packages/utils, but apps/web still imported the old name (TS2305). Updated the import and kept the useSearchDebounce public alias a test depends on.

  3. Wrong date format/locale (packages/utils/src/format/date.ts) — explicit numeric month/day options overrode locale ordering and zero-padded, producing 01/03/2024 and failing the day-first test. Switched to dateStyle: "short" with en-AU, yielding unpadded day-first output (e.g. 1/3/24).

  4. Missing accessibility attribute (packages/ui/.../Button.tsx) — the aria-label prop was accepted but never forwarded to the <button>. Now wired through, with an empty-string fallback for icon-only buttons so the attribute is always present.

  5. Stale-closure sort bug (packages/ui/.../DataTable.tsx) — the sort toggle read sortDir from a stale closure. Switched to the functional setSortDir(prev => ...) updater, fixing the controlled re-render (sort-descending) test.

  6. bun:test type resolution (tsconfig.json) — added bun-types (already a dev dependency) to compilerOptions.types so import ... from "bun:test" resolves under tsc --noEmit.

Verification

  • bun test (from repo root): 13 pass, 0 fail
  • npx tsc --noEmit: clean, exit 0
  • No *.test.* files modified; no package.json / lockfile changes.

Notes / assumptions

  • dateStyle: "short" renders a 2-digit year (1/3/24). The tests only assert day-first ordering so they pass; flagged for awareness. Kept because it is the correct locale-driven fix.

- bunfig.toml: preload happy-dom setup so DOM globals exist when tests
  run from repo root (fixes 'document is not defined' in ui tests)
- apps/web/api.ts: update import to renamed useDebounce hook (was
  useThrottle), keep useSearchDebounce alias
- utils/date.ts: use dateStyle 'short' for en-AU day-first formatting
- ui/Button: pass aria-label through to button element for icon-only
- ui/DataTable: use functional setState updater to fix stale-closure sort
- tsconfig: declare bun-types so bun:test resolves under tsc --noEmit
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