fix: repair failing tests and type errors across monorepo - #132
Open
stooit wants to merge 1 commit into
Open
Conversation
- bunfig.toml: use valid [test] preload key so happy-dom registers the DOM for @testing-library/react (fixes "document is not defined") - tsconfig.json: add bun-types so `bun:test` imports type-check - apps/web/src/lib/api.ts: update import/usage of the renamed hook useThrottle -> useDebounce - packages/utils date.ts: formatDate now reassembles via Intl formatToParts to emit un-padded day/month with a 4-digit year (1/3/2024) - packages/ui Button.tsx: apply aria-label to the button, fall back to a default for icon-only buttons with no label, and dev-warn on the fallback
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 failing tests and type errors in the monorepo.
bun test→ 13/13 pass;npx tsc --noEmit→ exit 0. Four cross-package bugs plus two test-tooling config issues addressed. No test files modified; no dependencies added.Changes
bunfig.toml— the[test]block used an invalidenvironmentkey (a silent no-op), so happy-dom never registered a DOM and every@testing-library/reactrender()threwReferenceError: document is not defined. Switched to the validpreloadentry pointing at the existing setup file. Fixes 6 DOM errors across the Button/DataTable suites.tsconfig.json— addedbun-typestocompilerOptions.types(already present in devDependencies) so thebun:testimports in the four test files type-check. Fixes 4×TS2307.apps/web/src/lib/api.ts— theuseThrottlehook was renamed touseDebounceinpackages/utils; updated the import and its call sites. FixesTS2305and the dependent tests. (Old name is no longer exported — corrected the consumer rather than re-adding the stale export.)packages/utils/src/format/date.ts—formatDatezero-padded the day (01/03/2024), failing the "day 1 is not confused with month 1" assertion. Inen-AU, requesting a 4-digit numeric year forces ICU to zero-pad the day, soIntloptions alone can't produce1/3/2024. Reworked to useIntl.DateTimeFormat.formatToPartsand reassembleday/month/yearwith un-padded day/month while preserving the 4-digit year.formatDateTimeuntouched.packages/ui/src/components/Button/Button.tsx—aria-labelis now applied to the<button>. Icon-only buttons with no supplied label get a fallback so the accessible name is never null (WCAG 2.2 SC 4.1.2), and a dev-onlyconsole.warnfires in that fallback case. Non-icon-only buttons passaria-labelthrough unchanged (visible text remains the accessible name).Assumptions & decisions (made autonomously)
formatToParts) rather than switching todateStyle: 'short'which would silently shorten the year to 2 digits on a shared, re-exported public API — chosen to avoid a latent consumer-facing regression. Satisfies both/^1/andtoContain("3").console.warnalongside the fallback label so the missing-label a11y smell is loud at development time rather than shipped silently. The tests do not spy onconsole.warn, so this is informational only.Verification
bun test→ 13 pass, 0 failnpx tsc --noEmit→ clean (exit 0)formatDateTimeor other consumers.Follow-ups (non-blocking, out of scope)
"Button"fallback prevents a nameless control but conveys no purpose; icon-only buttons inapps/webtriggering the dev warn should get real labels. A discriminated-union type makingaria-labelrequired wheniconOnlyis true would be the honest fix but requires a test change.date.tsdoc comment could clarify that day-first ordering is applied explicitly foren-AUrather than derived from locale parts.