waterAlarmAuditWorkbench.test.mjs 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import assert from 'node:assert/strict'
  2. import { readFile } from 'node:fs/promises'
  3. import test from 'node:test'
  4. import { ensureUniqueSubsystemRouteNames } from '../src/router/routeNameUtils.js'
  5. const page = () => readFile('src/views/subSystem/alarm/index.vue', 'utf8')
  6. test('shared audit page consumes enum options and requires an opinion for either decision', async () => {
  7. const source = await page()
  8. assert.ok(source.includes("item.key !== 'UNREVIEWED'"))
  9. assert.ok(source.includes('v-for="item in reviewChoices"'))
  10. assert.ok(source.includes('请填写审核意见'))
  11. assert.ok(source.includes('auditStatus: undefined'))
  12. assert.ok(source.includes('await formRef.value.validate()'))
  13. assert.ok(!source.includes('auditAction'))
  14. })
  15. test('queue and statistics use shared REST endpoints with subsystem scope and server paging', async () => {
  16. const source = await page()
  17. const api = await readFile('src/api/alarmReview.js', 'utf8')
  18. for (const path of ['/api/alarm/reviews', '/api/alarm/reviews/statistics']) assert.ok(api.includes(path))
  19. assert.ok(source.includes('route.query.rootTypeId'))
  20. assert.ok(source.includes('route.query.warning_code'))
  21. assert.ok(source.includes('pageNum: pageNum.value, pageSize: pageSize.value'))
  22. assert.ok(source.includes('row.auditStatus === unreviewed.value'))
  23. assert.ok(!source.includes('仅展示未处理报警'))
  24. assert.ok(!source.includes('list-note'))
  25. })
  26. test('list and detail omit the entire numeric snapshot for alarms without an actual value', async () => {
  27. const source = await page()
  28. const summary = await readFile('src/views/subSystem/alarm/AlarmSummary.vue', 'utf8')
  29. assert.ok(source.includes('<div v-if="hasActualValue(row)" class="snapshot">'))
  30. assert.ok(summary.includes('<p v-if="hasActualValue(alarm)">实际值:'))
  31. })
  32. test('search card uses symmetric vertical padding without trailing form margins', async () => {
  33. const source = await page()
  34. assert.ok(source.includes('.search-card :deep(.el-card__body){padding:16px 20px}'))
  35. assert.ok(source.includes('.search-form :deep(.el-form-item){margin:0}'))
  36. assert.ok(source.includes('gap:12px 24px;margin:0'))
  37. })
  38. test('timeline renders thumbnails with teleported full-size image preview', async () => {
  39. const source = await page()
  40. const attachments = await readFile('src/views/subSystem/alarm/AlarmAttachments.vue', 'utf8')
  41. assert.ok(source.includes('<AlarmAttachments v-if="item.attachUrl"'))
  42. assert.ok(attachments.includes(':preview-src-list="previewUrls"'))
  43. assert.ok(attachments.includes(':initial-index="index"'))
  44. assert.ok(attachments.includes('preview-teleported'))
  45. assert.ok(attachments.includes('images.value.map(file => file.url)'))
  46. assert.ok(!attachments.includes('<el-link'))
  47. assert.ok(attachments.includes('width: 96px; height: 72px;'))
  48. assert.ok(source.includes('accept=".jpg,.jpeg,.png"'))
  49. assert.ok(!source.includes('PDF'))
  50. assert.ok(!source.includes('|pdf'))
  51. })
  52. test('legacy ledger navigates to alarmAudit and no longer implements auditing', async () => {
  53. const ledger = await readFile('src/views/subSystem/waterSupply/components/WaterAlarmPage.vue','utf8')
  54. assert.ok(ledger.includes("/monitorAlarm/alarmAudit"))
  55. assert.ok(!ledger.includes('submitAudit'))
  56. assert.ok(!ledger.includes('auditOrderStatCards'))
  57. const api = await readFile('src/api/pipeNetwork/waterSupply.js','utf8')
  58. assert.ok(!api.includes('/waterSupply/alarm/audit'))
  59. })
  60. test('four identical relative alarmAudit paths retain unique router names', () => {
  61. const routes = ensureUniqueSubsystemRouteNames(['waterSupply','drainage','gas','manholeCover'].map(name => ({
  62. path: '/subSystem/' + name, children: [{path:'alarmAudit',name:'AlarmAudit'}]
  63. })))
  64. assert.equal(new Set(routes.map(route => route.children[0].name)).size,4)
  65. })