| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- import test from 'node:test'
- import assert from 'node:assert/strict'
- import { readFile } from 'node:fs/promises'
- const readAlarmPage = () => readFile('src/views/subSystem/waterSupply/components/WaterAlarmPage.vue', 'utf8')
- test('the alarm map merges the alarm ledger and device points onto the shared canvas', async () => {
- const source = await readAlarmPage()
- assert.match(source, /buildAlarmGisPoints\(\{/u)
- assert.match(source, /async function loadAllAlarmLedgerRows\(\)/u)
- assert.match(source, /collected\.length >= ledgerPage\.total/u)
- assert.match(source, /getDeviceGisAllPoints\(/u)
- assert.match(source, /normalizeDeviceGisPoints[\s\S]*?normalizeDeviceRow/u)
- assert.match(source, /:points="gisMapPoints"/u)
- assert.match(source, /cluster-label="报警集合"/u)
- })
- test('clicking a map point or search result locates the alarm and opens the detail drawer', async () => {
- const source = await readAlarmPage()
- assert.match(source, /@point-click="locateAlarmPoint"/u)
- assert.match(source, /function locateAlarmPoint\(point\)[\s\S]*?gisMapRef\.value\?\.locatePoint\(/u)
- assert.match(source, /function locateAlarmPoint\(point\)[\s\S]*?openDetail\(point\)/u)
- })
- test('the alarm map shows distinct empty, failed and retry states', async () => {
- const source = await readAlarmPage()
- assert.match(source, /const mapLoadError = ref\(''\)/u)
- assert.match(source, /mapLoadError\.value = /u)
- assert.match(source, /@click="loadData"[^>]*>\s*重试/u)
- assert.match(source, /暂无报警点位/u)
- assert.match(source, /当前筛选下没有匹配的报警点位/u)
- assert.match(source, /v-if="mapEnrichmentWarning"[\s\S]*?v-if="!mapLoadError && mapPoints\.length && !filteredAlarmPoints\.length"/u)
- })
- test('the alarm map exposes five map states with text, not colour alone', async () => {
- const source = await readAlarmPage()
- const legendStates = [
- ['work-order', '关联工单'],
- ['alarm', '报警'],
- ['warning', '预警'],
- ['offline', '离线'],
- ['normal', '正常']
- ]
- for (const [statusClass, label] of legendStates) {
- assert.match(source, new RegExp(`status-dot-${statusClass}"\\/>${label}`, 'u'))
- }
- assert.match(source, /mapStatistics\.byStatus/u)
- })
- test('the alarm detail panel keeps device, record and work-order states apart', async () => {
- const source = await readAlarmPage()
- assert.match(source, /\['报警记录状态', row\.recordStatusText \|\| row\.alarmStatusText\]/u)
- assert.match(source, /\['设备报警状态', row\.deviceAlarmStatusText\]/u)
- assert.match(source, /\['报警展示状态', row\.displayStatusText\]/u)
- assert.match(source, /\['工单状态', row\.orderStatus/u)
- assert.match(source, /\['在线状态', row\.onlineStatusText\]/u)
- })
- test('the alarm map fits all points after the map and data are ready', async () => {
- const source = await readAlarmPage()
- assert.match(source, /@ready="handleAlarmMapReady"/u)
- assert.match(source, /function fitAlarmMap\(\)/u)
- assert.match(source, /<el-button :icon="Aim" @click="fitAlarmMap">全图<\/el-button>/u)
- })
|