31 lines
2.1 KiB
JavaScript
31 lines
2.1 KiB
JavaScript
|
|
import { expect, it } from 'vitest'
|
||
|
|
import { mount, flushPromises } from '@vue/test-utils'
|
||
|
|
import ElementPlus from 'element-plus'
|
||
|
|
import Preview from '@/components/BusinessAssistant/AssistantReferencePricePreview.vue'
|
||
|
|
|
||
|
|
it('one combined preview renders actual amounts first, cleared quotes as empty rather than zero, and restrictions', async () => {
|
||
|
|
const wrapper = mount(Preview, { props: { rows: [
|
||
|
|
{ name: '模拟水泵', quantity: 2, quotePrice: 12.5, oldActualPrice: 1, newActualPrice: 12.5, oldActualAmount: 2, newActualAmount: 25, oldQuoteAmount: 25, newQuotePrice: null, newQuoteAmount: null, clearQuote: true, changed: true, blocked: false, notice: '先复制原报价,再清空报价' },
|
||
|
|
{ name: '模拟历史采购', quantity: 1, quotePrice: 0, newActualPrice: 0, newActualAmount: 0, newQuotePrice: null, newQuoteAmount: null, clearQuote: true, changed: true, blocked: true, notice: '已有到货或入库记录,整批不执行' }
|
||
|
|
] }, global: { plugins: [ElementPlus] } })
|
||
|
|
await flushPromises()
|
||
|
|
expect(wrapper.text()).toContain('实际金额与报价核对')
|
||
|
|
expect(wrapper.text()).toContain('清空(未报价)')
|
||
|
|
expect(wrapper.text()).toContain('不是 0 元')
|
||
|
|
expect(wrapper.find('.blocked').text()).toContain('整批不执行')
|
||
|
|
expect(wrapper.findAll('.removed').map(node => node.text())).toEqual(['12.5', '0'])
|
||
|
|
const headers = wrapper.findAll('thead th').map(node => node.text())
|
||
|
|
expect(headers.indexOf('新实际金额')).toBeLessThan(headers.indexOf('原报价单价'))
|
||
|
|
expect(headers).toContain('新报价金额')
|
||
|
|
wrapper.unmount()
|
||
|
|
})
|
||
|
|
|
||
|
|
it('reference-only mode still promises unchanged quotes and never shows clear-quote columns', async () => {
|
||
|
|
const wrapper = mount(Preview, { props: { rows: [{ name: '模拟物品', newActualPrice: 0, newActualAmount: 0, quotePrice: 0, changed: true }] }, global: { plugins: [ElementPlus] } })
|
||
|
|
await flushPromises()
|
||
|
|
expect(wrapper.text()).toContain('不修改报价及成本')
|
||
|
|
expect(wrapper.text()).not.toContain('清空(未报价)')
|
||
|
|
expect(wrapper.findAll('thead th').map(node => node.text())).not.toContain('新报价单价')
|
||
|
|
wrapper.unmount()
|
||
|
|
})
|