| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- import test from 'node:test'
- import assert from 'node:assert/strict'
- import fs from 'node:fs'
- const source = fs.readFileSync(new URL('../src/views/subSystem/waterSupply/components/WaterDevicePage.vue', import.meta.url), 'utf8')
- test('device dispatch uses a department tree and paged single-assignee table', () => {
- assert.match(source, /<el-tree[\s\S]*@node-click="handleDeptClick"/)
- assert.match(source, /搜索用户名、昵称或手机号/)
- assert.match(source, /<el-pagination[\s\S]*assigneeTotal/)
- assert.match(source, /selectSingleAssignee\(\[row\]\)/)
- assert.match(source, /:disabled="!assigneeDraft"/)
- })
- test('assignee loading failure remains in place with a retry action', () => {
- assert.match(source, /userLoadError/)
- assert.match(source, /责任人列表加载失败,请点击重试/)
- assert.match(source, /@click="retryAssigneeLoading"/)
- })
- test('assignee loading failure preserves existing rows and total', () => {
- const loadFn = source.match(new RegExp("async function loadAssigneeUsers\\(\\)[\\s\\S]*?\\n\\s*function searchAssigneeUsers"))?.[0] || ""
- assert.doesNotMatch(loadFn, /users\.value = \[\]/)
- assert.doesNotMatch(loadFn, /assigneeTotal\.value = 0/)
- assert.match(loadFn, /userLoadError\.value = '责任人列表加载失败,请点击重试'/)
- })
- test('retry path force reloads the department tree before users', () => {
- assert.match(source, /async function loadDeptTree\(force = false\)/)
- assert.match(source, /async function retryAssigneeLoading\(\)\s*\{[\s\S]*?await loadDeptTree\(true\)[\s\S]*?await loadAssigneeUsers\(\)[\s\S]*?\}/)
- })
- test('assignee keyword search resets to the first result page', () => {
- assert.match(source, /@keyup\.enter="searchAssigneeUsers"/)
- assert.match(source, /@click="searchAssigneeUsers"/)
- assert.match(source, /function searchAssigneeUsers\(\)\s*\{[\s\S]*?assigneePageNum\.value = 1;?\s*loadAssigneeUsers\(\)[\s\S]*?\}/)
- })
- test('assignee pagination is server-backed', () => {
- assert.match(source, /buildAssigneeQuery\(\{\s*deptId:\s*assigneeDeptId\.value,\s*keyword:\s*assigneeKeyword\.value,\s*pageNum:\s*assigneePageNum\.value,\s*pageSize:\s*assigneePageSize\.value\s*\}\)/)
- assert.match(source, /@current-change="loadAssigneeUsers"/)
- assert.match(source, /@size-change="handleAssigneeSizeChange"/)
- })
- test('uses draft assignee state until confirmation in the split dispatch dialog', () => {
- assert.match(source, /const assigneeDraft = ref\(null\)/)
- assert.match(source, /function chooseAssignee\(row\)\s*\{[\s\S]*?assigneeDraft\.value = selectSingleAssignee\(\[row\]\)[\s\S]*?\}/)
- assert.match(source, /function confirmAssignee\(\)\s*\{[\s\S]*?selectedAssignee\.value = assigneeDraft\.value;?\s*dispatchForm\.value\.receiveUserId = assigneeDraft\.value\?\.userId[\s\S]*?\}/)
- assert.match(source, /<div class="dispatch-layout">/)
- assert.match(source, /<el-form class="dispatch-form"/)
- assert.match(source, /:current-row-key="assigneeDraft\?\.userId"/)
- })
- test('opens the split dispatch dialog with a fresh assignee query', () => {
- assert.match(source, /async function openOrder\(row\)/)
- assert.match(source, /assigneeDeptId\.value = undefined/)
- assert.match(source, /assigneeKeyword\.value = ''/)
- assert.match(source, /dispatchVisible\.value = true/)
- assert.match(source, /await retryAssigneeLoading\(\)/)
- })
- test('dispatch form exposes fixed fault type and editable priority', () => {
- assert.match(source, /<el-form-item label="工单类型">\s*<span>1-故障维修<\/span>\s*<\/el-form-item>/)
- assert.match(source, /<el-form-item label="优先级" required>\s*<el-select v-model="dispatchForm\.orderLevel"/)
- assert.match(source, /<el-option\s+label="紧急"\s+:value="1"\s*\/?>/)
- })
- test('dispatch requires a valid server order summary and preserves failure state', () => {
- assert.match(source, /const summary = normalizeDispatchOrderResponse\(response\)/)
- assert.match(source, /服务端未返回有效的待接单工单/)
- assert.match(source, /responseData\?\.msg \|\| responseData\?\.message \|\| error\?\.message/)
- })
- test('does not expose filters unsupported by the device GIS endpoint', () => {
- assert.match(source, /<el-form-item v-if="view !== 'gis'" label="设备名称"/)
- assert.match(source, /<el-form-item v-if="view !== 'gis'" label="设备编码"/)
- assert.match(source, /<el-form-item v-if="view === 'ledger'" label="报警状态"/)
- })
|