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, / { 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, /
/) assert.match(source, / { 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, /\s*1-故障维修<\/span>\s*<\/el-form-item>/) assert.match(source, /\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, /