Skip to content

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

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

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

Conversation

@stooit

@stooit stooit commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing tests and eliminates all type errors in the monorepo. bun run test now reports 13/13 pass (was 8 pass / 5 fail) and npx tsc --noEmit exits 0 (was 5 errors, incl. 1 real source error + 4 test-file resolution errors).

Four cross-package bugs were fixed, matching the areas flagged in the task:

1. Renamed hook broke a consumer — apps/web/src/lib/api.ts

The hook was renamed to useDebounce in packages/utils, but api.ts still imported/aliased the old useThrottle. Switched the import to useDebounce while preserving the public useSearchDebounce alias the test asserts. This also cleared the real type error TS2305: Module '@e2e/utils' has no exported member 'useThrottle'. No caller churn.

2. Missing accessibility attribute — packages/ui/src/components/Button/Button.tsx

ariaLabel was destructured but never applied to the <button>. Now forwarded as aria-label, with an iconOnly fallback that derives the label from string children when no explicit label is given, falling back to "Button" only when nothing can be derived — satisfying WCAG 2.2 SC 4.1.2 (Name, Role, Value). Normal text buttons get no stray aria-label. A dev-only console.warn (gated on NODE_ENV) fires only when no accessible name can be derived at all.

3. Wrong locale in date formatting — packages/utils/src/format/date.ts

formatDate(1 March 2024) returned "01/03/2024" but should be "1/03/2024" (non-padded day). Under ICU, en-AU always zero-pads the numeric day, so the locale was switched to en-GB, which produces the expected 1/03/2024. A code comment records why to prevent a well-meaning revert.

4. tsconfig — resolve bun:test type errors

Added "types": ["bun-types"] to compilerOptions so the bun:test imports in test files type-resolve. bun-types was already a devDependency. This clears the last 4 tsc errors without modifying any test file.

DataTable stale-closure test

The flagged "sorts descending on second click" test already passes and the source is correct — each click is a separate React batch, so the handler is recreated with fresh state. Left untouched per the "fix only what tests require" constraint.

Assumptions / decisions

  • Ran tests via the repo's bun run test script (uses --preload ./packages/ui/test/setup.ts for happy-dom). A bare bun test misses the preload and yields spurious document is not defined errors.
  • Chose en-GB over en-AU + dateStyle:"short" because the latter yields a 2-digit year, conflicting with the test's documented 15/06/2024 expectation.
  • No test files modified. No dependencies added.

Verification

  • bun run test → 13 pass, 0 fail
  • npx tsc --noEmit → exit 0

- api.ts: import renamed useDebounce (was useThrottle), keep public
  useSearchDebounce alias — clears TS2305 and the api import test
- Button: forward aria-label to the button element with an iconOnly
  fallback derived from string children (WCAG 2.2 SC 4.1.2); dev-only
  warning when no accessible name can be derived
- formatDate: use en-GB so the day is non-padded (1/03/2024); en-AU
  always zero-pads the numeric day under ICU
- tsconfig: add bun-types to compilerOptions.types so bun:test resolves,
  clearing the remaining test-file type errors
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