fix: repair cross-package test failures in monorepo - #131
Open
stooit wants to merge 1 commit into
Open
Conversation
Fixes 9 failing tests and the sole real type error across all three packages: - bunfig.toml: use Bun's `preload` key (was invalid `environment`) so happy-dom is registered for the packages/ui component tests, resolving "document is not defined" (6 tests). - apps/web/src/lib/api.ts: import the renamed `useDebounce` hook from @e2e/utils (was the stale `useThrottle`), fixing TS2305 and 2 tests. - packages/ui Button: apply `aria-label` for icon-only buttons with a dev-only warning when omitted (accessible-name test). - packages/ui DataTable: use a functional setState for sort direction to eliminate the stale-closure bug (descending-sort test). - packages/utils formatDate: emit an unpadded en-AU day via formatToParts (1/03/2024) while preserving padded month and 4-digit year. No test files modified; no dependencies added. Remaining tsc errors are pre-existing `bun:test` module-resolution noise in test files.
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
Fixes all 9 failing tests and the one real type error across the three-package monorepo (
packages/ui,packages/utils,apps/web).bun testnow reports 13 pass / 0 fail.Fixes
bunfig.tomlenvironmentkey with Bun'spreloadsohappy-domregisters for thepackages/uicomponent tests — resolvesReferenceError: document is not defined(6 tests).apps/web/src/lib/api.tsuseSearchDebounce/useThrottleimport was stale; the hook is now exported asuseDebouncefrom@e2e/utils. FixesTS2305and 2 tests.packages/ui/.../Button.tsxaria-labelfor icon-only buttons, with a dev-onlyconsole.warnwhen it's omitted (accessible-name test).packages/ui/.../DataTable.tsxsetStateupdater, removing the captured-render-value dependency (descending-sort test).packages/utils/.../date.tsformatDateemits an unpadded en-AU day viaformatToParts(1/03/2024), keeping the month zero-padded and the year 4-digit.Key decisions & assumptions
formatDate): en-AU'sIntlsilently coercesday: "numeric"to 2-digit, anddateStyle: "short"truncates the year to 2 digits (1/3/24). Chose theformatToPartsreassembly so only the single-digit day loses its leading zero — the narrowest change that satisfies the test without regressing the year width for downstream consumers (formatDateis re-exported throughapi.ts).aria-label: the test only asserts an accessible name exists, so an icon-only button with no label falls back to"Button"plus a dev warning. A stricter compile-time guard (discriminated-union props) would be a breaking API change and was intentionally left out of scope.tscoutput is limited to pre-existingCannot find module 'bun:test'errors in test files — unchanged from the base commit (confirmed viagit stash), and out of scope since fixing them would require editing test files or adding deps.Constraints honoured
Verification
bun test-> 13 pass / 0 failtsc --noEmit-> realTS2305error eliminated; only the pre-existingbun:testbaseline remains.