Skip to content

fix: repair cross-package bugs so tests and typecheck pass - #160

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2169-1788936489
Open

fix: repair cross-package bugs so tests and typecheck pass#160
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2169-1788936489

Conversation

@stooit

@stooit stooit commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing tests and eliminates all type errors in the monorepo. The acceptance gate bun test && npx tsc --noEmit now passes: 13 pass / 0 fail, tsc exit 0 (baseline was 4 pass / 9 fail, 5 TS errors).

Bugs spanned all three packages (packages/ui, packages/utils, apps/web) plus root test config.

Fixes

# File Root cause Fix
1 bunfig.toml environment = "happy-dom" is a no-op in bun, so DOM globals were absent when running bun test from the repo root → ReferenceError: document is not defined in all UI tests. Preload the existing happy-dom setup file.
2 apps/web/src/lib/api.ts Imported useThrottle from @e2e/utils, but the hook was renamed to useDebounce (TS2305). Import/re-export the correct name; merged the duplicate import.
3 packages/ui/.../Button.tsx Icon-only button had no accessible name; test asserts an aria-label-derived name is present. Forward aria-label; provide a fallback accessible name for icon-only buttons with a dev warning when unlabelled [WCAG 2.2 SC 4.1.2].
4 packages/ui/.../DataTable.tsx Stale-closure bug: separate sortKey/sortDir state meant second-click descending sort read a stale value. Collapse into a single state object with a functional updater (atomic key+dir).
5 packages/utils/.../date.ts en-AU Intl widens a numeric day to 01, so formatDate(1 Mar 2024) returned 01/03/2024; test expects day-first single-digit 1/03/2024. De-pad the day part via formatToParts.
6 tsconfig.json bun:test unresolved (TS2307) — bun-types lives outside node_modules/@types/ so it isn't auto-included. Add explicit "types": ["bun-types"] with an explanatory comment.

Assumptions & notes

  • No test files, package.json, or lockfile were modified; no dependencies added — per task constraints (verified via git diff --name-only).
  • tsconfig.json "types" array disables auto-inclusion of other @types/* packages. @types/react still resolves via module imports and typecheck is clean; a comment was added so future @types/* additions aren't silently ignored.
  • The DataTable change goes slightly beyond a one-line functional updater (collapses key+dir into one object). It's internal-only (no Props/API change), makes the new-column path atomic, and produces identical output for all tested sequences. Reviewed as justified and low-risk.
  • The console.warn seen during the test run is expected — a test exercises the unlabelled icon-only Button path.

Verification

  • bun test → 13 pass, 0 fail
  • npx tsc --noEmit → exit 0
  • Independent code review completed: verdict COMMENT, no blockers.

Out of scope (pre-existing, flagged for follow-up)

  • DataTable sortable <th> is mouse-only (no keyboard handler) — pre-existing WCAG 2.2 SC 2.1.1 gap.
  • formatDate (4-digit year) vs formatDateTime (dateStyle: "short", 2-digit year) inconsistency — pre-existing.

- bunfig.toml: preload happy-dom setup so DOM globals exist for root `bun test`
  (the prior `environment = "happy-dom"` key is a no-op in bun)
- apps/web api.ts: import/re-export renamed hook useDebounce (was useThrottle)
- Button: forward aria-label and provide accessible name for icon-only buttons
  with a dev warning when unlabelled [WCAG 2.2 SC 4.1.2]
- DataTable: collapse sort key/dir into one state object to fix stale-closure
  bug on second-click descending sort
- date.ts: de-pad the day part so en-AU output is day-first single-digit
- tsconfig.json: add explicit "types": ["bun-types"] for bun:test resolution

No test files, package.json, or lockfile 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