test: set up Vitest with 61 frontend tests #46

Merged
chihlasm merged 1 commits from test/frontend-vitest-setup into main 2026-02-08 23:21:00 +00:00
chihlasm commented 2026-02-08 23:18:58 +00:00 (Migrated from github.com)

Summary

  • Set up Vitest + @testing-library/react + jsdom for frontend testing
  • 61 tests across 4 test files, all passing in ~3s
  • CI workflow updated to run npm test before build

Test files

  • src/lib/utils.test.ts — 6 tests for cn() class merging utility
  • src/hooks/usePermissions.test.ts — 27 tests covering all roles (viewer, engineer, owner, super_admin) and resource-specific checks
  • src/hooks/useTreeValidation.test.ts — 22 tests for name validation, structure validation, and warnings
  • src/store/userPreferencesStore.test.ts — 6 tests for store defaults and setters

Config changes

  • vite.config.ts — added Vitest test configuration
  • tsconfig.app.json — excluded test files from production build
  • package.json — added test and test:watch scripts
  • .github/workflows/ci.yml — added test step before build

Test plan

  • All 61 tests pass (npx vitest run)
  • Production build succeeds (npm run build)
  • No regressions

🤖 Generated with Claude Code

## Summary - Set up **Vitest** + **@testing-library/react** + **jsdom** for frontend testing - **61 tests** across 4 test files, all passing in ~3s - CI workflow updated to run `npm test` before build ## Test files - `src/lib/utils.test.ts` — 6 tests for `cn()` class merging utility - `src/hooks/usePermissions.test.ts` — 27 tests covering all roles (viewer, engineer, owner, super_admin) and resource-specific checks - `src/hooks/useTreeValidation.test.ts` — 22 tests for name validation, structure validation, and warnings - `src/store/userPreferencesStore.test.ts` — 6 tests for store defaults and setters ## Config changes - `vite.config.ts` — added Vitest test configuration - `tsconfig.app.json` — excluded test files from production build - `package.json` — added `test` and `test:watch` scripts - `.github/workflows/ci.yml` — added test step before build ## Test plan - [x] All 61 tests pass (`npx vitest run`) - [x] Production build succeeds (`npm run build`) - [x] No regressions 🤖 Generated with [Claude Code](https://claude.com/claude-code)
railway-app[bot] commented 2026-02-08 23:19:06 +00:00 (Migrated from github.com)

🚅 Deployed to the patherly-pr-46 environment in selfless-grace

Service Status Web Updated (UTC)
patherly Success (View Logs) Feb 8, 2026 at 11:20 pm
hopeful-liberation Success (View Logs) Feb 8, 2026 at 11:19 pm
<!-- railway-bot-comment-version=2 --> <!-- railway-project-id="22b9b58c-271b-42e5-a10e-6fdec8d00134" railway-project-name="selfless-grace" --> 🚅 Deployed to the [patherly-pr-46](https://railway.com/project/22b9b58c-271b-42e5-a10e-6fdec8d00134?environmentId=2ab02857-2b63-40c1-96dd-7f72d9ede2cd) environment in **[selfless-grace](https://railway.com/project/22b9b58c-271b-42e5-a10e-6fdec8d00134)** | **Service** | **Status** | **Web** | **Updated** (UTC) | | :--- | :--- | :--- | :--- | | patherly | ✅ Success ([View Logs](https://railway.com/project/22b9b58c-271b-42e5-a10e-6fdec8d00134/service/95f556ff-5264-4116-a0c2-618a2fc53ba4?id=2c1057bd-78cb-4c91-a420-8634e2739475&environmentId=2ab02857-2b63-40c1-96dd-7f72d9ede2cd)) | | Feb 8, 2026 at 11:20 pm | | hopeful-liberation | ✅ Success ([View Logs](https://railway.com/project/22b9b58c-271b-42e5-a10e-6fdec8d00134/service/e1db2ee3-d241-4f45-abe4-c9c5fdf483d5?id=3668ab19-d8b7-4145-a9f1-eca22c06f72b&environmentId=2ab02857-2b63-40c1-96dd-7f72d9ede2cd)) | | Feb 8, 2026 at 11:19 pm |
Sign in to join this conversation.