Skip to content

fix: repair failing tests and type errors across monorepo - #132

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2317-1787361392
Open

fix: repair failing tests and type errors across monorepo#132
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2317-1787361392

Conversation

@stooit

@stooit stooit commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing tests and type errors in the monorepo. bun test13/13 pass; npx tsc --noEmitexit 0. Four cross-package bugs plus two test-tooling config issues addressed. No test files modified; no dependencies added.

Changes

  • bunfig.toml — the [test] block used an invalid environment key (a silent no-op), so happy-dom never registered a DOM and every @testing-library/react render() threw ReferenceError: document is not defined. Switched to the valid preload entry pointing at the existing setup file. Fixes 6 DOM errors across the Button/DataTable suites.
  • tsconfig.json — added bun-types to compilerOptions.types (already present in devDependencies) so the bun:test imports in the four test files type-check. Fixes 4× TS2307.
  • apps/web/src/lib/api.ts — the useThrottle hook was renamed to useDebounce in packages/utils; updated the import and its call sites. Fixes TS2305 and the dependent tests. (Old name is no longer exported — corrected the consumer rather than re-adding the stale export.)
  • packages/utils/src/format/date.tsformatDate zero-padded the day (01/03/2024), failing the "day 1 is not confused with month 1" assertion. In en-AU, requesting a 4-digit numeric year forces ICU to zero-pad the day, so Intl options alone can't produce 1/3/2024. Reworked to use Intl.DateTimeFormat.formatToParts and reassemble day/month/year with un-padded day/month while preserving the 4-digit year. formatDateTime untouched.
  • packages/ui/src/components/Button/Button.tsxaria-label is now applied to the <button>. Icon-only buttons with no supplied label get a fallback so the accessible name is never null (WCAG 2.2 SC 4.1.2), and a dev-only console.warn fires in that fallback case. Non-icon-only buttons pass aria-label through unchanged (visible text remains the accessible name).

Assumptions & decisions (made autonomously)

  • formatDate: preserved the 4-digit year (via formatToParts) rather than switching to dateStyle: 'short' which would silently shorten the year to 2 digits on a shared, re-exported public API — chosen to avoid a latent consumer-facing regression. Satisfies both /^1/ and toContain("3").
  • Button: added a dev-only console.warn alongside the fallback label so the missing-label a11y smell is loud at development time rather than shipped silently. The tests do not spy on console.warn, so this is informational only.

Verification

  • bun test → 13 pass, 0 fail
  • npx tsc --noEmit → clean (exit 0)
  • Independent review confirmed each change is load-bearing (verified by reverting individually) with no regressions to formatDateTime or other consumers.

Follow-ups (non-blocking, out of scope)

  • The "Button" fallback prevents a nameless control but conveys no purpose; icon-only buttons in apps/web triggering the dev warn should get real labels. A discriminated-union type making aria-label required when iconOnly is true would be the honest fix but requires a test change.
  • date.ts doc comment could clarify that day-first ordering is applied explicitly for en-AU rather than derived from locale parts.

- bunfig.toml: use valid [test] preload key so happy-dom registers the
  DOM for @testing-library/react (fixes "document is not defined")
- tsconfig.json: add bun-types so `bun:test` imports type-check
- apps/web/src/lib/api.ts: update import/usage of the renamed hook
  useThrottle -> useDebounce
- packages/utils date.ts: formatDate now reassembles via Intl
  formatToParts to emit un-padded day/month with a 4-digit year (1/3/2024)
- packages/ui Button.tsx: apply aria-label to the button, fall back to a
  default for icon-only buttons with no label, and dev-warn on the fallback
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