This commit is contained in:
2026-08-13 12:22:41 +08:00
parent 835ac0ad12
commit 8a8c4fa190
26 changed files with 572 additions and 148 deletions
@@ -29,12 +29,12 @@ const statement: FinanceStatementReadModel = {
const detail: FinanceReconciliationDetail = {
...statement, paidAmount: 100, periodStart: '2026-08-01', periodEnd: '2026-08-31', creditDays: 30, settled: false, remark: '八月账单',
createdBy: '创建人A', createdAt: '2026-08-01 09:00:00', updatedBy: '更新人B', updatedAt: '2026-08-20 11:00:00',
lines: [{ statementLineId: '601', sourceFeeId: '81', sourceFeeVersion: 2, orderId: '11', inboundId: '21', feeItemName: '运费', amount: 300 }],
lines: [{ statementLineId: '601', sourceFeeId: '81', sourceFeeVersion: 2, sourceHash: 'hash-81', orderId: '11', inboundId: '21', containerId: '31', feeItemName: '运费', sourceAmount: 320, amount: 300, adjustmentReason: '优惠调整' }],
paymentHistory: [{ transactionId: '701', transactionType: 'RECEIPT', transactionDate: '2026-08-20', amount: 100, method: 'BANK_TRANSFER', referenceNo: 'PAY-701', createdBy: '财务员', occurredAt: '2026-08-20 10:00:00' }],
revisions: [],
}
async function mountPage(permissions = ['platform:finance:bill:view']) {
async function mountPage(permissions = ['platform:finance:bill:view', 'platform:finance:fee-source:view']) {
const pinia = createPinia(); setActivePinia(pinia)
const auth = useAuthStore(); auth.token = 'token'; auth.permissions = permissions
useAccessPreviewStore().initializeAfterLogin()
@@ -75,6 +75,8 @@ describe('FinanceCustomerStatementsView', () => {
expect(document.body.textContent).toContain('CONT-31')
expect(document.body.textContent).toContain('IN-21')
expect(document.body.textContent).toContain('来源版本')
expect(document.body.textContent).toContain('hash-81')
expect(document.body.textContent).toContain('优惠调整')
expect(document.body.textContent).toContain('创建人A')
expect(document.body.textContent).toContain('2026-08-20 11:00:00')
expect(document.querySelector('.el-drawer')).toBeNull()
@@ -95,10 +97,11 @@ describe('FinanceCustomerStatementsView', () => {
expect(vm.filteredRows).toHaveLength(0)
})
it('exports the currently filtered real statement rows as CSV', async () => {
it('hydrates and exports the currently filtered real statement rows as CSV', async () => {
const clicked = vi.spyOn(HTMLAnchorElement.prototype, 'click').mockImplementation(() => {})
const wrapper = await mountPage()
;(wrapper.vm as unknown as { exportStatements(): void }).exportStatements()
await (wrapper.vm as unknown as { exportStatements(): Promise<void> }).exportStatements()
expect(getReconciliationStatement).toHaveBeenCalledWith('501')
expect(URL.createObjectURL).toHaveBeenCalledWith(expect.any(Blob))
expect(clicked).toHaveBeenCalledOnce()
})
@@ -112,6 +115,15 @@ describe('FinanceCustomerStatementsView', () => {
expect(listPlatformTenants).not.toHaveBeenCalled()
})
it('does not request fee-source details without its permission and keeps frozen trace fields visible', async () => {
const wrapper = await mountPage(['platform:finance:bill:view'])
await (wrapper.vm as unknown as { openDetail(row: FinanceStatementReadModel): Promise<void> }).openDetail(statement)
await flushPromises()
expect(getFinanceFeeSource).not.toHaveBeenCalled()
expect(document.body.textContent).toContain('柜次ID 31')
expect(document.body.textContent).toContain('hash-81')
})
it('surfaces detail hydration failures instead of silently returning an empty filtered list', async () => {
const wrapper = await mountPage()
vi.mocked(getReconciliationStatement).mockRejectedValueOnce(new Error('detail unavailable'))
@@ -119,4 +131,14 @@ describe('FinanceCustomerStatementsView', () => {
await flushPromises()
expect(document.body.textContent).toContain('筛选字段加载失败')
})
it('keeps the failed selected row visible and exposes a detail retry state', async () => {
const wrapper = await mountPage()
vi.mocked(getReconciliationStatement).mockRejectedValueOnce(new Error('detail unavailable'))
await (wrapper.vm as unknown as { openDetail(row: FinanceStatementReadModel): Promise<void> }).openDetail(statement)
await flushPromises()
expect(document.body.textContent).toContain('已选择 1 项')
expect(document.body.textContent).toContain('明细加载失败')
expect(document.body.textContent).toContain('重试')
})
})