mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 12:57:40 +00:00
test: dedupe repeated onboarding provider config cases
This commit is contained in:
@@ -298,9 +298,12 @@ describe("applyMinimaxApiConfig", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("applyMinimaxApiProviderConfig", () => {
|
describe("provider config helpers", () => {
|
||||||
it("does not overwrite existing primary model", () => {
|
it.each([
|
||||||
const cfg = applyMinimaxApiProviderConfig({
|
["applyMinimaxApiProviderConfig", applyMinimaxApiProviderConfig],
|
||||||
|
["applyZaiProviderConfig", applyZaiProviderConfig],
|
||||||
|
] as const)("%s does not overwrite existing primary model", (_name, applyConfig) => {
|
||||||
|
const cfg = applyConfig({
|
||||||
agents: { defaults: { model: { primary: "anthropic/claude-opus-4-5" } } },
|
agents: { defaults: { model: { primary: "anthropic/claude-opus-4-5" } } },
|
||||||
});
|
});
|
||||||
expectPrimaryModelPreserved(cfg);
|
expectPrimaryModelPreserved(cfg);
|
||||||
@@ -340,15 +343,6 @@ describe("applyZaiConfig", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("applyZaiProviderConfig", () => {
|
|
||||||
it("does not overwrite existing primary model", () => {
|
|
||||||
const cfg = applyZaiProviderConfig({
|
|
||||||
agents: { defaults: { model: { primary: "anthropic/claude-opus-4-5" } } },
|
|
||||||
});
|
|
||||||
expectPrimaryModelPreserved(cfg);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("applySyntheticConfig", () => {
|
describe("applySyntheticConfig", () => {
|
||||||
it("adds synthetic provider with correct settings", () => {
|
it("adds synthetic provider with correct settings", () => {
|
||||||
const cfg = applySyntheticConfig({});
|
const cfg = applySyntheticConfig({});
|
||||||
@@ -448,56 +442,38 @@ describe("applyXaiProviderConfig", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("applyOpencodeZenProviderConfig", () => {
|
describe("allowlist provider helpers", () => {
|
||||||
it("adds allowlist entry for the default model", () => {
|
it.each([
|
||||||
const cfg = applyOpencodeZenProviderConfig({});
|
{
|
||||||
expectAllowlistContains(cfg, "opencode/claude-opus-4-6");
|
name: "applyOpencodeZenProviderConfig",
|
||||||
});
|
applyConfig: applyOpencodeZenProviderConfig,
|
||||||
|
modelRef: "opencode/claude-opus-4-6",
|
||||||
|
alias: "My Opus",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "applyOpenrouterProviderConfig",
|
||||||
|
applyConfig: applyOpenrouterProviderConfig,
|
||||||
|
modelRef: OPENROUTER_DEFAULT_MODEL_REF,
|
||||||
|
alias: "Router",
|
||||||
|
},
|
||||||
|
] as const)(
|
||||||
|
"$name adds allowlist entry and preserves alias",
|
||||||
|
({ applyConfig, modelRef, alias }) => {
|
||||||
|
const withDefault = applyConfig({});
|
||||||
|
expectAllowlistContains(withDefault, modelRef);
|
||||||
|
|
||||||
it("preserves existing alias for the default model", () => {
|
const withAlias = applyConfig({
|
||||||
const cfg = applyOpencodeZenProviderConfig({
|
agents: {
|
||||||
agents: {
|
defaults: {
|
||||||
defaults: {
|
models: {
|
||||||
models: {
|
[modelRef]: { alias },
|
||||||
"opencode/claude-opus-4-6": { alias: "My Opus" },
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
});
|
||||||
});
|
expectAliasPreserved(withAlias, modelRef, alias);
|
||||||
expectAliasPreserved(cfg, "opencode/claude-opus-4-6", "My Opus");
|
},
|
||||||
});
|
);
|
||||||
});
|
|
||||||
|
|
||||||
describe("applyOpencodeZenConfig", () => {
|
|
||||||
it("sets correct primary model", () => {
|
|
||||||
const cfg = applyOpencodeZenConfig({});
|
|
||||||
expect(cfg.agents?.defaults?.model?.primary).toBe("opencode/claude-opus-4-6");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("preserves existing model fallbacks", () => {
|
|
||||||
const cfg = applyOpencodeZenConfig(createConfigWithFallbacks());
|
|
||||||
expectFallbacksPreserved(cfg);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("applyOpenrouterProviderConfig", () => {
|
|
||||||
it("adds allowlist entry for the default model", () => {
|
|
||||||
const cfg = applyOpenrouterProviderConfig({});
|
|
||||||
expectAllowlistContains(cfg, OPENROUTER_DEFAULT_MODEL_REF);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("preserves existing alias for the default model", () => {
|
|
||||||
const cfg = applyOpenrouterProviderConfig({
|
|
||||||
agents: {
|
|
||||||
defaults: {
|
|
||||||
models: {
|
|
||||||
[OPENROUTER_DEFAULT_MODEL_REF]: { alias: "Router" },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
expectAliasPreserved(cfg, OPENROUTER_DEFAULT_MODEL_REF, "Router");
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("applyLitellmProviderConfig", () => {
|
describe("applyLitellmProviderConfig", () => {
|
||||||
@@ -523,14 +499,26 @@ describe("applyLitellmProviderConfig", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("applyOpenrouterConfig", () => {
|
describe("default-model config helpers", () => {
|
||||||
it("sets correct primary model", () => {
|
it.each([
|
||||||
const cfg = applyOpenrouterConfig({});
|
{
|
||||||
expect(cfg.agents?.defaults?.model?.primary).toBe(OPENROUTER_DEFAULT_MODEL_REF);
|
name: "applyOpencodeZenConfig",
|
||||||
});
|
applyConfig: applyOpencodeZenConfig,
|
||||||
|
primaryModel: "opencode/claude-opus-4-6",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "applyOpenrouterConfig",
|
||||||
|
applyConfig: applyOpenrouterConfig,
|
||||||
|
primaryModel: OPENROUTER_DEFAULT_MODEL_REF,
|
||||||
|
},
|
||||||
|
] as const)(
|
||||||
|
"$name sets primary model and preserves existing model fallbacks",
|
||||||
|
({ applyConfig, primaryModel }) => {
|
||||||
|
const cfg = applyConfig({});
|
||||||
|
expect(cfg.agents?.defaults?.model?.primary).toBe(primaryModel);
|
||||||
|
|
||||||
it("preserves existing model fallbacks", () => {
|
const cfgWithFallbacks = applyConfig(createConfigWithFallbacks());
|
||||||
const cfg = applyOpenrouterConfig(createConfigWithFallbacks());
|
expectFallbacksPreserved(cfgWithFallbacks);
|
||||||
expectFallbacksPreserved(cfg);
|
},
|
||||||
});
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user