chore(workspace): move the app to apps/app under a pnpm workspace (step 2)
144 files moved with git mv (pure renames). Root package.json delegates dev/typecheck/test:run/lint/build to the packages; Node 24 LTS and pnpm 10.13.1 pinned (.nvmrc, .node-version, engines, packageManager, root devDependency, engine-strict). Dockerfile builds @faunosteo/app on node:24-alpine and copies apps/app/dist; nginx and runtime config unchanged. CI workflow for Gitea Actions. packages/ reserved (README only). Docs synced: WORKSPACE.md, CLAUDE.md, README, DEPLOY, CHANGELOG, plan. 271/271 tests, typecheck, lint, build green from the root.
This commit is contained in:
1 parent
c8d48ab4cc
commit
8673475293
164 files changed
+348
-128
No files matched your search
@@ -0,0 +1,120 @@
|
||||
import { describe, it, expect, beforeEach } from 'vitest'
|
||||
import { useReportStore } from '@/state/reportStore'
|
||||
|
||||
const draft = {
|
||||
date: '2026-05-18',
|
||||
practitioner: { name: 'Dr. Dupont' },
|
||||
animal: { speciesId: 'equine', name: 'Mistral' },
|
||||
owner: { name: 'Jean Martin' },
|
||||
observations: [],
|
||||
conclusion: '',
|
||||
recommendations: '',
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
useReportStore.getState().reset()
|
||||
})
|
||||
|
||||
describe('reportStore.initReport', () => {
|
||||
it('sets a report with version=2, id, and createdAt', () => {
|
||||
useReportStore.getState().initReport(draft)
|
||||
const r = useReportStore.getState().report!
|
||||
expect(r.version).toBe(2)
|
||||
expect(r.id.length).toBeGreaterThan(0)
|
||||
expect(r.createdAt).toMatch(/^\d{4}-\d{2}-\d{2}T/)
|
||||
expect(r.practitioner.name).toBe('Dr. Dupont')
|
||||
})
|
||||
|
||||
it('seeds a single empty observation when the draft has none', () => {
|
||||
useReportStore.getState().initReport(draft)
|
||||
const r = useReportStore.getState().report!
|
||||
expect(r.observations.length).toBe(1)
|
||||
expect(r.observations[0].zones).toEqual([])
|
||||
expect(r.observations[0].comment).toBe('')
|
||||
})
|
||||
|
||||
it('resets activeObservationIndex to 0', () => {
|
||||
useReportStore.getState().initReport(draft)
|
||||
expect(useReportStore.getState().activeObservationIndex).toBe(0)
|
||||
})
|
||||
})
|
||||
|
||||
describe('reportStore.reset', () => {
|
||||
it('clears the report', () => {
|
||||
useReportStore.getState().initReport(draft)
|
||||
useReportStore.getState().reset()
|
||||
expect(useReportStore.getState().report).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
describe('reportStore.addObservation', () => {
|
||||
it('appends an empty observation and sets it active', () => {
|
||||
useReportStore.getState().initReport(draft)
|
||||
useReportStore.getState().addObservation()
|
||||
const s = useReportStore.getState()
|
||||
expect(s.report!.observations.length).toBe(2)
|
||||
expect(s.activeObservationIndex).toBe(1)
|
||||
})
|
||||
})
|
||||
|
||||
describe('reportStore.updateObservation', () => {
|
||||
it('replaces the observation at the given index', () => {
|
||||
useReportStore.getState().initReport(draft)
|
||||
useReportStore.getState().addObservation()
|
||||
const next = {
|
||||
...useReportStore.getState().report!.observations[0],
|
||||
comment: 'patate',
|
||||
}
|
||||
useReportStore.getState().updateObservation(0, next)
|
||||
expect(useReportStore.getState().report!.observations[0].comment).toBe('patate')
|
||||
})
|
||||
})
|
||||
|
||||
describe('reportStore.removeObservation', () => {
|
||||
it('drops the observation at the given index', () => {
|
||||
const store = useReportStore.getState()
|
||||
store.initReport(draft) // seeds 1
|
||||
store.addObservation()
|
||||
store.addObservation()
|
||||
store.removeObservation(0)
|
||||
expect(useReportStore.getState().report!.observations.length).toBe(2)
|
||||
})
|
||||
|
||||
it('clamps activeObservationIndex within bounds', () => {
|
||||
const store = useReportStore.getState()
|
||||
store.initReport(draft) // seeds 1
|
||||
store.addObservation()
|
||||
store.addObservation() // total 3
|
||||
store.setActiveObservation(2)
|
||||
store.removeObservation(2)
|
||||
expect(useReportStore.getState().activeObservationIndex).toBe(1)
|
||||
})
|
||||
})
|
||||
|
||||
describe('reportStore.move up/down', () => {
|
||||
it('moveObservationUp swaps with previous', () => {
|
||||
const s = useReportStore.getState()
|
||||
s.initReport(draft)
|
||||
s.addObservation()
|
||||
s.addObservation()
|
||||
const idA = useReportStore.getState().report!.observations[0].id
|
||||
const idB = useReportStore.getState().report!.observations[1].id
|
||||
s.moveObservationUp(1)
|
||||
const after = useReportStore.getState().report!.observations
|
||||
expect(after[0].id).toBe(idB)
|
||||
expect(after[1].id).toBe(idA)
|
||||
})
|
||||
|
||||
it('moveObservationDown swaps with next', () => {
|
||||
const s = useReportStore.getState()
|
||||
s.initReport(draft)
|
||||
s.addObservation()
|
||||
s.addObservation()
|
||||
const idA = useReportStore.getState().report!.observations[0].id
|
||||
const idB = useReportStore.getState().report!.observations[1].id
|
||||
s.moveObservationDown(0)
|
||||
const after = useReportStore.getState().report!.observations
|
||||
expect(after[0].id).toBe(idB)
|
||||
expect(after[1].id).toBe(idA)
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user