Skip to content

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

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2175-1788936449
Open

fix: repair cross-package bugs so all tests and typecheck pass#161
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2175-1788936449

Conversation

@stooit

@stooit stooit commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 5 failing tests and 5 type errors across the monorepo. After these changes bun run test reports 13/13 pass and bun run typecheck (tsc --noEmit) exits 0. No test files or package.json were modified.

Changes

Area File Fix
Renamed hook apps/web/src/lib/api.ts The hook was renamed to useDebounce in @e2e/utils but api.ts still imported useThrottle. Import the real export and keep the useSearchDebounce alias the app/test expect. useDebounce is a genuine trailing-edge debounce, so this is a rename, not a semantic swap.
Accessibility attr packages/ui/src/components/Button/Button.tsx aria-label was never forwarded to the <button> element. Now forwarded; for iconOnly buttons it defaults to an explicit label (explicit aria-label is never clobbered), with a dev-only WCAG 2.2 SC 4.1.2 warning. Guard hardened with typeof process !== "undefined" so it can't throw in browsers.
Stale-closure bug packages/ui/src/components/DataTable/DataTable.tsx Sort key and direction were two separate useState atoms; on batched clicks the toggle branch read stale state and never fired. Merged into one sort object updated through a single functional updater so key/direction update atomically.
Date format packages/utils/src/format/date.ts formatDate produced 01/03/2024 (leading-zero day); the test requires a day-first, unpadded day (1/03/2024). Switched to en-GB with explicit field options. formatDateTime aligned to match (it had drifted to a 2-digit year).
Type config tsconfig.json Added bun-types and the apps test glob so apps/web/test typechecks — mirrors the existing packages test pattern, and resolves the bun:test errors.

Assumptions & judgement calls

  • Pinned timeZone Australia/Sydney in the date formatters. Load-bearing, not cosmetic: without it the date test fails under non-AEST timezones (e.g. the UTC timestamp renders as 02/03/2024 under Pacific/Auckland). Pinning makes output deterministic regardless of host timezone. Follow-up could make it an opt-in parameter.
  • Unpadded day (1/03/2024). Required by the test regex. A follow-up could pad both fields and relax the test if a stricter DD/MM/YYYY convention is preferred (out of scope: would require a test change).
  • iconOnly default label + dev warning kept as runtime behaviour. A stricter design would make aria-label a compile-time requirement via a discriminated union; left as a follow-up to avoid widening the public Button API beyond what tests require.

Testing

  • bun run test -> 13 pass, 0 fail
  • bun run typecheck -> exit 0
  • Date formatters verified consistent across UTC, America/New_York, and AU timezones.

- api.ts: import renamed hook useDebounce (was useThrottle), keep useSearchDebounce alias
- Button: forward aria-label to DOM element and default it for icon-only buttons; dev-only WCAG 4.1.2 warning (guarded for browser/no-process environments)
- DataTable: merge sort key/direction into a single atomically-updated state object to fix stale-closure bug on batched clicks
- date.ts: format day-first with 4-digit year and a pinned timeZone so output is deterministic across timezones; align formatDateTime with formatDate
- tsconfig: add bun-types and apps test globs so test files typecheck
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