Skip to content

fix: repair test harness, cross-package imports, and formatting bugs - #136

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2228-1787761934
Open

fix: repair test harness, cross-package imports, and formatting bugs#136
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2228-1787761934

Conversation

@stooit

@stooit stooit commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing tests and type errors in the monorepo. Baseline was 4 pass / 9 fail with 5 tsc errors; now 13 pass / 0 fail and bunx tsc --noEmit exits clean.

Bugs fixed (spanning all three packages)

Area Root cause Fix
Test harness (bunfig.toml) environment = "happy-dom" is a Vitest key Bun silently ignores, so no DOM ever registered — every @testing-library/react render threw document is not defined. Replaced with a root-relative preload of the happy-dom global registrator setup.
Cross-package import (apps/web/src/lib/api.ts) Imported useThrottle from @e2e/utils, which had been renamed. Import/re-export useDebounce; the underlying hook is a genuine debounce so useSearchDebounce's semantics now match its name.
Accessibility (packages/ui Button) aria-label was destructured but never applied to the element. Apply the label; dev-warn on unlabelled icon-only buttons (WCAG 2.2 SC 4.1.2).
Stale closure (packages/ui DataTable) Sort-toggle read the render-time sortDir. Functional setState setSortDir(prev => ...) so a net-2-toggle is a true no-op.
Date formatting (packages/utils) en-AU output padded the day (01/03/2024). Intl.formatToParts with an unpadded day gives 1/03/2024, year preserved as 4 digits, TZ-robust.
Types (tsconfig.json) bun:test imports failed TS2307. Added bun-types to compilerOptions.types.

Verification

  • bun test -> 13 pass / 0 fail
  • bunx tsc --noEmit -> exit 0

Constraints upheld

  • No test files modified.
  • No dependencies added (package.json / lockfile untouched).

Assumptions / notes

  • The original in-code BUG comments diagnosed the date bug as MM/DD/YYYY field ordering; the actual defect was a leading zero on the day (dateStyle: "short" would have truncated the year), so the fix targets padding, not ordering.
  • Follow-ups (out of scope, not required by tests): make Button's aria-label compile-time-required via a discriminated union when iconOnly; consider a per-suite DOM env rather than a global preload.

Fix all failing tests and type errors across the monorepo:

- bunfig.toml: replace ignored Vitest `environment` key with a bun
  `preload` of the happy-dom global registrator so DOM is available in
  packages/ui component tests (fixes "document is not defined").
- apps/web/src/lib/api.ts: import/re-export `useDebounce` (renamed from
  the now-nonexistent `useThrottle`) from @e2e/utils.
- packages/ui Button: apply the destructured aria-label to the element
  and warn on unlabelled icon-only buttons (WCAG 2.2 SC 4.1.2).
- packages/ui DataTable: use functional setState for the sort-direction
  toggle to eliminate the stale-closure defect.
- packages/utils date: use Intl formatToParts with an unpadded day so
  en-AU output is day-first without a leading zero (1/03/2024).
- tsconfig.json: add bun-types so `bun:test` imports type-check.

No test files modified; no dependencies added.
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