Skip to content

fix: repair cross-package test failures and type errors - #181

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2200-1789921044
Open

stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2200-1789921044

Conversation

@stooit

@stooit stooit commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Repairs all failing tests and type errors across the monorepo. bun test → 13 pass / 0 fail (was 4 pass / 9 fail); tsc --noEmit → clean (was 5 errors).

Bugs spanned all three packages plus test/build config. Only source and config were changed — no test files modified, no dependencies added (package.json/lockfile untouched).

Fixes

File Change Bug
bunfig.toml Replace the unrecognised environment key with a preload of the DOM test setup UI tests failed with ReferenceError: document is not defined — the old key was a silent no-op, so happy-dom never registered for a bare bun test
packages/ui/.../Button.tsx Apply aria-label for icon-only buttons, with a dev-only warning when omitted Icon-only button had no accessible name (WCAG 2.2 SC 4.1.2)
packages/utils/.../date.ts Use explicit numeric en-AU fields via formatToParts formatDate zero-padded the day (01/03/2024); now renders unpadded day-first 1/3/2024
apps/web/src/lib/api.ts useThrottle → useDebounce at both import and re-export sites Hook was renamed in @e2e/utils; the old name was still imported
tsconfig.json Add bun-types; include apps/*/test Cannot find module 'bun:test'; apps/web tests were never typechecked

Assumptions & notes

  • Date format preserves the 4-digit year. The minimal fix (dateStyle: "short") also passed the tests, but silently truncated the year to 2 digits (1/3/24) for every consumer of this public formatter — an unrequested behavioural regression. formatToParts fixes the padding bug the test targets while keeping 2024. Verified across multiple timezones.
  • Button uses a runtime aria-label fallback + dev warning rather than making the prop type-required for iconOnly, because a frozen test renders <Button iconOnly /> without a label — a type-level requirement would break tsc and require editing a test file, which the task forbids.
  • DataTable left untouched. Its BUG: comment about a stale-closure sort toggle no longer describes a real defect — all its tests pass unmodified because fireEvent.click flushes between clicks. Worth deleting the stale comment in a follow-up.

Suggested follow-ups (non-blocking)

  • Derive the icon-only Button accessible name from string children (needs a test-contract change).
  • Move the Button dev warning into a deduped warnOnce helper out of the render body.
  • Scope the DOM preload to packages/ui so pure packages/utils tests stay environment-free.

- bunfig.toml: replace unrecognised `environment` key with a test preload
  so the happy-dom DOM globals register for a bare `bun test`
- Button: apply an aria-label for icon-only buttons with a dev-only warning
  when one is omitted (WCAG 2.2 SC 4.1.2)
- formatDate: use explicit numeric en-AU fields via formatToParts to render
  unpadded day-first dates ("1/3/2024") while preserving the 4-digit year
- api.ts: useThrottle -> useDebounce at both the import and re-export sites
  following the hook rename in @e2e/utils
- tsconfig: add bun-types (fixes `bun:test` resolution) and typecheck
  apps/*/test

bun test: 13 pass / 0 fail. tsc --noEmit: clean.
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