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.
chajia/__tests__/lib/flock/flock-checkout-store.test.ts

44 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 { toFlockCheckoutPublic } from "@/lib/flock/flock-checkout-store";
describe("toFlockCheckoutPublic", () => {
it("不暴露 screenshot_path,失败文案脱敏", () => {
const pub = toFlockCheckoutPublic({
quote_id: "q1",
status: "failed",
message: "TimeoutError: page.click",
screenshot_path: "/tmp/secret.png",
updated_at_ms: 1,
});
expect(pub).toEqual({
status: "failed",
stage: null,
preferred_tier: null,
selected_total: null,
message: "官网同步失败,请稍后重试",
});
expect(pub).not.toHaveProperty("screenshot_path");
});
it("done / processing 使用固定中文文案", () => {
expect(
toFlockCheckoutPublic({
quote_id: "q1",
status: "done",
message: "raw rpa ok",
preferred_tier: "flock_direct",
selected_total: 2034,
updated_at_ms: 1,
}).message,
).toBe("已在官网填齐详情(未支付)");
expect(
toFlockCheckoutPublic({
quote_id: "q1",
status: "processing",
message: "internal",
updated_at_ms: 1,
}).message,
).toMatch(/正在官网/);
});
});