import assert from 'node:assert/strict' import { readFile } from 'node:fs/promises' import test from 'node:test' const pagePath = 'src/views/subSystem/waterSupply/components/WaterAlarmPage.vue' const apiPath = 'src/api/pipeNetwork/waterSupply.js' test('audit workbench exposes exactly two actions, not an action x result matrix', async () => { const source = await readFile(pagePath, 'utf8') assert.match(source, /转工单<\/el-radio>/u) assert.match(source, /误报解除<\/el-radio>/u) assert.doesNotMatch(source, /v-model="auditForm\.auditAction"/u, '不应再暴露 auditAction 原始码') assert.doesNotMatch(source, /v-model="auditForm\.auditResult"/u, '不应再暴露 auditResult 原始码') assert.doesNotMatch(source, /label="审核结果"/u, '四个组合已收敛为两个动作') }) test('audit submission maps to backend action codes and requires an opinion on release', async () => { const source = await readFile(pagePath, 'utf8') const submit = source.slice(source.indexOf('async function submitAudit'), source.indexOf('async function submitAudit') + 1000) assert.match(submit, /auditAction: decision === 'release' \? 2 : 1/u) assert.match(submit, /auditResult: decision === 'release' \? 2 : 1/u) assert.match(submit, /decision === 'release' && !String\(auditOpinion \|\| ''\)\.trim\(\)/u, '误报解除必须留下审核意见') }) test('audit workbench shows work order status counts fed by the backend aggregate', async () => { const source = await readFile(pagePath, 'utf8') const api = await readFile(apiPath, 'utf8') assert.match(api, /getAuditOrderStats[^\n]*\/waterSupply\/alarm\/audit\/order-stats/u) const cards = source.slice(source.indexOf('const auditOrderStatCards'), source.indexOf('const pageIcon')) for (const label of ['全部工单', '待处理', '处理中', '待验收', '已完成']) { assert.match(cards, new RegExp(`label: '${label}'`, 'u'), `计数条缺少:${label}`) } assert.match(source, /v-for="card in auditOrderStatCards"/u) assert.match(source, /getAuditOrderStats\(\)/u, '审核模式应加载工单状态计数') }) test('audit queue reads derived display status instead of raw alarm record status', async () => { const source = await readFile(pagePath, 'utf8') // 队列来源:只读台账接口 + 展示状态=待审核 assert.match(source, /const AUDIT_DISPLAY_PENDING = 1/u) assert.match(source, /listAlarmLedger\(\{\.\.\.query\.value, displayStatus: AUDIT_DISPLAY_PENDING\}\)/u) assert.doesNotMatch(source, /listAlarmHistory\(\{\.\.\.query\.value, alarmStatus: 0\}\)/u, '不应再按底层报警记录状态硬过滤队列') // 「未处理/已处理」噪声口径不应再出现在审核模式 assert.doesNotMatch(source, //u) assert.doesNotMatch(source, /Number\(row\.alarmStatus\) === 1 \? '已处理' : '未处理'/u) assert.match(source, //u, '两种模式都应展示后端推导的展示状态') })