waterSupplyHomeContract.test.mjs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. import test from 'node:test'
  2. import assert from 'node:assert/strict'
  3. import { readFile } from 'node:fs/promises'
  4. const homePath = 'src/views/subSystem/waterSupply/components/WaterSupplyHome.vue'
  5. test('home removes the A/B/C placeholder headings', async () => {
  6. const source = await readFile(homePath, 'utf8')
  7. assert.doesNotMatch(source, /A · 指挥台/u)
  8. assert.doesNotMatch(source, /B · 异常待办/u)
  9. assert.doesNotMatch(source, /C · 数据总览/u)
  10. })
  11. test('home realtime alarms split between audit and work order by display status', async () => {
  12. const source = await readFile(homePath, 'utf8')
  13. assert.match(source, /openRealtimeAlarm\(item\)/u)
  14. assert.match(source, /realtimeAlarmJumpTarget\(item\)/u)
  15. assert.match(source, /goPage\(target\.path, target\.query\)/u)
  16. assert.match(source, /item\.displayStatusText/u)
  17. assert.match(source, /item\.displayStatusType/u)
  18. assert.match(source, /goPage\('\/device\/maintain'/u)
  19. })
  20. test('home overview uses the shared GIS map canvas and aggregates all one-map layers', async () => {
  21. const source = await readFile(homePath, 'utf8')
  22. assert.match(source, /<GisMapCanvas/u)
  23. assert.match(source, /ref="overviewMapRef"/u)
  24. assert.match(source, /:points="overviewMapPoints"/u)
  25. assert.match(source, /:lines="overviewMapLines"/u)
  26. assert.match(source, /@point-click="openOverviewPoint"/u)
  27. assert.match(source, /@line-click="openOverviewPoint"/u)
  28. assert.match(source, /buildHomeGisOverview/u)
  29. assert.match(source, /getWaterFacilityFeatures\(\)/u)
  30. assert.match(source, /listAlarmMapPoints\(\)/u)
  31. assert.match(source, /getDeviceGisAllPoints\(\)/u)
  32. })
  33. test('home overview map takes at least 60% of the same row in desktop layout', async () => {
  34. const source = await readFile(homePath, 'utf8')
  35. assert.match(source, /grid-template-columns:\s*minmax\(240px,\s*1fr\)\s+minmax\(0,\s*3fr\)\s+minmax\(240px,\s*1fr\)/u)
  36. })
  37. test('home work order jumps point to device maintenance dispatch page', async () => {
  38. const source = await readFile(homePath, 'utf8')
  39. const jumps = source.match(/goPage\('\/device\/maintain'/gu) || []
  40. assert.ok(jumps.length >= 3, 'header, work order rows and related order should all route to device maintain')
  41. assert.doesNotMatch(source, /monitorAlarm\/workOrder/u)
  42. assert.match(source, />设备维修派单<\/el-button>/u)
  43. })
  44. test('home B-road detail panel is 1:1 with the todo and shortcut panels', async () => {
  45. const source = await readFile(homePath, 'utf8')
  46. assert.match(source, /workbench-grid--equal/u)
  47. assert.match(source, /repeat\(3,\s*minmax\(0,\s*1fr\)\)/u)
  48. const sectionB = source.match(/<section class="home-section">([\s\S]*?)<el-card shadow="never" class="water-panel home-panel detail-panel">/u)
  49. assert.ok(sectionB, 'detail panel should live in the equal-width B section')
  50. })
  51. test('home list panels scroll to reveal the full queue instead of pinning a few rows', async () => {
  52. const source = await readFile(homePath, 'utf8')
  53. const listSelector = source.match(/\.compact-list\s*\{[^}]*\}/u)
  54. assert.ok(listSelector, 'compact list style block exists')
  55. assert.match(listSelector[0], /max-height:\s*[\w.]+/u)
  56. assert.match(listSelector[0], /overflow-y:\s*auto/u)
  57. assert.match(source, /listRealtimeAlarms\(\),/u)
  58. })
  59. test('home overview map fills the full map card body', async () => {
  60. const source = await readFile(homePath, 'utf8')
  61. assert.match(source, /\.map-panel[\s\S]{0,160}?display:\s*flex/u)
  62. assert.match(source, /\.map-stage[\s\S]{0,140}?flex:\s*1/u)
  63. })
  64. test('home overview legend and detail cover unified device and facility status colors', async () => {
  65. const source = await readFile(homePath, 'utf8')
  66. assert.match(source, /gisPointStatusColors\.alarm[\s\S]{0,20}报警\/异常/u)
  67. assert.match(source, /gisPointStatusColors\.workOrder[\s\S]{0,20}工单\/检修中/u)
  68. assert.match(source, /gisPointStatusColors\.warning[\s\S]{0,20}预警\/欠费/u)
  69. assert.match(source, /gisPointStatusColors\.offline[\s\S]{0,20}离线/u)
  70. assert.match(source, /gisPointStatusColors\.normal[\s\S]{0,20}正常/u)
  71. assert.match(source, /overviewDetail\.statusText \|\| gisStatusLabel\(overviewDetail\.statusKey\)/u)
  72. })
  73. test('home device data sources track the unified equipment endpoints', async () => {
  74. const source = await readFile(homePath, 'utf8')
  75. // 设备台账已统一到 /equipment-base:统计与列表都走统一设备接口,供水范围用 rootTypeId 限定
  76. assert.match(source, /getEquipmentStatusStatistics\(/u)
  77. assert.match(source, /listEquipment\(/u)
  78. assert.match(source, /rootTypeId/u)
  79. assert.match(source, /normalizeDeviceStatistics/u)
  80. // 供水专属的旧设备接口已下线,不得再被首页引用
  81. assert.doesNotMatch(source, /getDeviceLedgerStatistics/u)
  82. assert.doesNotMatch(source, /listAbnormalDevices/u)
  83. })
  84. test('home surfaces partial load failures instead of swallowing them', async () => {
  85. const source = await readFile(homePath, 'utf8')
  86. // settle 自身吞掉异常并返回兜底值,因此失败上报必须由 settle 内部完成;
  87. // 链式 .catch(recordProblem(...)) 永不触发,会让“部分数据加载失败”提示变成死代码。
  88. assert.match(source, /async function settle\(fn, fallback = null, onError = null\)/u)
  89. assert.match(source, /onError\?\.\(\)/u)
  90. assert.doesNotMatch(source, /\.catch\(recordProblem\(/u)
  91. assert.match(source, /settle\(\(\) => getWaterFacilityOverview\(\), \[\], recordProblem\('设施概览'\)\)/u)
  92. assert.match(source, /settle\(\(\) => listRealtimeAlarms\(\), \[\], recordProblem\('实时报警'\)\)/u)
  93. })