|
|
import { describe, expect, it } from "vitest";
|
|
|
import {
|
|
|
isCargoStateReady,
|
|
|
type CargoStateEvidence,
|
|
|
} from "@/workers/rpa/cargo-state";
|
|
|
|
|
|
describe("isCargoStateReady", () => {
|
|
|
it("hydrating:mounted 但无 interactive → not ready", () => {
|
|
|
const evidence: CargoStateEvidence = {
|
|
|
phase: "hydrating",
|
|
|
mountedCargoFields: [{ placeholder: "需要几个托盘?", ariaLabel: null }],
|
|
|
interactiveCargoFields: [],
|
|
|
blockedCargoFields: [
|
|
|
{
|
|
|
placeholder: "需要几个托盘?",
|
|
|
ariaLabel: null,
|
|
|
blockers: ["pointer_events_none"],
|
|
|
},
|
|
|
],
|
|
|
};
|
|
|
expect(isCargoStateReady(evidence)).toBe(false);
|
|
|
});
|
|
|
|
|
|
it("仅 interactive 非托盘字段 → not ready", () => {
|
|
|
const evidence: CargoStateEvidence = {
|
|
|
phase: "interactive",
|
|
|
mountedCargoFields: [{ placeholder: "长度", ariaLabel: null }],
|
|
|
interactiveCargoFields: [{ placeholder: "长度", ariaLabel: null }],
|
|
|
blockedCargoFields: [],
|
|
|
};
|
|
|
expect(isCargoStateReady(evidence)).toBe(false);
|
|
|
});
|
|
|
|
|
|
it("托盘 interactive → ready", () => {
|
|
|
const evidence: CargoStateEvidence = {
|
|
|
phase: "interactive",
|
|
|
mountedCargoFields: [{ placeholder: "需要几个托盘?", ariaLabel: null }],
|
|
|
interactiveCargoFields: [
|
|
|
{ placeholder: "需要几个托盘?", ariaLabel: null },
|
|
|
],
|
|
|
blockedCargoFields: [],
|
|
|
};
|
|
|
expect(isCargoStateReady(evidence)).toBe(true);
|
|
|
});
|
|
|
});
|