import { expect, it } from 'vitest' import { mount, flushPromises } from '@vue/test-utils' import ElementPlus from 'element-plus' import Review from '@/views/archive/ArchiveReview.vue' it('review renders version differences, zero cost values, and opens only explicit item keys', async () => { const wrapper = mount(Review, { props: { canReturn: true, items: [{ item_key: 'technical', title: '技术方案' }, { item_key: 'costAnalysis', title: '项目成本分析表' }], review: { baselineAvailable: true, baselineAt: '2026-10-20 09:00:00', submittedAt: '2026-10-23 09:00:00', documents: [{ kind: 'NEW_VERSION', itemKey: 'technical', itemTitle: '技术方案', beforeName: '图纸.pdf', afterName: '图纸.pdf', beforeRevision: 1, afterRevision: 1, currentRevision: 2 }], costChanges: [{ label: '项目收入', before: 10, after: 0 }], itemChanges: [] } }, global: { plugins: [ElementPlus] } }) await flushPromises() expect(wrapper.text()).toContain('与上次提交相比,改了什么') expect(wrapper.text()).toContain('新上传了第 2 版,当前仍使用第 1 版') expect(wrapper.find('.cost-after').text()).toBe('0.00 元');expect(wrapper.text()).toContain('减少 10.00 元') await wrapper.findAll('button').find(button => button.text() === '要求补充').trigger('click') expect(wrapper.emitted('return')).toEqual([['technical']]) await wrapper.findAll('button').find(button => button.text() === '查看成本明细').trigger('click') expect(wrapper.emitted('open')).toEqual([['costAnalysis']]) wrapper.unmount() }) it('missing history is clearly identified and all current items remain accessible', async () => { const wrapper = mount(Review, { props: { review: { baselineAvailable: false, costChanges: [{ label: '备注', after: '' }] }, items: [{ item_key: 'technical', title: '技术方案', documents: [] }] }, global: { plugins: [ElementPlus] } }) await flushPromises() expect(wrapper.text()).toContain('暂无可对比的上次提交记录') expect(wrapper.find('.review-all button').text()).toContain('技术方案') expect(wrapper.find('.cost-after').text()).toContain('') expect(wrapper.find('script').exists()).toBe(false) expect(wrapper.findAll('button').some(button => button.text() === '要求补充')).toBe(false) await wrapper.find('.review-all button').trigger('click') expect(wrapper.emitted('open')).toEqual([['technical']]) wrapper.unmount() })