check-oa-progress-merge-comments.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import assert from 'node:assert/strict'
  2. import { mergeProgressWithComments } from '../src/utils/oa-progress-merge-comments'
  3. const progress = [
  4. {
  5. key: 'submit',
  6. kind: 'submit',
  7. title: '发起人',
  8. status: 'submitted',
  9. timestamp: '2026-09-21 10:00:00'
  10. },
  11. {
  12. key: 'task-a',
  13. kind: 'task',
  14. title: '主管审批',
  15. status: 'approved',
  16. timestamp: '2026-09-21 10:05:00'
  17. },
  18. {
  19. key: 'task-b',
  20. kind: 'task',
  21. title: '经理审批',
  22. status: 'pending',
  23. timestamp: '2026-09-21 10:05:01'
  24. },
  25. {
  26. key: 'future',
  27. kind: 'task',
  28. title: '财务',
  29. status: 'not_reached',
  30. timestamp: ''
  31. }
  32. ]
  33. const comments = [
  34. {
  35. id: 'c1',
  36. content: '请补充材料',
  37. attachmentRefs: [],
  38. status: 'normal',
  39. createBy: 'u1',
  40. createByName: '张三',
  41. createTime: '2026-09-21 10:06:00',
  42. canRevoke: true
  43. }
  44. ]
  45. const out = mergeProgressWithComments(progress as any, comments as any)
  46. assert.equal(
  47. out.map((x) => x.key).join(','),
  48. 'submit,task-a,comment-c1,task-b,future'
  49. )
  50. assert.equal(out[2].kind, 'comment')
  51. assert.equal(out[3].status, 'pending')
  52. assert.equal(out[4].status, 'not_reached')
  53. console.log('ok: mergeProgressWithComments')