mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 13:20:43 +00:00
test(providers): share onboard smoke assertions
This commit is contained in:
40
test/helpers/plugins/provider-onboard.ts
Normal file
40
test/helpers/plugins/provider-onboard.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import {
|
||||
resolveAgentModelFallbackValues,
|
||||
resolveAgentModelPrimaryValue,
|
||||
} from "openclaw/plugin-sdk/provider-onboard";
|
||||
import { expect } from "vitest";
|
||||
import type { OpenClawConfig } from "../../../src/config/config.js";
|
||||
import { createConfigWithFallbacks, EXPECTED_FALLBACKS } from "./onboard-config.js";
|
||||
|
||||
export function expectProviderOnboardAllowlistAlias(params: {
|
||||
applyProviderConfig: (config: OpenClawConfig) => OpenClawConfig;
|
||||
modelRef: string;
|
||||
alias: string;
|
||||
}) {
|
||||
const withDefault = params.applyProviderConfig({});
|
||||
expect(Object.keys(withDefault.agents?.defaults?.models ?? {})).toContain(params.modelRef);
|
||||
|
||||
const withAlias = params.applyProviderConfig({
|
||||
agents: {
|
||||
defaults: {
|
||||
models: {
|
||||
[params.modelRef]: { alias: params.alias },
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(withAlias.agents?.defaults?.models?.[params.modelRef]?.alias).toBe(params.alias);
|
||||
}
|
||||
|
||||
export function expectProviderOnboardPrimaryAndFallbacks(params: {
|
||||
applyConfig: (config: OpenClawConfig) => OpenClawConfig;
|
||||
modelRef: string;
|
||||
}) {
|
||||
const cfg = params.applyConfig({});
|
||||
expect(resolveAgentModelPrimaryValue(cfg.agents?.defaults?.model)).toBe(params.modelRef);
|
||||
|
||||
const cfgWithFallbacks = params.applyConfig(createConfigWithFallbacks());
|
||||
expect(resolveAgentModelFallbackValues(cfgWithFallbacks.agents?.defaults?.model)).toEqual([
|
||||
...EXPECTED_FALLBACKS,
|
||||
]);
|
||||
}
|
||||
Reference in New Issue
Block a user