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>
48 lines
1.4 KiB
TypeScript
48 lines
1.4 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import {
|
|
formatTickLabel,
|
|
generateTicks,
|
|
isoToMinutes,
|
|
minutesToIso,
|
|
minutesToPx,
|
|
pxToMinutes,
|
|
} from '@/lib/timetable/time-grid'
|
|
|
|
describe('time-grid coordinate conversions', () => {
|
|
const gridStart = '2026-07-10T14:00:00.000Z'
|
|
|
|
it('isoToMinutes returns 0 at the anchor', () => {
|
|
expect(isoToMinutes(gridStart, gridStart)).toBe(0)
|
|
})
|
|
|
|
it('isoToMinutes computes minute offsets', () => {
|
|
expect(isoToMinutes('2026-07-10T15:00:00.000Z', gridStart)).toBe(60)
|
|
expect(isoToMinutes('2026-07-10T14:30:00.000Z', gridStart)).toBe(30)
|
|
expect(isoToMinutes('2026-07-10T13:30:00.000Z', gridStart)).toBe(-30)
|
|
})
|
|
|
|
it('roundtrip isoToMinutes ↔ minutesToIso preserves the value', () => {
|
|
const back = minutesToIso(isoToMinutes('2026-07-10T18:45:00.000Z', gridStart), gridStart)
|
|
|
|
expect(back).toBe('2026-07-10T18:45:00.000Z')
|
|
})
|
|
|
|
it('minutesToPx and pxToMinutes are inverses', () => {
|
|
expect(minutesToPx(30, 2)).toBe(60)
|
|
expect(pxToMinutes(60, 2)).toBe(30)
|
|
expect(pxToMinutes(60, 0)).toBe(0)
|
|
})
|
|
|
|
it('formatTickLabel returns nl-NL HH:MM', () => {
|
|
const label = formatTickLabel(0, gridStart)
|
|
|
|
expect(label).toMatch(/^\d{2}:\d{2}$/)
|
|
})
|
|
|
|
it('generateTicks produces inclusive endpoints', () => {
|
|
const ticks = generateTicks(120, 30)
|
|
|
|
expect(ticks).toEqual([0, 30, 60, 90, 120])
|
|
})
|
|
})
|