import { buildLocalEventQuery, candidateLabel, evidenceLabel, evidenceType, retentionLabel } from '@/views/sense/local-event/localEventState' describe('Sense local event presentation state', () => { test('keeps candidate and evidence states distinct', () => { expect(candidateLabel('candidate')).toBe('候选') expect(candidateLabel('confirmed')).toBe('已确认事件') expect(evidenceLabel('pending')).toBe('处理中') expect(evidenceLabel('success')).toBe('成功') expect(evidenceLabel('failed')).toBe('失败') expect(evidenceType('failed')).toBe('danger') }) test('builds an allowlisted query with RFC3339 time bounds', () => { const result = buildLocalEventQuery({ pageIndex: 2, pageSize: 20, candidateState: 'candidate', evidenceState: 'failed', ruleRef: ' rule-1 ', keyword: ' camera-3 ', ignored: 'not-sent' }, ['2026-08-27T00:00:00Z', '2026-08-28T00:00:00Z']) expect(result).toEqual({ pageIndex: 2, pageSize: 20, candidateState: 'candidate', evidenceState: 'failed', ruleRef: 'rule-1', keyword: 'camera-3', occurredAfter: '2026-08-27T00:00:00.000Z', occurredBefore: '2026-08-28T00:00:00.000Z' }) }) test('describes retention without inventing a global duration', () => { expect(retentionLabel({ retainUntil: '2026-09-09T00:00:00Z', retentionState: 'active', remainingDays: 12 })).toBe('保留至 2026-09-09') expect(retentionLabel({ retainUntil: '2026-08-30T00:00:00Z', retentionState: 'expiring', remainingDays: 2 })).toBe('2 天内到期') expect(retentionLabel({ retainUntil: '2026-08-01T00:00:00Z', retentionState: 'expired', remainingDays: 0 })).toBe('已到期') }) })