Skip to content

fix: resolve cross-package test failures and type errors - #179

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2243-1789748248
Open

stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2243-1789748248

Conversation

@stooit

@stooit stooit commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing tests and type errors across the monorepo. Before: 5 failing tests + a tsc type error. After: 13/13 tests pass (bun run test) and tsc --noEmit exits 0.

Bugs spanned all three packages (packages/ui, packages/utils, apps/web):

  • Hook rename mismatch (utils + web): the debounce hook was renamed but consumers drifted. apps/web/src/lib/api.ts imported the non-existent useThrottle, while the test asserts useSearchDebounce is the exported name. Made useSearchDebounce canonical end-to-end — renamed the hook file/function, updated the barrel export in packages/utils/src/index.ts, and fixed the apps/web import/re-export. The public export name from api.ts is unchanged, so downstream consumers are unaffected.
  • Button aria-label not applied (ui): the aria-label prop never reached the rendered <button>. Now forwarded to the element, and icon-only buttons derive a non-null accessible name (WCAG 2.2 SC 4.1.2). aria-hidden on the decorative icon is applied only when the button already has an accessible label, so it can never strip the accessible name.
  • DataTable stale-closure (ui): consolidated split sortKey/sortDir state into a single object updated via a functional setState, so repeated clicks toggle sort direction robustly even under batched/StrictMode re-renders.
  • Date format (utils): formatDate kept en-AU field order and separators but the day was zero-padded (01/03/2024). Now strips the leading zero on the day via formatToParts -> 1/03/2024, satisfying the test while preserving DD/MM/YYYY ordering. currency formatting untouched.
  • tsconfig (bun:test resolution): added "types": ["bun-types"] so bun:test imports resolve and tsc --noEmit exits cleanly. This is a config file, not a test file.

Assumptions & decisions

  • The test files are the source of truth and were not modified (per the task constraints). Where the tests dictate a specific shape (canonical hook name useSearchDebounce, day format matching /^1/, non-null aria-label on icon-only buttons), the source was changed to match.
  • Scope kept minimal. A code review flagged two initially-introduced changes that went beyond what tests required — a hard-coded type="button" (which would silently break form submission) and an over-broad aria-hidden that could remove a button's accessible name. Both were reverted/tightened so no consumer behaviour changed beyond the fixes the tests demand.
  • No new dependencies added; bun-types was already in devDependencies.

Verification

  • bun run test -> 13 pass, 0 fail
  • ./node_modules/.bin/tsc --noEmit -> exit 0, no output

Generated with QuantCode

- utils: rename useDebounce -> useSearchDebounce (was mis-imported as
  useThrottle in apps/web) and update the barrel export + consumer
- ui/Button: forward aria-label to the button element and derive a
  non-null accessible name for icon-only buttons (WCAG 4.1.2)
- ui/DataTable: consolidate sort state into a single object updated via a
  functional setState to remove the potential stale-closure toggle bug
- utils/formatDate: keep en-AU field order/separators but strip the day's
  leading zero via formatToParts so 1 March -> 1/03/2024
- tsconfig: add types: [bun-types] so bun:test resolves (tsc exits 0)
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