describe('ocean bookings api',()=>{it('normalizes pagination and long ids',async()=>{vi.spyOn(http,'get').mockResolvedValueOnce({code:'200',message:'ok',data:{records:[{id: 123,customerId: 456,containers:[]}],page:'2',size:'20',total:'21',pages:'2'}});constresult=awaitlistOceanBookings({page: 1,size: 10});expect(result.page).toBe(2);expect(result.total).toBe(21);expect(result.records[0]?.id).toBe('123');expect(result.records[0]?.customerId).toBe('456')})
it('wraps writes with idempotency and expected version action payload',async()=>{constpost=vi.spyOn(http,'post').mockResolvedValue({code:'200',message:'ok',data:'id-1'});awaitcreateOceanBooking({expectedVersion: null,data:{customerId:'c1',customerName:'客户',parties:[],containerRequirements:[]}});expect(post.mock.calls[0]?.[2]).toMatchObject({headers:{'Idempotency-Key':expect.any(String)}});awaitperformOceanBookingAction('id-1','confirm',{expectedVersion: 3,reason:'ok'});expect(post.mock.calls[1]?.[0]).toContain('/id-1/confirm');expect(post.mock.calls[1]?.[1]).toEqual({expectedVersion: 3,reason:'ok'})})})