Test: add unit test suite for frontend components#80
Merged
snowrugar-beep merged 1 commit intoJun 22, 2026
Conversation
Contributor
Author
|
@snowrugar-beep Kindly review the PR. |
5 tasks
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.
Closes #19
Feat: Vitest Unit Test Suite for Frontend Workspace (#19)
Description
Adds a full Vitest unit test suite to the Frontend workspace — covering components, pages, and utilities — with coverage enforcement and CI integration.
Changes
Setup & Configuration
vitest,@testing-library/react,@testing-library/jest-dom,jsdom,@vitejs/plugin-react)vitest.config.tswith jsdom environment,@/alias resolution, PostCSS bypass for leaflet's CSS import, and 70% coverage thresholds across all four metrics (lines, statements, functions, branches)src/tests/setup.ts) that registers@testing-library/jest-dommatchersnpm run testandnpm run test:watchscripts toFrontend/package.jsonUnit tests: npm run testinto the frontend CI job between Lint and BuildCLAUDE.mdandplan.mdto.gitignoreto prevent local-only files from being accidentally committedTests Written — 44 tests across 8 files
cn()utilityBadgeHeaderFeaturesAddGistModalMapChecklist
Security
No security-sensitive changes. Test coverage improvements reduce the risk of undetected regressions in UI rendering, but no auth, payment, or data-exposure logic was touched.
Notes for Reviewers
vitest.config.ts— PostCSS override:css: { postcss: { plugins: [] } }is set to prevent Vite from loadingpostcss.config.mjsduring tests. That file uses@tailwindcss/postcss, which is a Next.js-only plugin and invalid in the Vite/Vitest context. This override only affects the test runner — the Next.js build is unaffected.CTA.tsxhas no tests:CTA.tsxis not imported by any page or component in the codebase. Testing a dead component would inflate coverage with no behavioral value. Tests should be added when it is wired into a page.AddGistModalsubmit uses fake timers: The submit handler has a hardcodedsetTimeout(..., 2000). Tests usevi.useFakeTimers()+vi.advanceTimersByTime(2000)to avoid slow tests.To run tests locally: