t3-code-android-nightly/.repos/alchemy-effect/packages/alchemy/test/Cli/NamespaceTree.test.ts
Julius Marminge 6f9cea00ae
chore(refs): sync Effect and Alchemy references to 4.0.1 and beta.80 (#16170)
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-05 13:22:30 -07:00

51 lines
1.8 KiB
TypeScript

import { buildNamespaceTree, flattenTree } from "@/Cli/NamespaceTree.ts";
import { describe, expect, test } from "alchemy-test";
import { createNode, replaceNode, updateNode } from "./PlanTestNodes.ts";
describe("NamespaceTree YAML properties", { tags: ["unit", "local"] }, () => {
test("does not attach details in compact mode", () => {
const [item] = flattenTree(
buildNamespaceTree([
updateNode({ config: { retries: 2 } }, { config: { retries: 3 } }),
]),
);
expect(item?.propertyYaml).toBeUndefined();
});
test("attaches safe structured YAML in detailed mode", () => {
const items = flattenTree(
buildNamespaceTree([
createNode({ config: { region: "iad" } }, "Api"),
updateNode({ retries: 2 }, { retries: 3 }, "Worker"),
]),
{ includePropertyYaml: true },
);
expect(
items.find((item) => item.id === "Api")?.propertyYaml?.lines,
).toEqual(["properties:", " config:", " region: iad"]);
expect(
items.find((item) => item.id === "Worker")?.propertyYaml?.lines,
).toEqual(["properties:", "- retries: 2", "+ retries: 3"]);
});
test("attaches drift details in compact mode", () => {
const node = updateNode({ value: "declared" }, { value: "declared" });
node.drift = {
expected: { value: "declared" },
actual: { value: "changed-out-of-band" },
};
const [item] = flattenTree(buildNamespaceTree([node]));
expect(item?.propertyYaml?.lines).toEqual([
"- value: declared",
"+ value: changed-out-of-band",
]);
});
test("represents non-property replacement details honestly", () => {
const [item] = flattenTree(
buildNamespaceTree([replaceNode({ name: "same" }, { name: "same" })]),
{ includePropertyYaml: true },
);
expect(item?.propertyYaml).toBeUndefined();
});
});