Skip to content

fix: repair cross-package bugs and DOM test wiring - #145

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2180-1788302699
Open

fix: repair cross-package bugs and DOM test wiring#145
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2180-1788302699

Conversation

@stooit

@stooit stooit commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 9 failing tests and 5 tsc --noEmit errors across the monorepo. 13 pass / 0 fail, typecheck clean. No test files modified, no dependencies added.

Root causes & fixes

  • apps/web/src/lib/api.ts — imported useThrottle from @e2e/utils, but the hook was renamed to useDebounce. Updated the import while preserving the as useSearchDebounce re-export the api test asserts.
  • packages/ui/.../Button.tsx — icon-only buttons had no accessible name. Now applies aria-label, with a dev-only console.warn and a fallback label for unlabelled icon-only buttons (WCAG 2.2 SC 4.1.2). Text buttons keep pass-through behaviour so their accessible name still derives from visible text.
  • packages/ui/.../DataTable.tsx — sort-direction toggle read stale state from a closure. Switched to functional setState(prev => ...).
  • packages/utils/src/format/date.tsen-AU numeric format zero-padded the day (01/03/2024), failing the /^1/ assertion. Reassembled via Intl.DateTimeFormat.formatToParts to drop the day's leading zero (1/03/2024).
  • bunfig.toml — added preload = ["./packages/ui/test/setup.ts"]. bun test at the repo root resolves bunfig.toml from CWD only and never reads the per-package bunfig, so happy-dom's global-registrator wasn't running — causing the document is not defined failures. This is the wiring change that fixed 6 of the 9 failures.
  • tsconfig.json — added "types": ["bun-types"] (already-installed dep) so bun:test resolves, clearing the 4 TS2307 errors.

Verification

  • bun test (bare, from root): 13 pass / 0 fail, verified stable across repeated runs
  • npx tsc --noEmit: exit 0, clean
  • Per-package runs (ui / utils / web) all green

Assumptions & notes

  • The DataTable stale-closure fix is not strictly required by the test (it passes without it once the DOM exists, since fireEvent.click flushes re-renders), but it is a genuine latent bug and the functional-setState form is strictly more correct — kept as a zero-risk correctness fix.
  • The date.ts and Button.tsx in-code BUG: comments were misdiagnosing the actual causes; docblocks were updated to match the real fixes.
  • Follow-up (out of scope): the icon-only fallback label satisfies SC 4.1.2 in the letter but isn't descriptive. The cleaner design makes aria-label a required prop when iconOnly — a breaking Props API change that would conflict with the current test contract.

Constraints honoured

  • No test files modified
  • No new dependencies added
  • Fixed only what the failing tests required (plus the one zero-risk latent DataTable bug)

- api.ts: import renamed hook useDebounce (was useThrottle), keep useSearchDebounce alias
- Button: apply aria-label with dev-only warn + fallback for icon-only buttons (SC 4.1.2)
- DataTable: use functional setState to fix stale-closure sort toggle
- date.ts: assemble via formatToParts so day drops its leading zero (en-AU)
- bunfig.toml: preload happy-dom setup so DOM globals exist for bun test at root
- tsconfig.json: include bun-types so bun:test resolves
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