This commit is contained in:
2026-08-12 16:40:09 +08:00
parent d8bbfe05f3
commit a44fd5f235
12 changed files with 355 additions and 72 deletions
@@ -90,7 +90,7 @@ describe('InboundFeeDetailManager', () => {
})
it('keeps currency fixed to CNY in the form and write payload', async () => {
const wrapper = mountManager(['firstleg:inbound:fee-detail:view', 'firstleg:inbound:fee-detail:edit'])
const wrapper = mountManager(['firstleg:inbound:fee-detail:view', 'firstleg:inbound:fee-detail:edit', 'firstleg:fee-item:view'])
await flushPromises()
await wrapper.findAll('button').find((button) => button.text().includes('新增费用'))?.trigger('click')
await flushPromises()
@@ -105,4 +105,40 @@ describe('InboundFeeDetailManager', () => {
expect(wrapper.find('.fee-table-shell').exists()).toBe(true)
expect(wrapper.find('.detail-table-wrap').exists()).toBe(false)
})
it('loads RECEIVABLE fee items without requesting counterparties', async () => {
const wrapper = mountManager(['firstleg:inbound:fee-detail:view', 'firstleg:inbound:fee-detail:edit', 'firstleg:fee-item:view'])
await flushPromises()
await wrapper.findAll('button').find((button) => button.text().includes('新增费用'))?.trigger('click')
await flushPromises()
expect(listInboundFeeItemOptions).toHaveBeenCalledTimes(1)
expect(listInboundFeePartnerOptions).not.toHaveBeenCalled()
expect(document.body.textContent).toContain('缺少往来单位查看权限')
expect(document.body.textContent).toContain('应收费用不受影响')
})
it('does not expose the editor without fee-item view permission', async () => {
const wrapper = mountManager(['firstleg:inbound:fee-detail:view', 'firstleg:inbound:fee-detail:edit'])
await flushPromises()
expect(wrapper.findAll('button').some((button) => button.text().includes('新增费用'))).toBe(false)
expect(listInboundFeeItemOptions).not.toHaveBeenCalled()
})
it('keeps fee items usable when the independent counterparty request fails', async () => {
vi.mocked(listInboundFeeDetails).mockResolvedValue([{ ...pending, direction: 'PAYABLE', partnerId: '41', partnerName: '测试往来单位' }])
vi.mocked(listInboundFeePartnerOptions).mockRejectedValue(new ApiResponseError('往来单位不可用', 'A0403', 403, null, 'request-partner', 'trace-partner'))
const wrapper = mountManager([
'firstleg:inbound:fee-detail:view', 'firstleg:inbound:fee-detail:edit',
'firstleg:fee-item:view', 'platform:counterparty:list',
])
await flushPromises()
await wrapper.findAll('button').find((button) => button.text().includes('编辑'))?.trigger('click')
await flushPromises()
expect(listInboundFeeItemOptions).toHaveBeenCalledTimes(1)
expect(listInboundFeePartnerOptions).toHaveBeenCalledTimes(1)
expect(document.body.textContent).toContain('往来单位不可用')
expect(document.body.textContent).toContain('request-partner')
expect(document.body.textContent).toContain('trace-partner')
expect(document.querySelector('.fee-form .el-select')?.classList.contains('is-disabled')).toBe(false)
})
})