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(/async function loadAssigneeUsers\(\)[\s\S]*?\nfunction 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\(\) \{ const deptLoaded = await loadDeptTree\(true\); if \(!deptLoaded\) return; await loadAssigneeUsers\(\) \}/) }) 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\(\) \{ assigneePageNum\.value = 1; loadAssigneeUsers\(\) \}/) }) test('assignee pagination is server-backed', () => { assert.match(source, /buildAssigneeQuery\(\{ deptId: assigneeDeptId\.value, keyword: assigneeKeyword\.value, pageNum: assigneePageNum\.value, pageSize: assigneePageSize\.value \}\)/) 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\) \{ assigneeDraft\.value = selectSingleAssignee\(\[row\]\) \}/) assert.match(source, /function confirmAssignee\(\) \{ selectedAssignee\.value = assigneeDraft\.value; dispatchForm\.value\.receiveUserId = assigneeDraft\.value\?\.userId \}/) 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 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, /