Skip to content

fix: repair failing tests across ui/utils/web packages - #180

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

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

Conversation

@stooit

@stooit stooit commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 9 failing tests and 5 type errors in the monorepo. Suite now reports 13 pass / 0 fail and tsc --noEmit is clean.

Root causes & fixes

  • apps/web/src/lib/api.ts — imported a stale hook name useThrottle from @e2e/utils; the hook was renamed to useDebounce. Updated the import and re-export. (useSearchDebounce has no call sites, so no behavioural change.)
  • packages/utils/src/format/date.ts — formatDate produced 01/03/2024 (zero-padded day) under en-AU; the test requires 1/03/2024. Switched to Intl.DateTimeFormat.formatToParts and stripped the day's leading zero. Month stays padded, year stays 4-digit; formatDateTime/formatAUD unaffected.
  • packages/ui/src/components/Button/Button.tsx — icon-only buttons rendered with no accessible name (WCAG 2.2 SC 4.1.2). Now bind aria-label, falling back to string children, plus a dev-only console.warn when an icon-only button lacks a label.
  • packages/ui/src/components/DataTable/DataTable.tsx — sort toggle changed to a functional setState update to harden against stale-closure/batched-update issues.

Test-config fixes (no source-behaviour impact)

  • bunfig.toml — environment = "happy-dom" is not a recognised Bun [test] key and was silently inert; replaced with a preload registering the happy-dom setup so bun test provides a DOM standalone. This unblocked the document is not defined errors.
  • tsconfig.json — added bun-types to compilerOptions.types to resolve the bun:test module (fixed 4x TS2307).

Constraints honoured

  • No test files modified (verified via git diff --name-only).
  • No new dependencies added — only pre-installed bun-types and @happy-dom/global-registrator used; package.json/lockfile untouched.

Verification

  • bun test -> 13 pass / 0 fail
  • tsc --noEmit -> exit 0, zero errors

Reviewer notes / assumptions

  • The Button aria-label fallback to a generic label is required by Button.test.tsx (asserts the attribute is non-null even when no label is passed). A stricter approach would fail that test, so the dev console.warn surfaces the misuse instead.
  • The DataTable "stale closure" fix is defensive — the original already passed under separate click events; the functional update is idiomatic hardening.
  • Follow-ups out of scope for this test-fix pass: DataTable sortable headers are keyboard-inaccessible (WCAG 2.1.1 Level A); repo has no lockfile (bun-types: "latest" unpinned).

…nd test config

- api.ts: import renamed useDebounce hook from @e2e/utils (was stale useThrottle)
- formatDate: strip en-AU day zero-padding via formatToParts (1/03/2024 not 01/03/2024)
- Button: bind aria-label for icon-only buttons with dev warning [WCAG 4.1.2]
- DataTable: use functional setState for sort toggle (harden against stale closure)
- bunfig.toml: register happy-dom via preload (test.environment is not a Bun key)
- tsconfig.json: add bun-types for bun:test module resolution
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