A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode,DeepSeek Harness and more. Only official website: ccswitch.io
Rust ai-toolsclaude-codecodexdeepseek-harnessdesktop-appgrokgrokbuildhermeskimi-codemcpopen-sourceopencodepiprovider-managementrustskillsskills-managementtauriwsl-support
import { describe, expect, it } from "vitest";
import {
agyLiveConfigText,
parseAgyLiveConfig,
spliceAgyOwnedKeys,
} from "@/components/providers/forms/hooks/useAgyLiveConfig";
describe("Antigravity editor config.json", () => {
it("swaps in only the keys CC Switch owns and keeps their position", () => {
const text = JSON.stringify({
plugins: { a: true },
gateway: { url: "https://old.example" },
userSettings: { theme: "light" },
caCertPath: "/old.pem",
});
const next = parseAgyLiveConfig(
spliceAgyOwnedKeys(text, {
plugins: { a: false },
gateway: { url: "https://new.example" },
models: { defaultModelId: "m1" },
}),
);
expect(Object.keys(next ?? {})).toEqual([
"plugins",
"gateway",
"userSettings",
"models",
]);
// 用户在编辑器里的全局设置不被投影覆盖
expect(next?.plugins).toEqual({ a: true });
expect(next?.gateway).toEqual({ url: "https://new.example" });
expect(next?.caCertPath).toBeUndefined();
});
it("leaves text that is not a JSON object alone", () => {
expect(spliceAgyOwnedKeys("{ broken", { gateway: {} })).toBe("{ broken");
expect(parseAgyLiveConfig("[1]")).toBeNull();
});
it("reads the projection from a row", () => {
expect(agyLiveConfigText({ env: {} })).toBe("");
expect(agyLiveConfigText({ liveConfig: { a: 1 } })).toBe(
JSON.stringify({ a: 1 }, null, 2),
);
});
});