feat(gui-v2): statusSeverity SoT map + bidirectional §8.X consistency test

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-18 10:23:44 +02:00
parent dd45e89990
commit 20af2ebd32
2 changed files with 89 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
// apps/app/tests/unit/utils/statusSeverity.consistency.spec.ts
import { describe, expect, it } from 'vitest'
import { ShiftAssignmentStatus } from '@/types/shiftAssignment'
import { PersonStatus } from '@/types/person'
import { MatchStatus } from '@/types/identityMatch'
import { ArtistEngagementStatus, PaymentStatus } from '@/types/timetable'
import { STATUS_SEVERITY, statusSeverity } from '@/components-v2/shared/statusSeverity'
const ENUMS = { ShiftAssignmentStatus, ArtistEngagementStatus, PaymentStatus, PersonStatus, MatchStatus }
const ALL_VALUES = Object.values(ENUMS).flatMap(e => Object.values(e)) as string[]
describe('statusSeverity §8.X enforcement', () => {
it('completeness: every live enum value resolves to an explicit severity (no dev-fallback)', () => {
const missing = ALL_VALUES.filter(v => !(v in STATUS_SEVERITY))
expect(missing, `unmapped enum values: ${missing.join(', ')}`).toEqual([])
})
it('no phantoms: every map key exists in at least one live enum', () => {
const orphans = Object.keys(STATUS_SEVERITY).filter(k => !ALL_VALUES.includes(k))
expect(orphans, `orphan keys: ${orphans.join(', ')}`).toEqual([])
})
it('resolver returns the mapped severity and never throws on a known value', () => {
expect(statusSeverity('approved')).toBe('success')
expect(statusSeverity('no_show')).toBe('danger')
expect(statusSeverity('deposit_paid')).toBe('info')
})
})