mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 03:50:20 +00:00
test: dedupe plugin provider runtime status suites
This commit is contained in:
@@ -120,6 +120,38 @@ function expectWizardResolutionCount(params: {
|
||||
});
|
||||
}
|
||||
|
||||
function expectWizardCacheInvalidationCount(params: {
|
||||
provider: ProviderPlugin;
|
||||
config: { [key: string]: unknown };
|
||||
env: NodeJS.ProcessEnv;
|
||||
mutate: () => void;
|
||||
expectedCount?: number;
|
||||
}) {
|
||||
setResolvedProviders(params.provider);
|
||||
|
||||
resolveProviderWizardOptions(
|
||||
createWizardRuntimeParams({
|
||||
config: params.config,
|
||||
env: params.env,
|
||||
}),
|
||||
);
|
||||
|
||||
params.mutate();
|
||||
|
||||
resolveProviderWizardOptions(
|
||||
createWizardRuntimeParams({
|
||||
config: params.config,
|
||||
env: params.env,
|
||||
}),
|
||||
);
|
||||
|
||||
expectProviderResolutionCall({
|
||||
config: params.config,
|
||||
env: params.env,
|
||||
count: params.expectedCount ?? 2,
|
||||
});
|
||||
}
|
||||
|
||||
function expectProviderResolutionCall(params?: {
|
||||
config?: object;
|
||||
env?: NodeJS.ProcessEnv;
|
||||
@@ -341,23 +373,18 @@ describe("provider wizard boundaries", () => {
|
||||
});
|
||||
|
||||
it("invalidates the wizard cache when config or env contents change in place", () => {
|
||||
const provider = createSglangSetupProvider();
|
||||
const config = createSglangConfig();
|
||||
const env = createHomeEnv("-a");
|
||||
setResolvedProviders(provider);
|
||||
|
||||
expect(resolveProviderWizardOptions(createWizardRuntimeParams({ config, env }))).toHaveLength(
|
||||
1,
|
||||
);
|
||||
|
||||
config.plugins.allow = ["vllm"];
|
||||
env.OPENCLAW_HOME = "/tmp/openclaw-home-b";
|
||||
|
||||
expect(resolveProviderWizardOptions(createWizardRuntimeParams({ config, env }))).toHaveLength(
|
||||
1,
|
||||
);
|
||||
|
||||
expectProviderResolutionCall({ config, env, count: 2 });
|
||||
expectWizardCacheInvalidationCount({
|
||||
provider: createSglangSetupProvider(),
|
||||
config,
|
||||
env,
|
||||
mutate: () => {
|
||||
config.plugins.allow = ["vllm"];
|
||||
env.OPENCLAW_HOME = "/tmp/openclaw-home-b";
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it.each([
|
||||
@@ -403,20 +430,19 @@ describe("provider wizard boundaries", () => {
|
||||
});
|
||||
|
||||
it("invalidates provider-wizard snapshots when cache-control env values change in place", () => {
|
||||
const provider = createSglangSetupProvider();
|
||||
const config = {};
|
||||
const env = createHomeEnv("", {
|
||||
OPENCLAW_PLUGIN_DISCOVERY_CACHE_MS: "1000",
|
||||
});
|
||||
setResolvedProviders(provider);
|
||||
|
||||
resolveProviderWizardOptions(createWizardRuntimeParams({ config, env }));
|
||||
|
||||
env.OPENCLAW_PLUGIN_DISCOVERY_CACHE_MS = "5";
|
||||
|
||||
resolveProviderWizardOptions(createWizardRuntimeParams({ config, env }));
|
||||
|
||||
expectProviderResolutionCall({ config, env, count: 2 });
|
||||
expectWizardCacheInvalidationCount({
|
||||
provider: createSglangSetupProvider(),
|
||||
config,
|
||||
env,
|
||||
mutate: () => {
|
||||
env.OPENCLAW_PLUGIN_DISCOVERY_CACHE_MS = "5";
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("routes model-selected hooks only to the matching provider", async () => {
|
||||
|
||||
Reference in New Issue
Block a user