import { buildOperationsQuery, canRetry, objectLabel, problemLabel, severityType, stateLabel } from '@/views/sense/operations/operationsState' describe('Sense operations presentation state', () => { test('uses operator-facing state labels', () => { expect(objectLabel('local_inference')).toBe('本地推理') expect(problemLabel('orphan_safety_gate')).toBe('孤儿安全闸') expect(stateLabel('unavailable')).toBe('不可用(未安装)') expect(stateLabel('active / ready')).toBe('已启用 / 就绪') expect(severityType('high')).toBe('danger') }) test('allows retry only when the server projection says it is safe', () => { expect(canRetry({ retryable: true, retryInProgress: false, version: 2 })).toBe(true) expect(canRetry({ retryable: true, retryInProgress: true, version: 2 })).toBe(false) expect(canRetry({ retryable: false, retryInProgress: false, version: 2 })).toBe(false) }) test('builds an allowlisted query', () => { expect(buildOperationsQuery({ pageIndex: 2, pageSize: 20, objectType: ' device ', problemType: 'clock_drift', severity: ' medium ', keyword: ' 南门 ', ignored: 'not-sent' })).toEqual({ pageIndex: 2, pageSize: 20, objectType: 'device', problemType: 'clock_drift', severity: 'medium', keyword: '南门' }) }) })