investigationStates.test.ts
1 // Copyright (c) 2026 VPL Solutions. All rights reserved. 2 // Licensed under the MIT License. See LICENSE for details. 3 4 import { describe, it, expect } from 'vitest'; 5 import { 6 STATUS_META, 7 TIMELINE_STATES, 8 APPROVAL_GATE_INDEX, 9 AGENT_ROLE_META, 10 STATUS_GROUPS, 11 } from '../investigationStates'; 12 13 describe('investigationStates data', () => { 14 it('defines metadata for all 13 statuses', () => { 15 const allStatuses = [ 16 'INTAKE', 'RESEARCH', 'DATA_ANALYSIS', 'POLICY_EVALUATE', 17 'AWAITING_APPROVAL', 'APPROVED', 'EXECUTING', 18 'COMPLETED', 'NO_ACTION_REQUIRED', 'INSUFFICIENT_DATA', 19 'REJECTED', 'EXPIRED', 'FAILED', 20 ]; 21 allStatuses.forEach((s) => { 22 expect(STATUS_META[s as keyof typeof STATUS_META]).toBeDefined(); 23 expect(STATUS_META[s as keyof typeof STATUS_META].label).toBeTruthy(); 24 expect(STATUS_META[s as keyof typeof STATUS_META].color).toBeTruthy(); 25 }); 26 }); 27 28 it('has 8 happy-path timeline states', () => { 29 expect(TIMELINE_STATES).toHaveLength(8); 30 expect(TIMELINE_STATES[0]).toBe('INTAKE'); 31 expect(TIMELINE_STATES[7]).toBe('COMPLETED'); 32 }); 33 34 it('places approval gate at index 4 (AWAITING_APPROVAL)', () => { 35 expect(APPROVAL_GATE_INDEX).toBe(4); 36 expect(TIMELINE_STATES[APPROVAL_GATE_INDEX]).toBe('AWAITING_APPROVAL'); 37 }); 38 39 it('defines agent role metadata for all roles', () => { 40 const roles = ['intake', 'research', 'analysis', 'policy', 'execution', 'machine', 'system']; 41 roles.forEach((r) => { 42 expect(AGENT_ROLE_META[r]).toBeDefined(); 43 expect(AGENT_ROLE_META[r].label).toBeTruthy(); 44 }); 45 }); 46 47 it('status groups cover all 13 statuses without overlap', () => { 48 const allGrouped = [...STATUS_GROUPS.active, ...STATUS_GROUPS.awaiting, ...STATUS_GROUPS.terminal]; 49 expect(allGrouped).toHaveLength(13); 50 const unique = new Set(allGrouped); 51 expect(unique.size).toBe(13); 52 }); 53 54 it('timeline states are in ascending order', () => { 55 for (let i = 1; i < TIMELINE_STATES.length; i++) { 56 const prev = STATUS_META[TIMELINE_STATES[i - 1]].order; 57 const curr = STATUS_META[TIMELINE_STATES[i]].order; 58 expect(curr).toBeGreaterThanOrEqual(prev); 59 } 60 }); 61 });