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.

40 lines
1.2 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import { describe, expect, it } from "vitest";
import {
mapPageTextToErrorCode,
mapUrlToErrorCode,
} from "@/modules/rpa/error-mapper";
describe("error-mapper", () => {
it("无运力页 → CARRIER_NO_CAPACITY", () => {
expect(mapPageTextToErrorCode("No carriers available for this lane")).toBe(
"CARRIER_NO_CAPACITY",
);
});
it("不支持邮编 → ADDRESS_NOT_SUPPORTED", () => {
expect(mapPageTextToErrorCode("This zip code is not supported")).toBe(
"ADDRESS_NOT_SUPPORTED",
);
});
it("验证码 URL → RPA_CAPTCHA", () => {
expect(mapUrlToErrorCode("https://example.com/captcha")).toBe(
"RPA_CAPTCHA",
);
});
it("login URL 无凭据 → null由 adapter 判 STRUCT_CHANGE", () => {
delete process.env.MOTHERSHIP_EMAIL;
delete process.env.MOTHERSHIP_PASSWORD;
expect(mapUrlToErrorCode("https://example.com/login")).toBe(null);
});
it("login URL 有凭据 → PROVIDER_LOGIN_FAILED", () => {
process.env.MOTHERSHIP_EMAIL = "test@example.com";
process.env.MOTHERSHIP_PASSWORD = "secret";
expect(mapUrlToErrorCode("https://example.com/login")).toBe(
"PROVIDER_LOGIN_FAILED",
);
});
});