Problem
The frontend has no unit test framework configured. Only Playwright E2E tests exist (e2e/search.spec.ts). Issue #12 (Cluster Drill-Down and Annotation) specified frontend component tests as a requirement, but the infrastructure to run them does not exist.
Proposed Solution
1. Set up Vitest + React Testing Library + jsdom
Install and configure:
vitest as the test runner
@testing-library/react + @testing-library/jest-dom for component testing
jsdom as the test environment
@testing-library/user-event for user interaction simulation
Add vitest.config.ts and a test:unit script to package.json.
2. Write component tests for issue #12 features
ClusterDetailDrawer.test.tsx
- Renders drawer with cluster items (metadata, thumbnails)
- Pagination controls work correctly
- Inline cluster name editing
- Notes textarea updates
- Tags input
- Calls correct API functions on interaction
SubClusterView.test.tsx
- Renders mini scatter plot with sub-cluster data
- Sub-cluster count selector triggers re-computation
- Handles loading and error states
ClusterLegend.test.tsx
- Click on cluster name opens detail drawer (not just toggle visibility)
- Visibility toggle checkbox still works independently
- Shows annotation indicator when cluster has notes
plotStore.test.ts
openClusterDetail() action fetches and stores cluster items
subCluster() action triggers sub-cluster computation
updateAnnotation() action persists annotation changes
selectedCluster and clusterItems derived state
3. Add to CI
Add a test:unit job to .github/workflows/ci.yml that runs npm run test:unit in the frontend directory.
Acceptance Criteria
Related
Problem
The frontend has no unit test framework configured. Only Playwright E2E tests exist (
e2e/search.spec.ts). Issue #12 (Cluster Drill-Down and Annotation) specified frontend component tests as a requirement, but the infrastructure to run them does not exist.Proposed Solution
1. Set up Vitest + React Testing Library + jsdom
Install and configure:
vitestas the test runner@testing-library/react+@testing-library/jest-domfor component testingjsdomas the test environment@testing-library/user-eventfor user interaction simulationAdd
vitest.config.tsand atest:unitscript topackage.json.2. Write component tests for issue #12 features
ClusterDetailDrawer.test.tsxSubClusterView.test.tsxClusterLegend.test.tsxplotStore.test.tsopenClusterDetail()action fetches and stores cluster itemssubCluster()action triggers sub-cluster computationupdateAnnotation()action persists annotation changesselectedClusterandclusterItemsderived state3. Add to CI
Add a
test:unitjob to.github/workflows/ci.ymlthat runsnpm run test:unitin the frontend directory.Acceptance Criteria
npm run test:unitscript added to package.jsonRelated