import { describe, expect, it, vi } from "vitest";
import type { Page } from "playwright";

const calls: string[] = [];

vi.mock("@/workers/rpa/kernel/steps/cargo-step", () => ({
  fillCargoStep: vi.fn(async () => {
    calls.push("cargo-step");
  }),
}));

import { fillCargo } from "@/workers/rpa/mothership";
import { fillCargoStep } from "@/workers/rpa/kernel/steps/cargo-step";

const probeReq = {
  cargoHash: "t",
  pickup: {} as never,
  delivery: {} as never,
  weightLb: 500,
  dimsIn: { l: 48, w: 40, h: 48 },
  palletCount: 2,
  cargoType: "general_freight",
};

describe("fillCargo thin wrapper", () => {
  it("委托 kernel fillCargoStep", async () => {
    calls.length = 0;
    await fillCargo({} as Page, probeReq);
    expect(calls).toEqual(["cargo-step"]);
    expect(fillCargoStep).toHaveBeenCalled();
  });
});
