Skip to content

chore: add vitest - #91

Open
ayhid wants to merge 2 commits into
strapi:developfrom
ayhid:chore/add-vitest
Open

ayhid wants to merge 2 commits into
strapi:developfrom
ayhid:chore/add-vitest

Conversation

@ayhid

@ayhid ayhid commented Sep 25, 2026

Copy link
Copy Markdown

Part 2 of 7 — profile links. Depends on #90 (the cms tests cover code added there). Branched from feature/profile-links-schema, so until #90 merges this diff also shows its commit — review only chore: add vitest (95007b7).

Summary

Adds a unit-test runner to the monorepo. Today pnpm test runs turbo test, but there is no test task and no framework, so nothing runs.

Why

The profile links work adds per-type validation, URL normalization and a data migration — pure logic that's cheap to unit test and easy to get subtly wrong.

Changes

  • vitest (dev dependency) in apps/web and apps/cms, each with "test": "vitest run" and a vitest.config.ts scoped to src/**/*.test.ts (so compiled copies in dist/ are never picked up).
  • test task in turbo.json.
  • Pinned to vitest 3.2: the workspace resolves vite 5 (Strapi's admin build), and vitest 4+ requires a newer vite. Adding a newer vite to apps/cms could interfere with strapi build, so vitest 3 was the safer choice.
  • Tests:
    • apps/cms/.../utils/profile-links.test.ts — 16 cases for pickProfileLinks / validateProfileLinks (every type, pasted URLs in handle types, invalid addresses, unknown type, empty value, >10 links, non-array, id stripping).
    • apps/web/.../profile-view/validation.test.ts — existing profile field validation (empty values, length limits, website/github/email formats).

No component tests (no Testing Library / jsdom) and no CI step yet — left for a separate decision.

Test plan

  • pnpm test → web 4 passed, cms 16 passed
  • pnpm --filter web --filter cms check-types
  • Biome clean on new files
  • pnpm --filter cms build
  • apps/web compiles; next build then needs a running CMS for generateStaticParams, which is unchanged by this PR

Follow-ups

  • Optionally run pnpm test in .github/workflows/tests.yml.

Add a repeatable `profile.link` component ({ type, value }, max 10) to
`api::profile.profile`, accept and validate `links` in the user and
organization profile endpoints, and populate it in their responses.

Social types store only the handle; `website`/`other` store a full URL.
The legacy `website`/`github` fields are kept until migrated.

See docs/adr/0003-profile-links.md.
Add vitest to apps/web and apps/cms with a `test` script each and a
`test` task in turbo, so `pnpm test` runs something. Pinned to vitest 3,
which supports the vite 5 the workspace resolves for the Strapi admin.

Cover the new profile links validation (cms) and the existing profile
field validation (web).
@vercel

vercel Bot commented Sep 25, 2026

Copy link
Copy Markdown

@ayhid is attempting to deploy a commit to the Strapi-Website Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
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