Skip to content

fix: repair failing tests and type errors across the monorepo - #172

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

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

Conversation

@stooit

@stooit stooit commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing tests and eliminates all type errors across the monorepo. Baseline was 8 pass / 5 fail with 5 type errors; now 13 pass / 0 fail with 0 type errors (bun run test and tsc --noEmit).

Four cross-package bugs plus one tsconfig issue:

  • apps/web/src/lib/api.ts — the hook was renamed useThrottleuseDebounce in @e2e/utils, but api.ts still imported the old name (runtime SyntaxError + TS2305). Updated the import and the useSearchDebounce re-export to the real export. Confirmed the hook body is genuinely a debounce, so renaming the consumer (rather than re-adding a useThrottle alias) is the correct direction.
  • packages/utils/src/format/date.tsformatDate returned 01/03/2024; the test contract is day-first with no leading zero on the day (1/03/2024). Keeps the en-AU locale and strips only the day's leading zero. Verified across multiple dates (incl. 2024-02-29) that only the day part is affected, never the month.
  • packages/ui/src/components/Button/Button.tsx — icon-only buttons had no accessible name. Now exposes one via aria-label (an explicit caller-supplied aria-label always wins), with a dev-mode console.warn citing WCAG 2.2 SC 4.1.2 when an icon-only button is rendered without a label. Text and icon+text buttons emit no aria-label (verified).
  • tsconfig.json — added bun-types to compilerOptions.types so bun:test resolves (TS2307 in the test files). No dependency added — bun-types was already a devDependency; skipLibCheck retained.

Also removed stale/misleading BUG: comments in DataTable.tsx and useDebounce.ts that described defects which no longer (or never) existed.

Investigated but deliberately not changed

  • DataTable "stale closure" — the flagged stale-closure bug is a phantom: handleSort is a plain inline function recreated every render (no useCallback/useMemo), so it always reads current state. The test passes untouched; no edit made.
  • Happy-dom / document is not defined — this only occurs with a bare bun test that skips the --preload ./packages/ui/test/setup.ts in the project's test script. It is an invocation artefact, not a source bug; setup.ts registers happy-dom correctly. No change needed — run via bun run test.

Assumptions

  • The d/mm/yyyy day-first, no-leading-zero-day format is the intended formatDate contract (asserted directly by date.test.ts).
  • Test files and package.json were not modified, and no dependencies were added, per task constraints.

Verification

bun run test  → 13 pass / 0 fail
tsc --noEmit  → 0 errors (exit 0)

Follow-ups (out of scope, not blocking)

  • The stronger Button fix is a discriminated-union Props type making aria-label mandatory when iconOnly: true — turns the runtime warning into a compile error, but requires editing Button.test.tsx (out of scope here).
  • The date leading-zero strip is correct but coupled to a day-first locale; a formatToParts mapping would remove that implicit assumption.

🤖 Generated with QuantCode

…abel, and bun:test types

- api.ts: import useDebounce (renamed from useThrottle) from @e2e/utils
- date.ts: emit day-first with no leading zero on day (en-AU, d/mm/yyyy)
- Button: expose accessible name for icon-only buttons via aria-label,
  with dev-mode WCAG 2.2 SC 4.1.2 warning when no aria-label is supplied
- tsconfig.json: add bun-types to types so bun:test resolves
- remove stale/misleading BUG comments in DataTable and useDebounce
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