Skip to content

fix: repair cross-package test failures in monorepo - #131

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2286-1787328705
Open

fix: repair cross-package test failures in monorepo#131
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2286-1787328705

Conversation

@stooit

@stooit stooit commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 9 failing tests and the one real type error across the three-package monorepo (packages/ui, packages/utils, apps/web). bun test now reports 13 pass / 0 fail.

Fixes

Area File Fix
Test env bunfig.toml Replaced the invalid environment key with Bun's preload so happy-dom registers for the packages/ui component tests — resolves ReferenceError: document is not defined (6 tests).
Renamed hook apps/web/src/lib/api.ts The useSearchDebounce/useThrottle import was stale; the hook is now exported as useDebounce from @e2e/utils. Fixes TS2305 and 2 tests.
Accessibility packages/ui/.../Button.tsx Apply aria-label for icon-only buttons, with a dev-only console.warn when it's omitted (accessible-name test).
Stale closure packages/ui/.../DataTable.tsx Sort-direction now uses a functional setState updater, removing the captured-render-value dependency (descending-sort test).
Date format packages/utils/.../date.ts formatDate emits an unpadded en-AU day via formatToParts (1/03/2024), keeping the month zero-padded and the year 4-digit.

Key decisions & assumptions

  • Date format (formatDate): en-AU's Intl silently coerces day: "numeric" to 2-digit, and dateStyle: "short" truncates the year to 2 digits (1/3/24). Chose the formatToParts reassembly so only the single-digit day loses its leading zero — the narrowest change that satisfies the test without regressing the year width for downstream consumers (formatDate is re-exported through api.ts).
  • Button aria-label: the test only asserts an accessible name exists, so an icon-only button with no label falls back to "Button" plus a dev warning. A stricter compile-time guard (discriminated-union props) would be a breaking API change and was intentionally left out of scope.
  • Remaining tsc output is limited to pre-existing Cannot find module 'bun:test' errors in test files — unchanged from the base commit (confirmed via git stash), and out of scope since fixing them would require editing test files or adding deps.

Constraints honoured

  • No test files modified.
  • No dependencies added.
  • Only the code required by the failing tests was changed.

Verification

  • bun test -> 13 pass / 0 fail
  • tsc --noEmit -> real TS2305 error eliminated; only the pre-existing bun:test baseline remains.

Fixes 9 failing tests and the sole real type error across all three packages:

- bunfig.toml: use Bun's `preload` key (was invalid `environment`) so
  happy-dom is registered for the packages/ui component tests, resolving
  "document is not defined" (6 tests).
- apps/web/src/lib/api.ts: import the renamed `useDebounce` hook from
  @e2e/utils (was the stale `useThrottle`), fixing TS2305 and 2 tests.
- packages/ui Button: apply `aria-label` for icon-only buttons with a
  dev-only warning when omitted (accessible-name test).
- packages/ui DataTable: use a functional setState for sort direction to
  eliminate the stale-closure bug (descending-sort test).
- packages/utils formatDate: emit an unpadded en-AU day via formatToParts
  (1/03/2024) while preserving padded month and 4-digit year.

No test files modified; no dependencies added. Remaining tsc errors are
pre-existing `bun:test` module-resolution noise 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