You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
2.5 KiB
80 lines
2.5 KiB
import { describe, expect, it } from "vitest";
|
|
import {
|
|
buildCcApiFailureMessage,
|
|
ccContainerStatusLabel,
|
|
ccShipmentStatusLabel,
|
|
isContainerArrivedOrLater,
|
|
} from "@/constants/cc-api-codes";
|
|
import {
|
|
classifyCcFailure,
|
|
formatCcApiFailure,
|
|
formatCcCause,
|
|
formatCcContainerStatusReason,
|
|
} from "@/constants/error-copy";
|
|
|
|
describe("V1.73 CC status labels", () => {
|
|
it("maps container F_Status per V1.73", () => {
|
|
expect(ccContainerStatusLabel(0)).toBe("0-新单");
|
|
expect(ccContainerStatusLabel(20)).toBe("20-清关结束");
|
|
expect(ccContainerStatusLabel(60)).toBe("60-已到仓");
|
|
expect(ccContainerStatusLabel(65)).toBe("65-直送运输中");
|
|
expect(ccContainerStatusLabel(70)).toBe("70-已拆柜");
|
|
expect(ccContainerStatusLabel(80)).toBe("80-已还柜");
|
|
expect(isContainerArrivedOrLater(40)).toBe(false);
|
|
expect(isContainerArrivedOrLater(60)).toBe(true);
|
|
});
|
|
|
|
it("maps shipment Status including 22-已装车", () => {
|
|
expect(ccShipmentStatusLabel(20)).toBe("20-已出仓");
|
|
expect(ccShipmentStatusLabel(22)).toBe("22-已装车");
|
|
expect(ccShipmentStatusLabel(26)).toBe("26-运输中");
|
|
});
|
|
});
|
|
|
|
describe("formatCcApiFailure per interface", () => {
|
|
it("explains GetContainerList 400/410", () => {
|
|
expect(
|
|
formatCcApiFailure({
|
|
api: "GetContainerList",
|
|
code: 410,
|
|
info: "没有登录信息",
|
|
}),
|
|
).toMatch(/集装箱列表|没有登录信息|410/);
|
|
expect(
|
|
formatCcApiFailure({
|
|
api: "GetContainerList",
|
|
code: 400,
|
|
info: "查询条件无效",
|
|
}),
|
|
).toMatch(/集装箱列表|业务失败|查询条件/);
|
|
});
|
|
|
|
it("explains SaveContainer 400 with field reason", () => {
|
|
const msg = formatCcApiFailure({
|
|
api: "SaveContainer",
|
|
code: 400,
|
|
info: "以下字段未填写,不能保存:柜型",
|
|
});
|
|
expect(msg).toMatch(/集装箱数据导入|柜型/);
|
|
expect(classifyCcFailure(msg)).toBe("validation");
|
|
});
|
|
|
|
it("buildCcApiFailureMessage covers 500", () => {
|
|
expect(
|
|
buildCcApiFailureMessage({ api: "GetShipmentInfo", code: 500 }),
|
|
).toMatch(/集装箱货件信息|异常|500/);
|
|
});
|
|
|
|
it("formats gate reason with container status", () => {
|
|
expect(formatCcContainerStatusReason(60, "批量转仓")).toMatch(
|
|
/60-已到仓.*批量转仓/,
|
|
);
|
|
});
|
|
|
|
it("still rewrites legacy GetContainerList failed strings", () => {
|
|
expect(formatCcCause("GetContainerList failed: 410")).toMatch(
|
|
/没有登录|集装箱列表|410/,
|
|
);
|
|
});
|
|
});
|