cmvr-wms/ruoyi-ui-vue3/tests/runtime/archive-workflow.spec.js
lixiaolong f8f286d2a1 feat(assistant): 新增用户核对功能并优化对话流程
- 新增 user.check 功能用于核对人员是否已有系统账号
- 在 assistant-table-layout.js 中为用户表格添加 checkedIdentity 和 matchResult 字段
- 优化 AssistantConversationService 中的任务记忆和澄清流程
- 支持对草稿特定行进行修改,无需重新填写整张表
- 限制 user.check 操作最大查询数量为 100 条记录
- 实现中断任务恢复机制,保持原始请求上下文
- 添加针对多行数据选择性修改的目标行标识支持
2026-10-27 09:04:41 +08:00

42 lines
2.9 KiB
JavaScript

import { expect, it } from 'vitest'
import { archiveItemEligibility, itemPresentationState, itemNextStep, pendingArchiveItems, nextPendingItem, reviewWaitDays } from '@/views/archive/archive-workflow'
import { summary } from '@/views/archive/archive-model'
const file = { id: 1, item_key: 'technical', title: '技术方案', required: 1, applicable: 1, state: 'MISSING', documents: [{ current_file_id: 'a' }] }
it('uploaded legacy records are presented as maintenance while confirmation stays explicit', () => {
expect(itemPresentationState(file)).toBe('PARTIAL')
expect(file.state).toBe('MISSING')
expect(itemNextStep(file)).toContain('待本人确认齐全')
expect(itemNextStep({ ...file, state: 'DONE' })).toContain('项目是否归档请查看顶部归档状态')
expect(itemPresentationState({ ...file, documents: [] })).toBe('MISSING')
expect(itemPresentationState({ ...file, applicable: 0 })).toBe('NA')
expect(archiveItemEligibility({ ...file, documents: [{ current_file_id: null }] }).allowed).toBe(false)
expect(archiveItemEligibility({ ...file, expected_count: 2 }).reason).toContain('还需补充 1 份')
})
it('cost completeness is separate from saving, unsaved edits and explicit confirmation', () => {
const cost = { ...file, item_key: 'costAnalysis', documents: [] }
expect(archiveItemEligibility(cost, {}).allowed).toBe(false)
expect(archiveItemEligibility(cost, { data: {}, complete: false }).reason).toContain('补齐')
expect(archiveItemEligibility(cost, { complete: true }, true).allowed).toBe(false)
expect(archiveItemEligibility(cost, { complete: true }).allowed).toBe(true)
expect(itemPresentationState(cost, { data: {}, complete: true })).toBe('PARTIAL')
expect(itemPresentationState({ ...cost, has_cost_saved: 1 })).toBe('PARTIAL')
expect(archiveItemEligibility({ ...cost, state: 'DONE' }, { complete: true }).allowed).toBe(false)
})
it('next pending navigation prioritizes required issues, skips inapplicable items and never loops onto the same item', () => {
const items = [{ ...file, id: 0, item_key: 'optional', required: 0 }, file, { ...file, id: 2, item_key: 'costAnalysis' }, { ...file, id: 3, item_key: 'na', applicable: 0 }]
expect(pendingArchiveItems(items).map(item => item.item_key)).toEqual(['technical', 'costAnalysis', 'optional'])
expect(nextPendingItem(items, '').item_key).toBe('technical')
expect(nextPendingItem(items, 'technical').item_key).toBe('costAnalysis')
expect(nextPendingItem([file], 'technical')).toBeNull()
const totals = summary(items)
expect(totals).toMatchObject({ required: 2, optional: 1, optionalDone: 0, na: 1 })
})
it('waiting days never invent a date or a negative wait', () => {
const now = Date.parse('2026-10-23T00:00:00Z')
expect(reviewWaitDays('2026-10-20T00:00:00Z', now)).toBe(3)
expect(reviewWaitDays('2026-11-20T00:00:00Z', now)).toBe(0)
expect(reviewWaitDays(null, now)).toBeNull()
expect(reviewWaitDays('invalid', now)).toBeNull()
})