优化
This commit is contained in:
@@ -18,7 +18,7 @@ vi.mock('@/core/unsaved-work/useUnsavedWorkRegistration', () => ({ useUnsavedWor
|
||||
enableAutoUnmount(afterEach)
|
||||
const workflow = (status = 'RECEIVING'): ProcurementWorkflow => ({ orderNo: 'OP-1', version: 4, status, receivedQuantity: 5, stockQuantity: 5, reservedQuantity: 0, availableQuantity: 5, receipts: [], outbounds: [] })
|
||||
const detail = { customerView: { order: { purchaseQuantity: 20 } }, files: [] } as unknown as PlatformProcurement
|
||||
const beforeOutbound = vi.fn<() => Promise<void>>()
|
||||
const beforeOutbound = vi.fn<() => Promise<boolean | null>>()
|
||||
function render(status = 'RECEIVING', permissions = ['receive-overseas', 'ship-customer']) {
|
||||
const pinia = createPinia(); setActivePinia(pinia)
|
||||
const auth = useAuthStore(); auth.token = 'test'; auth.permissions = permissions.map(value => `platform:overseas-business:purchase:${value}`); useAccessPreviewStore().initializeAfterLogin()
|
||||
@@ -26,18 +26,15 @@ function render(status = 'RECEIVING', permissions = ['receive-overseas', 'ship-c
|
||||
}
|
||||
beforeEach(() => { vi.clearAllMocks(); beforeOutbound.mockResolvedValue(undefined); vi.mocked(submitProcurementWorkflow).mockResolvedValue(workflow()); vi.mocked(listOverseasPurchaseWarehouseOptions).mockResolvedValue([]) })
|
||||
describe('simplified procurement operations', () => {
|
||||
it('blocks the outbound dialog when fees are missing or not approved and permits retry after approval', async () => {
|
||||
it('allows outbound when the fee check reports missing or unreviewed details', async () => {
|
||||
const wrapper = render('CONFIRMED')
|
||||
const button = wrapper.findAll('button').find(button => button.text() === '创建出库单')!
|
||||
beforeOutbound.mockRejectedValueOnce(new Error('请先添加费用明细并审核通过后再出库'))
|
||||
await button.trigger('click'); await flushPromises()
|
||||
expect(wrapper.findComponent(AppDialog).props('modelValue')).toBe(false)
|
||||
expect(submitProcurementWorkflow).not.toHaveBeenCalled()
|
||||
beforeOutbound.mockRejectedValueOnce(new Error('费用明细尚未全部审核通过'))
|
||||
await button.trigger('click'); await flushPromises()
|
||||
expect(wrapper.findComponent(AppDialog).props('modelValue')).toBe(false)
|
||||
beforeOutbound.mockResolvedValueOnce(true)
|
||||
await button.trigger('click'); await flushPromises()
|
||||
expect(wrapper.findComponent(AppDialog).props('modelValue')).toBe(true)
|
||||
await button.trigger('click'); await flushPromises()
|
||||
expect(wrapper.findComponent(AppDialog).props('modelValue')).toBe(true)
|
||||
expect(beforeOutbound).toHaveBeenCalledTimes(2)
|
||||
})
|
||||
it('gates receipt and outbound actions with the existing operation permissions', () => {
|
||||
const receipt = render('RECEIVING', [])
|
||||
|
||||
Reference in New Issue
Block a user