import { buildEdgeNodeQuery, durationText, eventLabel, freshnessText, stateLabel, stateType } from '@/views/sense/edge-node/edgeNodeState' describe('Sense edge node presentation state', () => { test('uses operator-facing connection and channel labels', () => { expect(stateLabel('offline')).toBe('离线') expect(stateLabel('recovering')).toBe('恢复中') expect(stateType('offline')).toBe('danger') expect(eventLabel('node_recovered')).toBe('心跳恢复') }) test('makes stale last-known data explicit', () => { expect(freshnessText({ stale: true, freshnessSeconds: 245, lastHeartbeatAt: '2026-08-28T00:00:00Z' })).toBe('已陈旧 4 分钟') expect(freshnessText({ stale: false, freshnessSeconds: 18, lastHeartbeatAt: '2026-08-28T00:00:00Z' })).toBe('18 秒前') expect(durationText(172800)).toBe('2 天') }) test('sends only allowlisted pagination fields', () => { expect(buildEdgeNodeQuery({ pageIndex: '2', pageSize: 20, ignored: 'not-sent' })).toEqual({ pageIndex: 2, pageSize: 20 }) }) })