The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { describe, expect, test } from "@alchemy.run/test"; |
| 2 | import { buildNamespaceTree, flattenTree } from "@/Cli/NamespaceTree.ts"; |
| 3 | import { createNode, replaceNode, updateNode } from "./PlanTestNodes.ts"; |
| 4 | |
| 5 | describe("NamespaceTree YAML properties", { tags: ["unit", "local"] }, () => { |
| 6 | test("does not attach details in compact mode", () => { |
| 7 | const [item] = flattenTree( |
| 8 | buildNamespaceTree([updateNode({ config: { retries: 2 } }, { config: { retries: 3 } })]), |
| 9 | ); |
| 10 | expect(item?.propertyYaml).toBeUndefined(); |
| 11 | }); |
| 12 | |
| 13 | test("attaches safe structured YAML in detailed mode", () => { |
| 14 | const items = flattenTree( |
| 15 | buildNamespaceTree([ |
| 16 | createNode({ config: { region: "iad" } }, "Api"), |
| 17 | updateNode({ retries: 2 }, { retries: 3 }, "Worker"), |
| 18 | ]), |
| 19 | { includePropertyYaml: true }, |
| 20 | ); |
| 21 | expect(items.find((item) => item.id === "Api")?.propertyYaml?.lines).toEqual([ |
| 22 | "properties:", |
| 23 | " config:", |
| 24 | " region: iad", |
| 25 | ]); |
| 26 | expect(items.find((item) => item.id === "Worker")?.propertyYaml?.lines).toEqual([ |
| 27 | "properties:", |
| 28 | "- retries: 2", |
| 29 | "+ retries: 3", |
| 30 | ]); |
| 31 | }); |
| 32 | |
| 33 | test("attaches drift details in compact mode", () => { |
| 34 | const node = updateNode({ value: "declared" }, { value: "declared" }); |
| 35 | node.drift = { |
| 36 | expected: { value: "declared" }, |
| 37 | actual: { value: "changed-out-of-band" }, |
| 38 | }; |
| 39 | const [item] = flattenTree(buildNamespaceTree([node])); |
| 40 | expect(item?.propertyYaml?.lines).toEqual([ |
| 41 | "- value: declared", |
| 42 | "+ value: changed-out-of-band", |
| 43 | ]); |
| 44 | }); |
| 45 | |
| 46 | test("represents non-property replacement details honestly", () => { |
| 47 | const [item] = flattenTree( |
| 48 | buildNamespaceTree([replaceNode({ name: "same" }, { name: "same" })]), |
| 49 | { includePropertyYaml: true }, |
| 50 | ); |
| 51 | expect(item?.propertyYaml).toBeUndefined(); |
| 52 | }); |
| 53 | }); |