import { describe, expect, it } from "vitest"; import { AUTOMATION_CONDITION_BRANCHES_CONFIG_KEY, automationConditionBranchForParent, automationConditionBranches, withAutomationConditionBranch, } from "./automation-graph.js"; describe("automation condition edge metadata", () => { it("defaults legacy condition edges to the true branch", () => { expect(automationConditionBranchForParent({}, "condition")).toBe("true"); }); it("adds, reads and removes branch metadata without changing action config", () => { const configured = withAutomationConditionBranch({ titel: "Nachfassen" }, "condition", "false"); expect(configured).toEqual({ titel: "Nachfassen", [AUTOMATION_CONDITION_BRANCHES_CONFIG_KEY]: { condition: "false" } }); expect(automationConditionBranches(configured)).toEqual({ condition: "false" }); expect(automationConditionBranchForParent(configured, "condition")).toBe("false"); expect(withAutomationConditionBranch(configured, "condition", null)).toEqual({ titel: "Nachfassen" }); }); });