Conversation
Wire happy-dom via bunfig preload and add bun-types to tsconfig so the test suite has DOM globals and TS resolves bun:test. Fix four source bugs the tests catch: - api.ts: useThrottle -> useDebounce (hook was renamed in @e2e/utils) - Button: forward an aria-label for icon-only buttons [WCAG-4.1.2] - DataTable: use functional setState in sort handler (stale closure) - formatDate: emit day-first en-AU format without leading-zero day No test files modified, no dependencies added.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes the full suite pass (
bun test→ 13 pass / 0 fail) and clears alltsc --noEmiterrors (exit 0). Fixes two test-environment/config gaps and four source bugs spanning all three packages. No test files were modified and no dependencies were added.Changes
Config (unblocked 8 of the failures)
bunfig.toml—[test].environment = "happy-dom"is Vitest syntax that Bun silently ignores, so tests ran with no DOM (document is not defined). Replaced withpreloadof the existing happy-domsetup.ts, so barebun testnow has DOM globals.tsconfig.json— added"types": ["bun-types"]. The package is installed but not under@types, so TS never auto-included it, causingCannot find module 'bun:test'.Source bugs
apps/web/src/lib/api.ts—useThrottle→useDebounce. The hook was renamed in@e2e/utils(onlyuseDebounceis exported; the implementation is a trailing debounce, and the consumer is a search input, so debounce is the correct primitive). Merged the duplicate@e2e/utilsimports.packages/ui/.../Button.tsx— icon-only buttons now forward anaria-label(explicit label → string children → fallback), with a dev-only warning when unlabelled. Text buttons receiveundefinedso React omits the attribute and their accessible name still derives from visible text. [WCAG 4.1.2, 2.5.3]packages/ui/.../DataTable.tsx— sort handler uses the functionalsetSortDir(prev => …)form, removing a stale-closure/batched-render hazard.packages/utils/.../date.ts—formatDateemits day-first en-AU output without a leading-zero day, usingformatToPartsto preserve a 4-digit year (avoidsdateStyle: "short"truncating to1/3/24).Verification
bun test→ 13 pass / 0 fail (each package also passes standalone).bunx tsc --noEmit→ exit 0.Assumptions / follow-ups (out of scope)
D/MM/YYYY(unpadded day, padded month) — the least-bad way to satisfy the existing/^1/assertion without truncating the year. A follow-up should align on one canonical format and adjust the test."Button"aria-label fallback satisfies WCAG's letter but conveys little; the dev warning steers callers to pass a meaningful label. A compile-time requirement wasn't possible because a test renders an unlabelled icon button.formatDate(ambient TZ) is retained; it passes on UTC/AU runners but would flake at UTC+13/+14.package.jsonpinsbun-typestolatest; now load-bearing fortsc, worth pinning later.