perf: defer container workbench data loading
This commit is contained in:
@@ -111,18 +111,26 @@ describe('ContainerFeesPanel contract', () => {
|
||||
expect(listContainerCostDetails).not.toHaveBeenCalledWith('11', expect.anything())
|
||||
})
|
||||
|
||||
it('uses the summary container ID when fee rows are empty', async () => {
|
||||
it('does not request any Finance data when container fees are empty', async () => {
|
||||
vi.mocked(listContainerFees).mockResolvedValue([])
|
||||
await mountPanel(['firstleg:inbound:fee-detail:view'])
|
||||
expect(listContainerCostDetails).toHaveBeenCalledWith('11', '99')
|
||||
await mountPanel(['firstleg:inbound:fee-detail:view', 'platform:finance:settlement-ar:list', 'platform:finance:settlement-ap:list'])
|
||||
expect(listContainerCostDetails).not.toHaveBeenCalled()
|
||||
expect(listFinanceReceivableSettlements).not.toHaveBeenCalled()
|
||||
expect(listFinancePayableSettlements).not.toHaveBeenCalled()
|
||||
expect(getFinanceSettlement).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('uses the summary container ID when fee rows agree', async () => {
|
||||
it('loads Finance data only on an explicit single request when fee rows agree', async () => {
|
||||
vi.mocked(listContainerFees).mockResolvedValue([
|
||||
{ id: '1', loadingPlanId: '9', containerBookingId: '99', containerNo: null, feeItemId: '1', feeItemName: '费用A', direction: 'RECEIVABLE', supplierId: null, supplierName: null, supplierCategory: null, businessDate: '2026-08-12', amount: 10, currency: 'CNY', reviewStatus: 'PENDING', sourceStatus: 'ACTIVE', sourceVersion: 1, remark: null, reviewerName: null, reviewedAt: null, reviewReason: null },
|
||||
])
|
||||
await mountPanel(['firstleg:inbound:fee-detail:view'])
|
||||
const wrapper = await mountPanel(['firstleg:inbound:fee-detail:view', 'platform:finance:settlement-ar:list'])
|
||||
expect(listContainerCostDetails).not.toHaveBeenCalled()
|
||||
expect(listFinanceReceivableSettlements).not.toHaveBeenCalled()
|
||||
await wrapper.findAll('button').find((button) => button.text() === '加载财务状态')!.trigger('click')
|
||||
await flushPromises()
|
||||
expect(listContainerCostDetails).toHaveBeenCalledWith('11', '99')
|
||||
expect(listFinanceReceivableSettlements).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('fails closed when fee rows disagree with the summary container', async () => {
|
||||
@@ -130,7 +138,9 @@ describe('ContainerFeesPanel contract', () => {
|
||||
{ id: '2', loadingPlanId: '9', containerBookingId: '100', containerNo: null, feeItemId: '2', feeItemName: '费用B', direction: 'PAYABLE', supplierId: '41', supplierName: '承运商A', supplierCategory: 'TRUCKING', businessDate: '2026-08-12', amount: 20, currency: 'CNY', reviewStatus: 'PENDING', sourceStatus: 'ACTIVE', sourceVersion: 1, remark: null, reviewerName: null, reviewedAt: null, reviewReason: null },
|
||||
])
|
||||
const wrapper = await mountPanel(['firstleg:inbound:fee-detail:view', 'firstleg:fee-item:view'])
|
||||
expect(wrapper.text()).toContain('柜次费用加载失败')
|
||||
await wrapper.findAll('button').find((button) => button.text() === '加载财务状态')!.trigger('click')
|
||||
await flushPromises()
|
||||
expect(wrapper.text()).toContain('财务状态加载失败')
|
||||
expect(listContainerCostDetails).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
@@ -161,6 +171,8 @@ describe('ContainerFeesPanel contract', () => {
|
||||
'firstleg:inbound:fee-detail:view', 'firstleg:inbound:fee-detail:edit', 'firstleg:inbound:fee-detail:review',
|
||||
'platform:finance:settlement-ar:list',
|
||||
])
|
||||
await wrapper.findAll('button').find((button) => button.text() === '加载财务状态')!.trigger('click')
|
||||
await flushPromises()
|
||||
expect(wrapper.findAll('button').some((button) => button.text() === '调整')).toBe(false)
|
||||
expect(wrapper.findAll('button').some((button) => button.text() === '作废')).toBe(false)
|
||||
expect(getFinanceSettlement).toHaveBeenCalledWith('ar-1')
|
||||
|
||||
Reference in New Issue
Block a user