|
|
@@ -190,4 +190,34 @@ test('报警已处理时流程结束在关闭步,不再停在处置步', () =>
|
|
|
))
|
|
|
assert.equal(view.status, '已处理')
|
|
|
assert.deepEqual(view.stage.map((item) => item.state), ['done', 'done', 'done', 'active'])
|
|
|
-})
|
|
|
+})
|
|
|
+// 票 11 真实联调抓到的契约偏差:后端对没有阈值的预警下发 minValue/maxValue = null,
|
|
|
+// 旧实现只把 undefined 当缺值 ⇒ 界面上出现「阈值 null ~ null(单位未发布)」。
|
|
|
+function warningWithMetrics(metrics) {
|
|
|
+ const raw = {
|
|
|
+ basicInfo: {
|
|
|
+ warningNo: 'YJ202612011319124570',
|
|
|
+ warningName: '测试环境监测-测试01',
|
|
|
+ status: 'PENDING',
|
|
|
+ eventTime: '2026-12-01T13:19:12.000+08:00',
|
|
|
+ ...metrics,
|
|
|
+ },
|
|
|
+ disposalHistory: [],
|
|
|
+ }
|
|
|
+ return entityDetailView(normalizeEntityDetail({ kind: 'event', id: 'YJ202612011319124570', family: 'WARNING' }, raw))
|
|
|
+}
|
|
|
+
|
|
|
+test('阈值两端为 null:整行不出,不把 null 打成字符串上屏', () => {
|
|
|
+ const view = warningWithMetrics({ minValue: null, maxValue: null, actualValue: null })
|
|
|
+ const metrics = view.sections.find((g) => g.title === '监测读数')
|
|
|
+ const thresholdRow = (metrics ? metrics.fields : []).find((f) => f.label === '阈值')
|
|
|
+ assert.equal(thresholdRow, undefined, '缺阈值的行应被 compactSections 剔除')
|
|
|
+ assert.equal(JSON.stringify(view.sections).includes('null ~ null'), false)
|
|
|
+})
|
|
|
+
|
|
|
+test('阈值有值时仍按「min ~ max 单位」渲染', () => {
|
|
|
+ const view = warningWithMetrics({ minValue: 1.5, maxValue: 2.5, unit: '%LEL', actualValue: 3.1 })
|
|
|
+ const metrics = view.sections.find((g) => g.title === '监测读数')
|
|
|
+ assert.equal(metrics.fields.find((f) => f.label === '阈值').value, '1.5 ~ 2.5 %LEL')
|
|
|
+ assert.equal(metrics.fields.find((f) => f.label === '实际值').value, '3.1 %LEL')
|
|
|
+})
|