flow.test.ts 1.0 KB

12345678910111213141516171819202122
  1. import { describe, expect, it } from "vitest";
  2. import { matchesNode } from "@/lib/flow";
  3. import type { FlowNodeRecord } from "@/lib/types";
  4. const node: FlowNodeRecord = {
  5. id: "root-delivery:artifact", node_type: "artifact", phase: "phase-3",
  6. lane: "root-delivery", title: "RootDeliveryManifest", subtitle: "唯一冻结 Manifest",
  7. status: "frozen", agent_role: "worker", task_kind: "root-delivery", sequence: 1,
  8. x: 0, y: 0, width: 268, tags: ["sha256"], metrics: [],
  9. record: { model_name: "RootDeliveryManifestV1", schema_version: "root-delivery-manifest/v1", payload: {} },
  10. };
  11. describe("matchesNode", () => {
  12. it("searches business labels, exact task kinds and schema model names", () => {
  13. expect(matchesNode(node, "Manifest")).toBe(true);
  14. expect(matchesNode(node, "root-delivery")).toBe(true);
  15. expect(matchesNode(node, "sha256")).toBe(true);
  16. expect(matchesNode(node, "mysql grant")).toBe(false);
  17. });
  18. it("keeps all nodes when query is blank", () => expect(matchesNode(node, " ")).toBe(true));
  19. });