test: minimal vitest harness for backend and frontend - #222
Closed
amal66 wants to merge 1 commit into
Closed
Conversation
Adds vitest (dev-dependency only) with a "test" script to both backend/ and frontend/, plus one unit test each exercising existing pure functions: backend lib/downloadTokens (sign/verify/build URL) and frontend app/lib/utils (cn, diceCoefficient, isFuzzyMatch). backend/tsconfig.json excludes test files so `npm run build` (tsc) output is unchanged. No runtime dependencies, no CI changes. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CEguyEgXa9JjCciXCcVemC
Collaborator
Author
|
Superseded by #227, which folds this into a single server-side security-hardening pack (with the vitest harness so its tests run standalone — 57 backend + 8 frontend tests green). |
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
Upstream currently has no test runner at all —
backend/package.jsoncarries onlydev/build/startscripts andfrontend/has none either. This adds the smallest possible vitest harness to both packages (a dev-dependency, atestscript, and one unit test each of existing pure functions) so that future changes can carry regression tests.Changes
backend/package.json: add"test": "vitest run"script andvitest@^4.1.9devDependencybackend/tsconfig.json: excludesrc/**/*.test.tsandsrc/**/__tests__/**so tests never reachdist/(tsc build output unchanged)backend/src/lib/__tests__/downloadTokens.test.ts: unit tests forsignDownload/verifyDownload/buildDownloadUrl(round-trip, tampered payload/signature, malformed tokens, wrong secret, URL embedding)frontend/package.json: add"test": "vitest run"script andvitest@^4.1.9devDependencyfrontend/src/app/lib/utils.test.ts: unit tests forcn,diceCoefficient,isFuzzyMatchbackend/package-lock.json,frontend/package-lock.json: regenerated vianpm install --save-dev vitest@4.1.9(never hand-edited)No vitest config files are needed — vitest picks up
*.test.tszero-config. No jsdom or testing-library; both suites test pure functions only.Why
A safety net for large sync bursts: with even a minimal harness in place, any future PR can land with tests instead of establishing infrastructure first. Dev-dependencies only — zero runtime cost, zero hosting cost, no CI workflow changes, no eslint changes.
Testing
cd backend && npm install && npm test— 1 file, 12 tests passed (vitest 4.1.9)cd backend && npm run build— tsc passes; verifieddist/contains no test filescd frontend && npm install && npm test— 1 file, 8 tests passed (vitest 4.1.9)next buildnot run (only test files and dev-dependencies changed)Provenance
All changes are mechanical ports of code in amal66/mike@origin/main (commit b3166dd); exceptions: none.
"test": "vitest run"script: verbatim fromapps/api/package.jsonandapps/web/package.jsonvitest@^4.1.9: range declared inapps/web/package.json; 4.1.9 is the exact version resolved in the fork's lockfile (apps/api declares^4.1.7, which also resolves to 4.1.9 there)excludeentries: verbatim fromapps/api/tsconfig.jsonfrontend/src/app/lib/utils.test.ts: byte-identical copy ofapps/web/src/app/lib/utils.test.tsbackend/src/lib/__tests__/downloadTokens.test.ts: strict subset ofapps/api/src/lib/__tests__/downloadTokens.test.ts(zero added lines); the fork-onlycore/downloadTokensimport and its "token expiry" suite are dropped because that module does not exist upstream🤖 Generated with Claude Code
https://claude.ai/code/session_01CEguyEgXa9JjCciXCcVemC