feat: 实现边缘节点资产与离线状态管理 (#76)

This commit is contained in:
QiuSW
2026-08-28 14:25:32 +08:00
parent a9fd8e8a47
commit 2db49fc955
20 changed files with 970 additions and 10 deletions
@@ -0,0 +1,18 @@
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 })
})
})