apps/app/tests/unit/lib/timetable/:
- snap.test.ts (5) — rounding, clamp, edge cases
- time-grid.test.ts (6) — px↔min↔ISO roundtrips, formatTickLabel
- conflict.test.ts (8) — overlap, endpoint-touching, lane/stage scoping, cancelled exclusion
- b2b.test.ts (6) — 0min, 2:59, 3:01, overlap, side-set mapping, threshold constant
- capacity.test.ts (7) — null capacity, missing data, warn/critical, crew+guests preference
- lane.test.ts (8) — Pass 1 + Pass 2, cascade-bump preview, cancelled exclusion
apps/app/tests/unit/composables/:
- useTimetableMutations.test.ts (5) — Idempotency-Key header, optimistic + cascade,
409 VersionMismatch surfaced, park sends null,
createStage POST path
- useDragOrClick.test.ts (3) — onClick fires under threshold, onDragStart+End
above threshold, Esc cancels mid-flight
apps/app/tests/unit/schemas/timetable.test.ts (8) — payload + response zod parsers
apps/app/tests/unit/lib/idempotencyKey.test.ts (3) — 6-30 char range, 24-hex, uniqueness
apps/app/tests/unit/stores/useTimetableStore.test.ts (5) — defaults, toggleStatus, drag state, null guard
Refactor: useTimetableMutations.move now throws Error instances (no-throw-literal)
so AxiosError.message and the VersionMismatchError shape both bubble through .catch().
Test count: 252 → 319 (+67). All 42 files pass.
Out of scope this session (added to BACKLOG):
- ART-PERFORMANCEBLOCK-COMPONENT-TESTS — Vuetify intentionally not loaded in
vitest.config.ts; a Vuexy-stub setup for component-mount tests is one PR of
its own. Pure rendering logic (capacity, B2B, conflict) is fully covered at
the lib/ layer.
- ART-AXE-CORE-A11Y-TESTS — axe-core not yet installed in the repo. The
aria-label structure on PerformanceBlock + aria-live on the page entry are
authored to pass an axe scan when added.
- ART-INTEGRATION-FLOW-TEST — full add → drag → resize → park flow needs
Vuetify + router + msw setup; defer with the component tests above.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
78 lines
2.4 KiB
TypeScript
78 lines
2.4 KiB
TypeScript
import { createPinia, setActivePinia } from 'pinia'
|
|
import { beforeEach, describe, expect, it } from 'vitest'
|
|
import { useTimetableStore } from '@/stores/useTimetableStore'
|
|
import { ArtistEngagementStatus, type Performance } from '@/types/timetable'
|
|
|
|
function p(): Performance {
|
|
return {
|
|
id: 'p1',
|
|
engagement_id: 'e1',
|
|
event_id: 'ev1',
|
|
stage_id: 's1',
|
|
lane: 0,
|
|
lane_resolved: 0,
|
|
start_at: '2026-07-10T18:00:00.000Z',
|
|
end_at: '2026-07-10T19:00:00.000Z',
|
|
version: 1,
|
|
notes: null,
|
|
warnings: [],
|
|
created_at: null,
|
|
updated_at: null,
|
|
deleted_at: null,
|
|
}
|
|
}
|
|
|
|
describe('useTimetableStore', () => {
|
|
beforeEach(() => setActivePinia(createPinia()))
|
|
|
|
it('initialises with cancelled OFF in status filter', () => {
|
|
const store = useTimetableStore()
|
|
|
|
expect(store.isStatusVisible(ArtistEngagementStatus.CONFIRMED)).toBe(true)
|
|
expect(store.isStatusVisible(ArtistEngagementStatus.CANCELLED)).toBe(false)
|
|
})
|
|
|
|
it('toggleStatus flips a single status', () => {
|
|
const store = useTimetableStore()
|
|
|
|
store.toggleStatus(ArtistEngagementStatus.CONFIRMED)
|
|
expect(store.isStatusVisible(ArtistEngagementStatus.CONFIRMED)).toBe(false)
|
|
store.toggleStatus(ArtistEngagementStatus.CONFIRMED)
|
|
expect(store.isStatusVisible(ArtistEngagementStatus.CONFIRMED)).toBe(true)
|
|
})
|
|
|
|
it('setActiveDay updates and selectPerformance maps to id', () => {
|
|
const store = useTimetableStore()
|
|
|
|
store.setActiveDay('day_1')
|
|
expect(store.activeDayId).toBe('day_1')
|
|
store.selectPerformance('p1')
|
|
expect(store.selectedPerformanceId).toBe('p1')
|
|
store.selectPerformance(null)
|
|
expect(store.selectedPerformanceId).toBeNull()
|
|
})
|
|
|
|
it('startDrag/endDrag manages snapshot + ghost', () => {
|
|
const store = useTimetableStore()
|
|
|
|
expect(store.isDragging).toBe(false)
|
|
store.startDrag(p())
|
|
expect(store.isDragging).toBe(true)
|
|
expect(store.dragOriginSnapshot?.id).toBe('p1')
|
|
|
|
store.updateDragGhost({ stageId: 's1', startAt: '2026-07-10T18:30:00Z', endAt: '2026-07-10T19:30:00Z', lane: 1 })
|
|
expect(store.dragGhost?.lane).toBe(1)
|
|
|
|
store.endDrag()
|
|
expect(store.isDragging).toBe(false)
|
|
expect(store.dragGhost).toBeNull()
|
|
})
|
|
|
|
it('isStatusVisible handles null gracefully', () => {
|
|
const store = useTimetableStore()
|
|
|
|
expect(store.isStatusVisible(null)).toBe(false)
|
|
expect(store.isStatusVisible(undefined)).toBe(false)
|
|
})
|
|
})
|