This commit is contained in:
2026-09-01 20:41:30 +08:00
parent a9570a4dae
commit 73b229bb95
2 changed files with 30 additions and 27 deletions
@@ -69,27 +69,30 @@ describe('ContainerCustomsPanel', () => {
const wrapper = await render('READY_TO_START')
expect(wrapper.text()).toContain('开始报关')
expect(wrapper.text()).toContain('客户退税资料.pdf')
expect(wrapper.find('[aria-label="下载源资料 客户退税资料.pdf"]').exists()).toBe(true)
expect(buttonTexts(wrapper)).not.toContain('上传完成文件')
expect(buttonTexts(wrapper)).not.toContain('覆盖完成文件')
expect(wrapper.text()).toContain('客户退税资料')
expect(wrapper.text()).toContain('报关完成文件')
expect(wrapper.text()).not.toContain('客户报关资料')
expect(wrapper.find('[aria-label="下载客户退税资料 客户退税资料.pdf"]').exists()).toBe(true)
expect(buttonTexts(wrapper)).not.toContain('上传报关完成文件')
expect(buttonTexts(wrapper)).not.toContain('覆盖报关完成文件')
expect(buttonTexts(wrapper)).not.toContain('提交')
})
it('allows completion upload and overwrite only while DECLARING with manage permission', async () => {
let wrapper = await render('DECLARING', true, false)
expect(wrapper.text()).toContain('上传完成文件')
expect(wrapper.text()).toContain('上传报关完成文件')
expect(wrapper.text()).toContain('提交')
wrapper.unmount()
wrapper = await render('DECLARING', true, true)
expect(wrapper.text()).toContain('覆盖完成文件')
expect(wrapper.text()).toContain('覆盖报关完成文件')
expect(wrapper.text()).toContain('报关完成文件.pdf')
wrapper.unmount()
wrapper = await render('DECLARING', false, true)
expect(wrapper.text()).toContain('只读')
expect(buttonTexts(wrapper)).not.toContain('上传完成文件')
expect(buttonTexts(wrapper)).not.toContain('覆盖完成文件')
expect(buttonTexts(wrapper)).not.toContain('上传报关完成文件')
expect(buttonTexts(wrapper)).not.toContain('覆盖报关完成文件')
expect(buttonTexts(wrapper)).not.toContain('提交')
})
@@ -98,19 +101,19 @@ describe('ContainerCustomsPanel', () => {
expect(wrapper.text()).toContain('客户退税资料.pdf')
expect(wrapper.text()).toContain('报关完成文件.pdf')
expect(wrapper.text()).toContain('报关已完成,待其他离仓条件')
expect(buttonTexts(wrapper)).not.toContain('上传完成文件')
expect(buttonTexts(wrapper)).not.toContain('覆盖完成文件')
expect(buttonTexts(wrapper)).not.toContain('上传报关完成文件')
expect(buttonTexts(wrapper)).not.toContain('覆盖报关完成文件')
expect(buttonTexts(wrapper)).not.toContain('提交')
})
it('routes source and completion downloads independently by the long document id and original names', async () => {
const wrapper = await render('COMPLETED', false, true)
await wrapper.get('[aria-label="下载源资料 客户退税资料.pdf"]').trigger('click')
await wrapper.get('[aria-label="下载客户退税资料 客户退税资料.pdf"]').trigger('click')
await flushPromises()
expect(api.downloadSource).toHaveBeenCalledWith('2092438843630391407')
expect(api.downloadCompletion).not.toHaveBeenCalled()
await wrapper.get('[aria-label="下载完成文件 报关完成文件.pdf"]').trigger('click')
await wrapper.get('[aria-label="下载报关完成文件 报关完成文件.pdf"]').trigger('click')
await flushPromises()
expect(api.downloadCompletion).toHaveBeenCalledWith('2092438843630391407')
expect(HTMLAnchorElement.prototype.click).toHaveBeenCalledTimes(2)
@@ -122,7 +125,7 @@ describe('ContainerCustomsPanel', () => {
api.downloadSource.mockRejectedValueOnce(new ApiResponseError('文件不可用', 'CUSTOMS_FILE_404', 404, undefined, 'request-customs-download', 'trace-customs-download'))
const wrapper = await render('COMPLETED', false, true)
await wrapper.get('[aria-label="下载源资料 客户退税资料.pdf"]').trigger('click')
await wrapper.get('[aria-label="下载客户退税资料 客户退税资料.pdf"]').trigger('click')
await flushPromises()
expect(wrapper.text()).toContain('文件不可用')