Skip to content

feat(ci): vitest tests, GitHub Actions workflow, typecheck gate prep#20

Open
lucavandee wants to merge 3 commits into
mainfrom
feat/ci-testing
Open

feat(ci): vitest tests, GitHub Actions workflow, typecheck gate prep#20
lucavandee wants to merge 3 commits into
mainfrom
feat/ci-testing

Conversation

@lucavandee

Copy link
Copy Markdown
Owner

Summary

  • Restore the pieces needed to run typecheck and tests outside Bolt
    (scripts/bolt-install.mjs was stripping @types/react,
    @types/react-dom, and vitest in every environment) and add
    those packages back to devDependencies.
  • Add a vitest suite for the recommendation engine: 27 unit tests
    across productFilter, calculateMatchScore, and outfitComposer.
    All tests pass.
  • Add a GitHub Actions workflow that runs npm ci, npm run typecheck, npm test, and npm run build on push-to-main and PRs.
  • Wire a vitest run step into the existing husky pre-commit hook so
    broken tests block commits locally.

What the tests cover

The task brief referenced src/engine/v2/ modules (profileBuilder,
scorer, composer), which don't exist in this branch — the engine
lives directly in src/engine/. The tests target the actual modules:

  • productFilter: isAdultClothingProduct rejects kids' items,
    underwear/socks, and priced-below-threshold rows; classifyCategory
    maps names to top/bottom/footwear/other and falls back to the DB
    category.
  • calculateMatchScore: preference-driven score sums correctly and
    is not hardcoded (flipping preferences changes the score);
    calculateMatchPercentage clamps to 0-100 and guards division by zero.
  • outfitComposer: every outfit has exactly one top, bottom, and
    footwear (never two tops); empty catalogs and missing categories
    return []; budget preferences cap per-item price; gender filter
    respects male/unisex; different preferences produce different
    outfits; match scores land in the documented 55-98 range.

⚠️ Important notes

Typecheck is informational (for now)

The codebase carries ~660 pre-existing TypeScript errors across ~160
files
— unrelated to this PR's changes. They are legitimate bugs
(supabase is possibly null, property mismatches, missing modules)
but fall outside the scope of setting up CI. The workflow runs
npm run typecheck with continue-on-error: true so PRs aren't
blocked until that backlog is worked down. Once clean, drop
continue-on-error to make typecheck a hard gate.

Workflow file location

.github/workflows/ci.yml could not be pushed: the OAuth token used
to create this PR does not have the workflow scope. The workflow is
checked in at .github/workflows-proposed/ci.yml with a README
explaining how to activate it — a one-line git mv via the GitHub
web UI (or a token with the workflow scope) is enough.

Pre-commit hook

Husky was already configured. The existing pre-commit is extended
to run vitest run --reporter=dot before lint-staged. Full
tsc --noEmit was intentionally not added to pre-commit — with
660+ pre-existing errors it would block every commit until they are
fixed. Vitest is the pragmatic gate until then.

Test plan

  • npm install succeeds outside Bolt with @types/react,
    @types/react-dom, and vitest present in node_modules/
  • npm test → 27/27 passing
  • npm run build → succeeds
  • npm run typecheck → runs (still reports pre-existing errors)
  • After merge: move .github/workflows-proposed/ci.yml
    .github/workflows/ci.yml and verify the first CI run

🤖 Generated with Claude Code

Luc and others added 3 commits April 18, 2026 08:48
bolt-install.mjs stripped @types/* and vitest in every environment, which
made tsc --noEmit and the test script unusable locally and in CI.

- Only strip in Bolt (BOLT=1, STACKBLITZ=1, or bolt user-agent); keep
  devDeps intact for local and CI runs
- Allowlist @types/react, @types/react-dom, @types/node (tsconfig types
  field depends on them)
- Add vitest, @types/react, @types/react-dom, @types/node to devDeps
- Split the test script: npm test runs once (CI-friendly), npm run
  test:watch runs the interactive watcher

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Covers the three engine modules most likely to regress under refactors:

- productFilter: isAdultClothingProduct rejects kids/underwear/socks and
  low-price items; classifyCategory handles tops/bottoms/footwear
- calculateMatchScore: verifies preference-driven scoring is not
  hardcoded and calculateMatchPercentage clamps to 0-100
- outfitComposer: enforces top+bottom+footwear per outfit (never two
  tops), respects budget ceilings, applies gender filtering, and
  produces different outfits when preferences change

27 tests total, all passing. vitest.config.ts wires the @/* alias so
tests can import engine code the same way the app does.

The strict tests/ ignore rule in .gitignore would swallow these files,
so src/__tests__/ is explicitly un-ignored.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- .github/workflows/ci.yml: npm ci, typecheck, vitest run, vite build on
  push to main and on PRs. Typecheck is informational for now because
  the codebase has ~660 pre-existing type errors; tests and build are
  hard gates. Once typecheck errors are resolved, drop
  continue-on-error to make it blocking.
- .husky/pre-commit: run vitest (dot reporter) before lint-staged so
  broken tests block commits locally. Guards with a node_modules check
  so Bolt environments without vitest installed keep working.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@netlify

netlify Bot commented Apr 18, 2026

Copy link
Copy Markdown

Deploy Preview for fitfiai ready!

Name Link
🔨 Latest commit 826c1c0
🔍 Latest deploy log https://app.netlify.com/projects/fitfiai/deploys/69e329a3d3d1f00008a9e60d
😎 Deploy Preview https://deploy-preview-20--fitfiai.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@supabase

supabase Bot commented Apr 18, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project wojexzgjyhijuxzperhq because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

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