Files
cc-switch/tests/utils/claudeEditorOverlay.test.ts
T
Jason 146f3196fa feat(claude): add auto mode server-check toggle and default it off for gateways
Add a "Disable auto mode server check" quick toggle to the Claude
provider editor that writes CLAUDE_CODE_AUTO_MODE_SERVER=0, with a hint
explaining that third-party gateways cannot serve the check and that
official endpoints should leave it unchecked.

New Claude providers now get the key by default unless the preset is
official or a cloud provider, or the preset already sets it. The default
form (no live base yet) also goes through the overlay so the custom
provider starts with the same value.
2026-10-06 21:13:04 +08:00

37 lines
1.2 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { withClaudeGatewayDefaults } from "@/utils/claudeEditorOverlay";
describe("withClaudeGatewayDefaults", () => {
const gateway = { env: { ANTHROPIC_BASE_URL: "https://gw.example" } };
it.each(["third_party", "aggregator", "cn_official", "custom", undefined])(
"turns auto mode server checks off for %s providers",
(category) => {
expect(withClaudeGatewayDefaults(gateway, category)).toEqual({
env: {
ANTHROPIC_BASE_URL: "https://gw.example",
CLAUDE_CODE_AUTO_MODE_SERVER: "0",
},
});
},
);
it.each(["official", "cloud_provider"])(
"leaves %s providers on the default",
(category) => {
expect(withClaudeGatewayDefaults(gateway, category)).toBe(gateway);
},
);
it("keeps a value the preset sets itself", () => {
const preset = { env: { CLAUDE_CODE_AUTO_MODE_SERVER: "1" } };
expect(withClaudeGatewayDefaults(preset, "third_party")).toBe(preset);
});
it("adds env when the preset has none", () => {
expect(withClaudeGatewayDefaults({}, "custom")).toEqual({
env: { CLAUDE_CODE_AUTO_MODE_SERVER: "0" },
});
});
});