test(kilo): share config home fixtures (#17348)

This commit is contained in:
Vincent Koc
2026-12-06 09:30:11 +08:00
committed by GitHub
parent 613b66ba1c
commit 18e9f6d367
@@ -30,6 +30,13 @@ import { PRODUCT_IDENTITY } from "../../../src/identity.js";
import { clearClientLocationEnvironment } from "../../fixtures/clientEnvironment.js";
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
const createKiloHome = async (prefix: string) => {
const home = await createTestTempDirectory(prefix);
const root = join(home, ".config", "kilo");
await mkdir(root, { recursive: true });
return { home, root };
};
const platform = process.platform;
const command = currentClientRegistrationCommand({ platform });
@@ -84,9 +91,7 @@ it.each([
);
it("keeps comments, settings and other servers through setup and uninstall of kilo.jsonc", async () => {
const home = await createTestTempDirectory("rea-kilo-jsonc-");
const root = join(home, ".config", "kilo");
await mkdir(root, { recursive: true });
const { home, root } = await createKiloHome("rea-kilo-jsonc-");
const target = join(root, "kilo.jsonc");
await writeFile(
target,
@@ -126,9 +131,7 @@ it("keeps comments, settings and other servers through setup and uninstall of ki
});
it("selects the last present Kilo layer, as rea mcp add does", async () => {
const home = await createTestTempDirectory("rea-kilo-layers-");
const root = join(home, ".config", "kilo");
await mkdir(root, { recursive: true });
const { home, root } = await createKiloHome("rea-kilo-layers-");
await writeFile(join(root, "config.json"), "{}");
const legacy = join(home, ".kilocode");
await mkdir(legacy);
@@ -168,9 +171,7 @@ it("plans kilo.json in an empty KILO_CONFIG_DIR", async () => {
});
it("loads KILO_CONFIG above Kilo's root files and below its home folders", async () => {
const home = await createTestTempDirectory("rea-kilo-config-file-");
const root = join(home, ".config", "kilo");
await mkdir(root, { recursive: true });
const { home, root } = await createKiloHome("rea-kilo-config-file-");
await writeFile(join(root, "kilo.json"), "{}");
const explicit = join(home, "profiles", "kilo.json");
const environment = { KILO_CONFIG: explicit };
@@ -333,9 +334,7 @@ it("lets doctor and uninstall act on the Kilo layer rea mcp add wrote", async ()
});
it("reads KILO_CONFIG_CONTENT as Kilo's top read-only layer", async () => {
const home = await createTestTempDirectory("rea-kilo-inline-");
const root = join(home, ".config", "kilo");
await mkdir(root, { recursive: true });
const { home, root } = await createKiloHome("rea-kilo-inline-");
const target = join(root, "kilo.json");
const registered = JSON.stringify({
mcp: { rea: { type: "local", command, enabled: true } },
@@ -403,9 +402,7 @@ it("reads KILO_CONFIG_CONTENT as Kilo's top read-only layer", async () => {
});
it("refuses a setup write that KILO_CONFIG_CONTENT would override", async () => {
const home = await createTestTempDirectory("rea-kilo-inline-write-");
const root = join(home, ".config", "kilo");
await mkdir(root, { recursive: true });
const { home, root } = await createKiloHome("rea-kilo-inline-write-");
const target = join(root, "kilo.json");
const environment = { HOPPER_LAUNCHER_PATH: "/opt/first/hopper" };
const registered = JSON.stringify({
@@ -518,9 +515,7 @@ const uninstallKilo = async (home: string, environment: NodeJS.ProcessEnv) => {
};
it("refuses to uninstall when removal would expose a lower Kilo layer's unowned entry", async () => {
const home = await createTestTempDirectory("rea-kilo-uninstall-lower-");
const root = join(home, ".config", "kilo");
await mkdir(root, { recursive: true });
const { home, root } = await createKiloHome("rea-kilo-uninstall-lower-");
const lower = join(root, "kilo.json");
const unowned = JSON.stringify({
mcp: { rea: { type: "local", command: ["/opt/other/rea", "mcp"] } },
@@ -540,9 +535,7 @@ it("refuses to uninstall when removal would expose a lower Kilo layer's unowned
});
it("refuses to uninstall while KILO_CONFIG_CONTENT keeps REA's entry in effect", async () => {
const home = await createTestTempDirectory("rea-kilo-uninstall-inline-");
const root = join(home, ".config", "kilo");
await mkdir(root, { recursive: true });
const { home, root } = await createKiloHome("rea-kilo-uninstall-inline-");
const target = join(root, "kilo.json");
const owned = JSON.stringify({
mcp: { rea: { type: "local", command, enabled: true } },
@@ -665,9 +658,7 @@ it("leaves a stale Kilo registration KILO_CONFIG_CONTENT pins out of update main
});
it("maintains a stale Kilo registration whose KILO_CONFIG_CONTENT entry setup's refresh keeps", async () => {
const home = await createTestTempDirectory("rea-kilo-update-inline-kept-");
const root = join(home, ".config", "kilo");
await mkdir(root, { recursive: true });
const { home, root } = await createKiloHome("rea-kilo-update-inline-kept-");
await writeFile(
join(root, "kilo.json"),
JSON.stringify({
@@ -698,9 +689,9 @@ it("maintains a stale Kilo registration whose KILO_CONFIG_CONTENT entry setup's
});
it("leaves an aligned Kilo registration out of update maintenance when KILO_CONFIG_CONTENT adds what setup would not write", async () => {
const home = await createTestTempDirectory("rea-kilo-update-inline-aligned-");
const root = join(home, ".config", "kilo");
await mkdir(root, { recursive: true });
const { home, root } = await createKiloHome(
"rea-kilo-update-inline-aligned-",
);
await writeFile(
join(root, "kilo.json"),
JSON.stringify({ mcp: { rea: { type: "local", command, enabled: true } } }),
@@ -739,9 +730,7 @@ it("leaves an aligned Kilo registration out of update maintenance when KILO_CONF
});
it("reports a Kilo registration whose KILO_CONFIG_CONTENT differs only in a discovered provider path as needing setup", async () => {
const home = await createTestTempDirectory("rea-kilo-update-discovered-");
const root = join(home, ".config", "kilo");
await mkdir(root, { recursive: true });
const { home, root } = await createKiloHome("rea-kilo-update-discovered-");
await writeFile(
join(root, "kilo.json"),
JSON.stringify({ mcp: { rea: { type: "local", command, enabled: true } } }),
@@ -799,11 +788,9 @@ it("reports a Kilo registration whose KILO_CONFIG_CONTENT differs only in a disc
});
it("reports a Kilo registration whose matching KILO_CONFIG_CONTENT sets a discovered provider path as needing setup", async () => {
const home = await createTestTempDirectory(
const { home, root } = await createKiloHome(
"rea-kilo-update-discovered-match-",
);
const root = join(home, ".config", "kilo");
await mkdir(root, { recursive: true });
const hopper = "/opt/hopper/hopper";
await writeFile(
join(root, "kilo.json"),
@@ -843,9 +830,7 @@ it("reports a Kilo registration whose matching KILO_CONFIG_CONTENT sets a discov
});
it("leaves a Kilo file whose own launcher REA does not own out of update maintenance", async () => {
const home = await createTestTempDirectory("rea-kilo-update-foreign-file-");
const root = join(home, ".config", "kilo");
await mkdir(root, { recursive: true });
const { home, root } = await createKiloHome("rea-kilo-update-foreign-file-");
await writeFile(
join(root, "kilo.json"),
JSON.stringify({
@@ -871,9 +856,9 @@ it("leaves a Kilo file whose own launcher REA does not own out of update mainten
});
it("matches a discovered setting by Windows environment identity in KILO_CONFIG_CONTENT", async () => {
const home = await createTestTempDirectory("rea-kilo-update-discovered-win-");
const root = join(home, ".config", "kilo");
await mkdir(root, { recursive: true });
const { home, root } = await createKiloHome(
"rea-kilo-update-discovered-win-",
);
await writeFile(
join(root, "kilo.json"),
JSON.stringify({ mcp: { rea: { type: "local", command, enabled: true } } }),