fix: record customs results in Shanghai business time

This commit is contained in:
2026-09-29 15:45:37 +08:00
parent ae13afd3d7
commit 4ead51a5fe
2 changed files with 22 additions and 1 deletions
@@ -1,5 +1,6 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { http } from '@/shared/api/http'
import { recordClearanceResult, type DeclarationBatch } from './platformContainerCustoms'
import { completeAllBuyContainerCustoms, downloadContainerCustomsReceipt, downloadContainerCustomsDocument, getContainerCustoms, sendContainerCustomsToBroker, startContainerCustoms, uploadContainerCustomsReceipt } from './platformContainerCustoms'
const customs = {
@@ -14,6 +15,20 @@ const customs = {
describe('platform container customs API', () => {
beforeEach(() => vi.restoreAllMocks())
it('records domestic customs time in Shanghai even when UTC falls on the previous day', async () => {
vi.useFakeTimers()
try {
vi.setSystemTime(new Date('2026-09-29T16:30:00Z'))
const post = vi.spyOn(http, 'post').mockResolvedValue({ code: '200', data: { id: '1' } })
await recordClearanceResult({ id: '123', version: 1 } as DeclarationBatch, 'OTHER', 'test')
expect(post).toHaveBeenCalledWith('/platform/v1/customs/loading-plans/declaration-batches/123/results',
expect.objectContaining({ occurredAt: '2026-09-30T00:30:00', resultType: 'OTHER', resolution: 'test' }),
expect.objectContaining({ headers: { 'Idempotency-Key': expect.any(String) } }))
} finally {
vi.useRealTimers()
}
})
it('uses the frozen customs-v1 paths and preserves long ids as strings', async () => {
const get = vi.spyOn(http, 'get').mockResolvedValue({ code: '200', message: 'ok', data: customs })
const result = await getContainerCustoms('2092438843630391402')