import { alertStateLabel, alertStateType, alertTypeLabel, buildOpsAlertQuery, canAcknowledge, canRecover } from '@/views/sense/ops-alert/opsAlertState' describe('Sense operational alert presentation state', () => { test('uses ordinary operations wording and six alert types', () => { expect(alertTypeLabel('device_offline')).toBe('设备离线') expect(alertTypeLabel('authentication_failed')).toBe('认证失败') expect(alertTypeLabel('clock_drift')).toBe('时间漂移') expect(alertTypeLabel('reconciliation_failed')).toBe('状态对账失败') expect(alertTypeLabel('media_shard_failed')).toBe('媒体分片异常') expect(alertTypeLabel('control_tunnel_failed')).toBe('控制隧道异常') expect(alertStateLabel('recovering')).toBe('恢复观察') expect(alertStateType('recovered')).toBe('success') }) test('enforces the approved state action boundary', () => { expect(canAcknowledge({ state: 'unacknowledged', version: 1 })).toBe(true) expect(canAcknowledge({ state: 'acknowledged', version: 2 })).toBe(false) expect(canRecover({ state: 'recovering', version: 3 })).toBe(true) expect(canRecover({ state: 'acknowledged', version: 3 })).toBe(false) }) test('builds an allowlisted query', () => { expect(buildOpsAlertQuery({ pageIndex: '2', pageSize: 20, alertType: ' clock_drift ', state: ' recovering ', keyword: ' 南门 ', ignored: true })).toEqual({ pageIndex: 2, pageSize: 20, alertType: 'clock_drift', state: 'recovering', keyword: '南门' }) }) })