Improve test coverage and fix component testing infrastructure#116
Open
Amadou-dot wants to merge 1 commit into
Open
Improve test coverage and fix component testing infrastructure#116Amadou-dot wants to merge 1 commit into
Amadou-dot wants to merge 1 commit into
Conversation
…ration projects Testing infrastructure: - Fix framer-motion under jsdom: the real animation loop recursed until the test process ran out of memory, which is why the four root-level component test suites were excluded from jest.config.js. framer-motion is now mocked globally in jest.setup.jsdom.ts (motion.*/m.* render as plain tags), so any HeroUI component can be rendered in tests. The mock moved from __tests__/__mocks__/ to __tests__/setup/ because Jest's manual-mock resolution made it require itself. - Split the node Jest project into "unit" (pure functions, no DB, <1s) and "integration" (MongoDB Memory Server). New scripts: test:unit, test:integration, and test:fast (unit + jsdom, no mongod binary needed). - Add utils/ and types/ to coverage collection. Test fixes: - Un-exclude and repair the legacy component suites: error.test.tsx asserted window.location navigation but app/error.tsx uses router.push now; PrintBooking assertions drifted from the template markup; the two AddExperienceForm suites were consolidated into one that matches the current component. All moved into __tests__/components/. - Update experience validation test for the stronger schema (#103): includes/ available are now required non-empty, so the "applies defaults" case was split into defaults-that-remain and required-array assertions. - Remove __tests__/test-utils.tsx (trivial passthrough only used by a deleted suite). New tests (+~180 cases, 568 passing in unit+jsdom): - utils/utilityFunctions and utils/bookingUtils (previously 0%) - types/errors type guards - lib/logger dev/prod/test behavior - lib/api-utils requireApiAuth (testing bypass, 401/403, error path) - lib/clerk-users batch fetching: caching, 404-vs-transient error classification, concurrency limit - Mutation hooks for bookings, customers, and settings (mutationFn payloads, error propagation, cache invalidation, toasts) Unrelated-but-necessary: prettier-formatted 4 files that were committed unformatted on main (app/api/bookings/route.ts, app/api/cron/seed/route.ts, lib/validations/experience.ts, __tests__/integration/api/cron-seed.test.ts) so ci:check passes. Formatting only, no logic changes. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PbLP4qpeRszHTtgavQFB2L
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
jest.setup.jsdom.ts, un-blocking the four component suites that were silently excluded fromjest.config.js.unit(pure functions, no DB, <1s) andintegration(MongoDB Memory Server). Addedtest:unit,test:integration, andtest:fast(unit + jsdom, no mongod binary needed) scripts.utils/(was 0%),types/errors,lib/logger,requireApiAuth,lib/clerk-usersbatch fetching, and mutation hooks for bookings/customers/settings (was 21–26%, now ~89% for hooks overall).error,PrintBooking,AddExperienceFormx2) to__tests__/components/— they'd drifted from the current component code (e.g.error.tsxnow usesrouter.pushinstead ofwindow.location).experience.test.tsthat predated a schema change makingincludes/availablerequired non-empty arrays.Unrelated but necessary: Prettier-formatted 4 files that were previously committed unformatted (
app/api/bookings/route.ts,app/api/cron/seed/route.ts,lib/validations/experience.ts,__tests__/integration/api/cron-seed.test.ts) sopnpm ci:checkpasses cleanly. Formatting only, no logic changes.Test plan
pnpm test:fast(unit + jsdom) — 568/568 passingpnpm lint— cleanpnpm format:check— cleanpnpm check:types— no errorspnpm test:integrationlocally — could not run in this sandbox (network policy blocks the MongoDB Memory Server binary download); only touched integration files were formatting, so no behavioral changes expected, but worth a local confirmation runGenerated by Claude Code