|
|
import { describe, expect, it } from "vitest";
|
|
|
import {
|
|
|
flockFreightClassRpaLabels,
|
|
|
flockLocationRpaLabels,
|
|
|
flockPackagingRpaLabels,
|
|
|
FLOCK_LOCATION_RPA_LABELS,
|
|
|
FLOCK_PICKUP_SERVICE_RPA_LABELS,
|
|
|
FLOCK_DELIVERY_SERVICE_RPA_LABELS,
|
|
|
FLOCK_PICKUP_SERVICE_WEIGHT_LOCKED,
|
|
|
} from "@/lib/flock/logged-in-rpa-options";
|
|
|
import { FLOCK_LOCATION_TYPES } from "@/components/flock/flock-logged-in-quote-form";
|
|
|
import { validateFlockQuoteInput, defaultFlockPickupDate } from "@/modules/flock/validation";
|
|
|
|
|
|
describe("flock logged-in RPA options", () => {
|
|
|
it("Bags / Business with Dock / density 候选可匹配官网", () => {
|
|
|
expect(flockPackagingRpaLabels("bags")).toContain("Bags");
|
|
|
expect(flockLocationRpaLabels("business_with_dock")[0]).toBe(
|
|
|
"Business with Dock",
|
|
|
);
|
|
|
expect(flockFreightClassRpaLabels("density")[0]).toMatch(/density/i);
|
|
|
});
|
|
|
|
|
|
it("地点 RPA 候选与 UI 12 类型对齐且含 Military Base", () => {
|
|
|
const uiIds = FLOCK_LOCATION_TYPES.map((t) => t.id).sort();
|
|
|
const rpaIds = Object.keys(FLOCK_LOCATION_RPA_LABELS).sort();
|
|
|
expect(rpaIds).toEqual(uiIds);
|
|
|
expect(FLOCK_LOCATION_RPA_LABELS.limited_military[0]).toMatch(
|
|
|
/Military Base/i,
|
|
|
);
|
|
|
expect(FLOCK_LOCATION_RPA_LABELS).not.toHaveProperty("limited_grocery");
|
|
|
});
|
|
|
|
|
|
it("调度服务文案含 During pickup window / Must arrive by date", () => {
|
|
|
expect(FLOCK_PICKUP_SERVICE_RPA_LABELS.during_window[0]).toMatch(
|
|
|
/pickup window/i,
|
|
|
);
|
|
|
expect(FLOCK_DELIVERY_SERVICE_RPA_LABELS.must_arrive_by[0]).toMatch(
|
|
|
/Must arrive by date/i,
|
|
|
);
|
|
|
expect(FLOCK_PICKUP_SERVICE_WEIGHT_LOCKED.during_window).toBe(true);
|
|
|
expect(FLOCK_PICKUP_SERVICE_WEIGHT_LOCKED.standard_fcfs).toBe(false);
|
|
|
});
|
|
|
});
|
|
|
|
|
|
describe("validateFlockQuoteInput logged_in_quick", () => {
|
|
|
it("允许数量 2(小于匿名托盘下限 4)", () => {
|
|
|
const parsed = validateFlockQuoteInput({
|
|
|
request_id: "11111111-1111-4111-8111-111111111111",
|
|
|
customer_id: "CUST_001",
|
|
|
flock_input: {
|
|
|
form_mode: "logged_in_quick",
|
|
|
pickup_date: defaultFlockPickupDate(),
|
|
|
pickup_zip: "90248",
|
|
|
delivery_zip: "15222",
|
|
|
pallet_count: 2,
|
|
|
total_weight: { value: 500, unit: "lb" },
|
|
|
dimensions: { length: 48, width: 40, height: 48, unit: "in" },
|
|
|
packaging_type: "bags",
|
|
|
freight_class: "density",
|
|
|
description: "papers",
|
|
|
stackable: true,
|
|
|
pickup_location_type: "business_with_dock",
|
|
|
delivery_location_type: "business_with_dock",
|
|
|
},
|
|
|
});
|
|
|
expect(parsed.formMode).toBe("logged_in_quick");
|
|
|
expect(parsed.palletCount).toBe(2);
|
|
|
expect(parsed.packagingType).toBe("bags");
|
|
|
expect(parsed.description).toBe("papers");
|
|
|
expect(parsed.stackable).toBe(true);
|
|
|
});
|
|
|
});
|