waterSupplyHomeContract.test.mjs 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. })