Skip to content

fix: repair cross-package bugs so tests and tsc pass#69

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2469-1783528723
Open

fix: repair cross-package bugs so tests and tsc pass#69
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2469-1783528723

Conversation

@stooit

@stooit stooit commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing tests and type errors in the monorepo. bun test (13/13 pass) and tsc --noEmit (clean) are both green. No test files were modified and no dependencies were added.

Fixes

  1. bunfig.toml — added preload = ["./packages/ui/test/setup.ts"] under [test]. When tests run from the repo root the root bunfig applies, but the happy-dom global registrator only ran via the packages/ui bunfig — so packages/ui React tests hit document is not defined. Preloading the setup at the root registers the DOM globals.
  2. apps/web/src/lib/api.ts — the hook was renamed useThrottleuseDebounce in @e2e/utils, but this file still imported/re-exported the old name, breaking the useSearchDebounce re-export. Updated the import and re-export to useDebounce.
  3. packages/utils/src/format/date.tsformatDate used explicit month/day/year: "numeric" options which rendered US month-first order. Switched to { dateStyle: "short" } on the en-AU locale so dates are day-first with no leading zero on single-digit days (e.g. 1/03/2024).
  4. packages/ui/src/components/Button/Button.tsx — the destructured ariaLabel prop was never applied. Added aria-label={iconOnly ? (ariaLabel ?? "") : ariaLabel} so icon-only buttons always carry the attribute (required by the test) and other buttons set it only when provided.
  5. packages/ui/src/components/DataTable/DataTable.tsxhandleSort read sortDir from a stale closure, so a second click did not toggle to descending. Switched to the functional updater setSortDir(prev => prev === "asc" ? "desc" : "asc").

Supporting change

  • tsconfig.json — added "types": ["bun-types"] so tsc --noEmit resolves the Bun test globals (test, expect, …) used in the .test.ts files. bun-types is already an installed dependency; no new deps added.

Verification

  • bun test → 13 pass / 0 fail
  • tsc --noEmit → clean (exit 0)
  • git diff --name-only confirms no test/ files were touched.

Assumptions

  • Treated bunfig.toml, the DOM setup.ts preload, and tsconfig.json as configuration (not test files), so editing them is within the "do not modify test files" constraint.
  • The Button icon-only without aria-label test requires the attribute to be present (non-null) when iconOnly is set, so the empty-string fallback is intentional and kept.

- bunfig.toml: preload happy-dom setup so DOM globals register when tests run from root (fixes 'document is not defined' in packages/ui)
- apps/web api.ts: import renamed useDebounce (was useThrottle) for the useSearchDebounce re-export
- utils/date.ts: use en-AU dateStyle:'short' for day-first formatting
- ui/Button: pass ariaLabel through to the button element
- ui/DataTable: use functional setState updater to fix stale-closure sort direction
- tsconfig.json: add bun-types so tsc resolves bun test globals
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