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.
69 lines
2.0 KiB
69 lines
2.0 KiB
import { describe, expect, it } from "vitest";
|
|
import {
|
|
buildAlertPresentation,
|
|
formatCustomerAddressForAdmin,
|
|
formatSelectedAddressForAdmin,
|
|
resolveAlertRootCause,
|
|
} from "@/modules/alert/alert-presentation";
|
|
|
|
describe("alert-presentation", () => {
|
|
it("区分客户填写地址与联想确认地址", () => {
|
|
const addr = {
|
|
street: "123 Main St",
|
|
city: "Denver",
|
|
state: "CO",
|
|
zip: "80202",
|
|
formatted_address: "123 Main St, Denver, CO",
|
|
mothership_display_label: "123 Main St, Denver, CO 80202, USA",
|
|
};
|
|
expect(formatCustomerAddressForAdmin(addr)).toBe(
|
|
"123 Main St, Denver, CO, 80202",
|
|
);
|
|
expect(formatSelectedAddressForAdmin(addr)).toBe(
|
|
"123 Main St, Denver, CO 80202, USA",
|
|
);
|
|
});
|
|
|
|
it("将 browserType.launch 转为可读根因", () => {
|
|
const cause = resolveAlertRootCause("RPA_FAILED", {
|
|
reason: "browserType.launch: Executable doesn't exist",
|
|
});
|
|
expect(cause).toContain("无法启动浏览器");
|
|
expect(cause).not.toContain("{");
|
|
});
|
|
|
|
it("buildAlertPresentation 包含客户与货物字段", () => {
|
|
const presentation = buildAlertPresentation(
|
|
"RPA_FAILED",
|
|
{ reason: "test", customer_id: "CUST_001" },
|
|
{
|
|
customerId: "CUST_001",
|
|
pickupJson: {
|
|
street: "A",
|
|
city: "B",
|
|
state: "CO",
|
|
zip: "80000",
|
|
mothership_display_label: "A, B, CO",
|
|
},
|
|
deliveryJson: {
|
|
street: "C",
|
|
city: "D",
|
|
state: "MA",
|
|
zip: "02101",
|
|
mothership_display_label: "C, D, MA",
|
|
},
|
|
weightLb: 500,
|
|
palletCount: 2,
|
|
cargoType: "general_freight",
|
|
dimLIn: 48,
|
|
dimWIn: 40,
|
|
dimHIn: 48,
|
|
} as never,
|
|
);
|
|
expect(presentation.customer_id).toBe("CUST_001");
|
|
expect(presentation.pickup_customer).toContain("A");
|
|
expect(presentation.pickup_selected).toBe("A, B, CO");
|
|
expect(presentation.cargo_summary).toContain("2 托");
|
|
});
|
|
});
|