Add frontend Vitest suite#4
Merged
Merged
Conversation
- Vitest + Testing Library + jsdom; test / test:watch scripts. - Covers session helpers and startOAuth (asserts the API key is sent as a header, never in the URL), the ProtectedRoute guard, the root ErrorBoundary, and Login password validation. - setup.ts installs an in-memory localStorage — jsdom's isn't reliable under Vitest 4 / Node Web Storage. - 14 tests passing. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Owner
Author
|
@claude review please |
|
Claude encountered an error after 15s —— View job I'll analyze this and get back to you. |
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
Adds the frontend's first automated test layer. The backend has 100 tests; the frontend had none — this is a focused smoke/behavior suite over the paths the production-hardening work touched.
What's covered (14 tests)
api.test.ts— session helpers (isLoggedIn,getStoredUser,logout),signup/login, andstartOAuth— the last explicitly asserts the API key is sent as anX-Api-Keyheader and never appears in the URL (guards the OAuth-key-leak fix from PR Harden for production: auth, error handling, UI cleanup #2).ProtectedRoute.test.tsx— unauthenticated users are redirected to/login; authenticated users get through.ErrorBoundary.test.tsx— a thrown child renders the recoverable fallback instead of a blank app.Login.test.tsx— password length validation and submit-button gating.Setup
test/test:watchscripts inpackage.json;testblock added tovite.config.ts.src/test/setup.tsregisters jest-dom matchers, auto-cleanup, and an in-memorylocalStorage(jsdom's isn't reliable under Vitest 4 / Node's experimental Web Storage)..gitignore: ignore.playwright-mcp/artifacts.Verification
bun run test— 14/14 pass.bun run lintandbun run build(tsc -b) clean./auth redirect, route guards, password signup against the live backend + migrated Supabase, and the Directory/Status pages rendering real data.Notes
Test files are co-located with source (
*.test.tsxnext to components) per standard React/Vitest convention.🤖 Generated with Claude Code