Skip to content

fix: repair cross-package bugs so all tests pass and typecheck is clean - #167

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2204-1788997586
Open

fix: repair cross-package bugs so all tests pass and typecheck is clean#167
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2204-1788997586

Conversation

@stooit

@stooit stooit commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing tests and eliminates all type errors across the monorepo (packages/ui, packages/utils, apps/web). Final state: bun test → 13 pass / 0 fail, npx tsc --noEmit → 0 errors.

Bugs fixed

  1. Renamed hook / stale import (apps/web/src/lib/api.ts) — the hook in packages/utils was renamed to useDebounce, but the app still imported the old name. Updated the consumer to import the real exported name so both the runtime import and the type check resolve.
  2. Date formatting locale (packages/utils/src/format/date.ts) — formatDate was zero-padding the day (01/03/2024). Now formats 1 Mar 2024 as day/month/year with an unpadded day, matching the test's /^1/ expectation.
  3. Missing accessibility attribute (packages/ui/.../Button.tsx) — icon-only buttons did not expose an accessible name. aria-label is now forwarded to the underlying <button>.
  4. Stale closure sort bug (packages/ui/.../DataTable.tsx) — replaced the state expression that read a stale sortDir with a functional updater, so a second click correctly toggles to descending.

Supporting changes (not source bugs, but required to run/verify)

  • bunfig.toml — wired up the already-installed @happy-dom/global-registrator preload so the UI tests have a DOM (previously failing with document is not defined). No new dependency.
  • tsconfig.json + new bun.d.ts — added a triple-slash reference to the already-installed bun-types so bun:test resolves in test files, clearing the 4 TS2307 errors. Used a reference file rather than compilerOptions.types to preserve automatic @types/react discovery. No test files modified, no new dependency.

Constraints honoured

  • No test files modified.
  • No new dependencies added (both happy-dom and bun-types were already in node_modules).
  • Only the changes required to make tests pass and typecheck clean.

Reviewer notes / assumptions

  • The DataTable "stale closure" test passes with or without the functional-updater change (each click is a discrete committed render). The functional updater is kept as the correct idiom and guards against future batching regressions, but it was not strictly required by the current test.
  • formatDate uses en-GB to get unpadded-day day/month/year output. An en-AU + formatToParts alternative was considered; either is defensible.
  • The icon-only Button falls back to a generic accessible name when no aria-label is provided (to satisfy the "still renders" test); a stricter type-level requirement would need a test edit, which is out of scope here.

- api.ts: import renamed hook (useDebounce) from @e2e/utils instead of stale name
- date.ts: format 1 Mar 2024 as en-GB style day/month/year (no leading zero on day)
- Button.tsx: forward aria-label so icon-only buttons expose an accessible name
- DataTable.tsx: use functional state updater to fix stale-closure sort toggle
- bunfig.toml: preload happy-dom global registrator so UI tests have a DOM
- tsconfig.json + bun.d.ts: reference already-installed 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