Problem Statement
The Frontend has zero tests across all components, pages, hooks, and utilities. There are no test files in Frontend/src/. Critical UI components (Map, Header, CTA, AddGistModal, Badge) and pages (Landing, Map) have no automated verification.
Evidence
- No
*.spec.ts or *.test.ts files exist anywhere in Frontend/
- Frontend/package.json has no test framework dependency (no Vitest, Jest, or Testing Library)
- Frontend CI only runs lint and TypeScript checks — no test step
Impact
UI regressions undetectable without manual testing. Refactoring is high-risk. No confidence in component behavior under different states.
Proposed Solution
- Install Vitest, @testing-library/react, @testing-library/jest-dom, jsdom
- Create vitest.config.ts matching Next.js configuration
- Add test: npm run test script to package.json
- Write tests for:
- Header component (renders logo, nav links, mobile menu)
- CTA component (animations, link href)
- AddGistModal (open/close, input, submit, char limit)
- Badge component (all variants)
- Map component (renders markers, geolocation)
- Landing and Map pages (render without errors)
- cn() utility function
Technical Requirements
- Must use Vitest (fast, native TypeScript support)
- Must use @testing-library/react (encourages testing behavior, not implementation)
- Must mock leaflet (canvas-based, doesn't work in jsdom)
- Must mock framer-motion AnimatePresence in tests
- Coverage threshold: 70% minimum
Acceptance Criteria
- Header test: renders logo, map link, has correct href
- CTA test: renders heading, body, link with correct URL
- AddGistModal test: opens on click, closes on backdrop, submits content, enforces 280 char limit
- Badge test: renders all 4 variants with correct styling
- Map test: renders without error with mock geolocation
- cn() test: merges classes correctly, handles falsy values
- npm run test passes with >70% coverage
- CI includes test step
File Inventory
- Frontend/src/components/ (all components need test files)
- Frontend/package.json
- Frontend/vitest.config.ts (new)
- Frontend/src/tests/ or co-located *.spec.tsx files
Dependencies
None.
Testing Strategy
Component unit tests using Vitest + Testing Library. Map component needs window.fetch and geolocation mocking.
Security Considerations
Better test coverage reduces risk of security regressions in UI (e.g., XSS via rendered content).
Definition of Done
Problem Statement
The Frontend has zero tests across all components, pages, hooks, and utilities. There are no test files in Frontend/src/. Critical UI components (Map, Header, CTA, AddGistModal, Badge) and pages (Landing, Map) have no automated verification.
Evidence
*.spec.tsor*.test.tsfiles exist anywhere in Frontend/Impact
UI regressions undetectable without manual testing. Refactoring is high-risk. No confidence in component behavior under different states.
Proposed Solution
Technical Requirements
Acceptance Criteria
File Inventory
Dependencies
None.
Testing Strategy
Component unit tests using Vitest + Testing Library. Map component needs window.fetch and geolocation mocking.
Security Considerations
Better test coverage reduces risk of security regressions in UI (e.g., XSS via rendered content).
Definition of Done