import { beforeEach, expect, it, vi } from 'vitest' const api = vi.hoisted(() => ({ get: vi.fn(), post: vi.fn() })) vi.mock('@/shared/api/http', async importOriginal => ({ ...await importOriginal(), http: api })) import { getProcurementWorkflow, submitProcurementWorkflow } from './procurementWorkflow' beforeEach(() => { vi.clearAllMocks(); api.get.mockResolvedValue({ code: '200', data: { orderNo: 'OP/1' } }); api.post.mockResolvedValue({ code: '200', data: { orderNo: 'OP/1' } }) }) it('scopes workflow and every batch operation to the exact order and customer', async () => { await getProcurementWorkflow('OP/1', '1001') expect(api.get).toHaveBeenCalledWith('/platform/v1/last-leg/overseas-procurements/OP%2F1/workflow', { params: { customerId: '1001' } }) for (const action of ['receipts', 'request-confirmation', 'outbounds', 'outbounds/9007199254740993/dispatch', 'outbounds/9007199254740993/complete']) { const command = { version: 3, idempotencyKey: 'retry-same-key' } await submitProcurementWorkflow('OP/1', '1001', action, command) expect(api.post).toHaveBeenLastCalledWith(`/platform/v1/last-leg/overseas-procurements/OP%2F1/${action}`, command, { params: { customerId: '1001' } }) } })