waterSupplyWorkOrderStatusDict.test.mjs 1.6 KB

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