|
|
@@ -91,7 +91,7 @@ test('适配层把后端 tags 带进 devices,计数函数才算得出报警/
|
|
|
assert.equal(counts.OFFLINE, 1)
|
|
|
})
|
|
|
|
|
|
-test('运行概况:环=在线/离线(合计 395,中心读数即总数),标签用三条以 395 为满宽的细条', () => {
|
|
|
+test('运行概况:一个「设备状态」块——环给在线/离线,可叠加标签作为细条并入,末尾「本数 / 395 台」', () => {
|
|
|
const devices = []
|
|
|
// 16 台报警,其中 4 台离线——旧指标六态只数到 12
|
|
|
for (let i = 0; i < 16; i += 1) {
|
|
|
@@ -103,25 +103,26 @@ test('运行概况:环=在线/离线(合计 395,中心读数即总数)
|
|
|
for (let i = 0; i < 133; i += 1) devices.push({ deviceCode: 'O' + i, status: 'OFFLINE', tags: [] })
|
|
|
assert.equal(devices.length, 395)
|
|
|
|
|
|
- const pools = deviceStatusStats(devices)
|
|
|
const view = operationOverviewPanel(
|
|
|
{ metricStatuses: [], abnormalEquipment: [], pagination: { total: 0 } },
|
|
|
{},
|
|
|
- { devices: [], deviceStatusPools: pools },
|
|
|
+ { devices: [], deviceStatusPools: deviceStatusStats(devices) },
|
|
|
)
|
|
|
|
|
|
- const donut = view.blocks.find((block) => block.kind === 'donut' && String(block.label).includes('在线'))
|
|
|
- assert.ok(donut, '必须有「在线/离线」环')
|
|
|
- assert.equal(donut.total, 395, '环的中心读数=设备总数')
|
|
|
- assert.equal(donut.rows.find((row) => row.label === '在线').count, 258)
|
|
|
- assert.equal(donut.rows.find((row) => row.label === '离线').count, 137)
|
|
|
+ // 只有一个块承载这件事:标题就叫「设备状态」(不再有「在线 / 离线」或「业务标签」副标题)
|
|
|
+ const stateBlocks = view.blocks.filter((block) => block.kind === 'donut' || block.kind === 'bars')
|
|
|
+ assert.equal(stateBlocks.length, 1, '环与细条必须在同一个块里')
|
|
|
+ const block = stateBlocks[0]
|
|
|
+ assert.equal(block.label, '设备状态')
|
|
|
+ assert.equal(block.total, 395, '环心读数=设备总数')
|
|
|
+ assert.equal(block.rows.find((row) => row.label === '在线').count, 258)
|
|
|
+ assert.equal(block.rows.find((row) => row.label === '离线').count, 137)
|
|
|
|
|
|
- const bars = view.blocks.find((block) => block.kind === 'bars' && String(block.label).includes('业务标签'))
|
|
|
- assert.ok(bars, '必须有可叠加标签的细条块')
|
|
|
- const byLabel = Object.fromEntries(bars.rows.map((row) => [row.label, row]))
|
|
|
+ assert.ok(block.bars && block.bars.rows.length === 3, '并入三条可叠加标签细条')
|
|
|
+ assert.equal(block.bars.total, 395, '细条满宽=395 台(末端读数 16 / 395 台)')
|
|
|
+ const byLabel = Object.fromEntries(block.bars.rows.map((row) => [row.label, row]))
|
|
|
assert.equal(byLabel['报警'].count, 16)
|
|
|
assert.equal(byLabel['预警'].count, 2)
|
|
|
assert.equal(byLabel['工单处置'].count, 1)
|
|
|
- // 条长以「395 台」为满宽(不是按本块最大值归一)
|
|
|
- assert.ok(Math.abs(byLabel['报警'].ratio - 16 / 395) < 1e-9, '报警条长应=16/395')
|
|
|
+ assert.ok(Math.abs(byLabel['报警'].ratio - 16 / 395) < 1e-9, '条长应按 395 归一,而不是按本块最大值')
|
|
|
})
|