Skip to content

Test: add unit test suite for frontend components#80

Merged
snowrugar-beep merged 1 commit into
VertexChainLabs:mainfrom
Lansa-18:test/frontend-unit-tests
Jun 22, 2026
Merged

Test: add unit test suite for frontend components#80
snowrugar-beep merged 1 commit into
VertexChainLabs:mainfrom
Lansa-18:test/frontend-unit-tests

Conversation

@Lansa-18

Copy link
Copy Markdown
Contributor

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

  • Installed and configured Vitest as the Frontend test framework (vitest, @testing-library/react, @testing-library/jest-dom, jsdom, @vitejs/plugin-react)
  • Created vitest.config.ts with jsdom environment, @/ alias resolution, PostCSS bypass for leaflet's CSS import, and 70% coverage thresholds across all four metrics (lines, statements, functions, branches)
  • Added a global test setup file (src/tests/setup.ts) that registers @testing-library/jest-dom matchers
  • Added npm run test and npm run test:watch scripts to Frontend/package.json
  • Wired Unit tests: npm run test into the frontend CI job between Lint and Build
  • Added CLAUDE.md and plan.md to .gitignore to prevent local-only files from being accidentally committed

Tests Written — 44 tests across 8 files

File Coverage
cn() utility Core utility function
Badge All 4 variants
Header Render and structure
Features Mobile + desktop viewport branches
AddGistModal Open/close, submit with fake timers, char limit, Escape key, loading state
Map Geolocation success + error paths, default markers, modal trigger
Landing page Smoke test
Map page Smoke test

Checklist

  • Tests added or updated
  • Documentation updated (README, docs, comments)
  • Linting passes
  • Type checking passes
  • Relevant issue linked
  • Changelog updated

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 loading postcss.config.mjs during 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.tsx has no tests: CTA.tsx is 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.

  • AddGistModal submit uses fake timers: The submit handler has a hardcoded setTimeout(..., 2000). Tests use vi.useFakeTimers() + vi.advanceTimersByTime(2000) to avoid slow tests.

  • To run tests locally:

  cd Frontend
  npm run test          # single run with coverage report
  npm run test:watch    # watch mode

@Lansa-18

Copy link
Copy Markdown
Contributor Author

@snowrugar-beep Kindly review the PR.

@snowrugar-beep snowrugar-beep left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@snowrugar-beep snowrugar-beep merged commit fada633 into VertexChainLabs:main Jun 22, 2026
5 checks passed
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.

test: add unit test suite for Frontend components

2 participants