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.
61 lines
1.7 KiB
61 lines
1.7 KiB
import { describe, expect, it } from "vitest";
|
|
import {
|
|
evaluateBusinessReadyGates,
|
|
isBusinessReady,
|
|
} from "@/workers/rpa/quote-capture/quote-business-ready";
|
|
|
|
describe("quote business ready gates", () => {
|
|
const allOk = {
|
|
buttonEnabled: true,
|
|
cookieClear: true,
|
|
cargoLocked: true,
|
|
hydrationReady: true,
|
|
addressesLocked: true,
|
|
submitHitTestOk: true,
|
|
domStable: true,
|
|
};
|
|
|
|
it("全部闸门通过时 ready", () => {
|
|
const probe = evaluateBusinessReadyGates(allOk);
|
|
expect(isBusinessReady(probe)).toBe(true);
|
|
expect(probe.reasons).toHaveLength(0);
|
|
});
|
|
|
|
it("cookie 遮挡时 fail", () => {
|
|
const probe = evaluateBusinessReadyGates({
|
|
...allOk,
|
|
cookieClear: false,
|
|
submitHitTestOk: false,
|
|
});
|
|
expect(isBusinessReady(probe)).toBe(false);
|
|
expect(probe.reasons.some((r) => r.includes("Cookie"))).toBe(true);
|
|
});
|
|
|
|
it("cargo 未锁定时 fail", () => {
|
|
const probe = evaluateBusinessReadyGates({
|
|
...allOk,
|
|
cargoLocked: false,
|
|
});
|
|
expect(isBusinessReady(probe)).toBe(false);
|
|
expect(probe.reasons.some((r) => r.includes("货物"))).toBe(true);
|
|
});
|
|
|
|
it("按钮 disabled 时 fail", () => {
|
|
const probe = evaluateBusinessReadyGates({
|
|
...allOk,
|
|
buttonEnabled: false,
|
|
});
|
|
expect(isBusinessReady(probe)).toBe(false);
|
|
expect(probe.reasons.some((r) => r.includes("disabled"))).toBe(true);
|
|
});
|
|
|
|
it("地址未锁定时 fail", () => {
|
|
const probe = evaluateBusinessReadyGates({
|
|
...allOk,
|
|
addressesLocked: false,
|
|
});
|
|
expect(isBusinessReady(probe)).toBe(false);
|
|
expect(probe.reasons.some((r) => r.includes("地址"))).toBe(true);
|
|
});
|
|
});
|