| 123456789101112131415161718192021222324252627282930313233343536 |
- import assert from 'node:assert/strict'
- import { readFile } from 'node:fs/promises'
- import test from 'node:test'
- import { canOperate, orderStatusType, orderStatusText } from '../src/views/subSystem/pipeNetwork/ops/workOrder/js/workOrderDict.js'
- test('cancellation is available only before a work order is accepted', () => {
- for (const status of [0, 1]) {
- assert.equal(canOperate.cancel({ orderStatus: status }), true)
- assert.equal(canOperate.cancel({ orderStatus: String(status) }), true)
- }
- for (const status of [2, 3, 4, 5, 6, 7, -1, 8]) {
- assert.equal(canOperate.cancel({ orderStatus: status }), false)
- }
- })
- test('shared work-order dictionary covers the authoritative 0-7 status codes', () => {
- assert.deepEqual(
- [0, 1, 2, 3, 4, 5, 6, 7].map(orderStatusText),
- ['待派单', '待接单', '已接单', '处理中', '待验收', '已结案', '延期中', '已取消']
- )
- const types = [0, 1, 2, 3, 4, 5, 6, 7].map(orderStatusType)
- assert.ok(types.every(type => ['danger', 'warning', 'primary', 'success', 'info'].includes(type)))
- assert.equal(orderStatusType(5), 'success')
- assert.equal(orderStatusType(7), 'info')
- })
- test('water supply device pages reuse the shared dictionary instead of a private status table', async () => {
- const source = await readFile('src/views/subSystem/waterSupply/components/WaterDeviceAbnormalPage.vue', 'utf8')
- assert.doesNotMatch(source, /function\s+workOrderStatusType/, '页面不应自带工单状态色表')
- assert.match(
- source,
- /from '@\/views\/subSystem\/pipeNetwork\/ops\/workOrder\/js\/workOrderDict\.js'/u,
- '页面应复用统一工单字典'
- )
- })
|