mirror of https://github.com/openclaw/openclaw.git
test: debrand fallback and registry pin fixtures
This commit is contained in:
parent
c815bddce7
commit
634db43b3f
|
|
@ -6,23 +6,23 @@ import {
|
|||
} from "./fallback-state.js";
|
||||
|
||||
const baseAttempt = {
|
||||
provider: "fireworks",
|
||||
model: "fireworks/minimax-m2p5",
|
||||
error: "Provider fireworks is in cooldown (all profiles unavailable)",
|
||||
provider: "demo-primary",
|
||||
model: "demo-primary/model-a",
|
||||
error: "Provider demo-primary is in cooldown (all profiles unavailable)",
|
||||
reason: "rate_limit" as const,
|
||||
};
|
||||
|
||||
describe("fallback-state", () => {
|
||||
it("treats fallback as active only when state matches selected and active refs", () => {
|
||||
const state: FallbackNoticeState = {
|
||||
fallbackNoticeSelectedModel: "fireworks/minimax-m2p5",
|
||||
fallbackNoticeActiveModel: "deepinfra/moonshotai/Kimi-K2.5",
|
||||
fallbackNoticeSelectedModel: "demo-primary/model-a",
|
||||
fallbackNoticeActiveModel: "demo-fallback/model-b",
|
||||
fallbackNoticeReason: "rate limit",
|
||||
};
|
||||
|
||||
const resolved = resolveActiveFallbackState({
|
||||
selectedModelRef: "fireworks/minimax-m2p5",
|
||||
activeModelRef: "deepinfra/moonshotai/Kimi-K2.5",
|
||||
selectedModelRef: "demo-primary/model-a",
|
||||
activeModelRef: "demo-fallback/model-b",
|
||||
state,
|
||||
});
|
||||
|
||||
|
|
@ -32,14 +32,14 @@ describe("fallback-state", () => {
|
|||
|
||||
it("does not treat runtime drift as fallback when persisted state does not match", () => {
|
||||
const state: FallbackNoticeState = {
|
||||
fallbackNoticeSelectedModel: "anthropic/claude",
|
||||
fallbackNoticeActiveModel: "deepinfra/moonshotai/Kimi-K2.5",
|
||||
fallbackNoticeSelectedModel: "other-provider/other-model",
|
||||
fallbackNoticeActiveModel: "demo-fallback/model-b",
|
||||
fallbackNoticeReason: "rate limit",
|
||||
};
|
||||
|
||||
const resolved = resolveActiveFallbackState({
|
||||
selectedModelRef: "fireworks/minimax-m2p5",
|
||||
activeModelRef: "deepinfra/moonshotai/Kimi-K2.5",
|
||||
selectedModelRef: "demo-primary/model-a",
|
||||
activeModelRef: "demo-fallback/model-b",
|
||||
state,
|
||||
});
|
||||
|
||||
|
|
@ -49,10 +49,10 @@ describe("fallback-state", () => {
|
|||
|
||||
it("marks fallback transition when selected->active pair changes", () => {
|
||||
const resolved = resolveFallbackTransition({
|
||||
selectedProvider: "fireworks",
|
||||
selectedModel: "fireworks/minimax-m2p5",
|
||||
activeProvider: "deepinfra",
|
||||
activeModel: "moonshotai/Kimi-K2.5",
|
||||
selectedProvider: "demo-primary",
|
||||
selectedModel: "model-a",
|
||||
activeProvider: "demo-fallback",
|
||||
activeModel: "model-b",
|
||||
attempts: [baseAttempt],
|
||||
state: {},
|
||||
});
|
||||
|
|
@ -62,16 +62,16 @@ describe("fallback-state", () => {
|
|||
expect(resolved.fallbackCleared).toBe(false);
|
||||
expect(resolved.stateChanged).toBe(true);
|
||||
expect(resolved.reasonSummary).toBe("rate limit");
|
||||
expect(resolved.nextState.selectedModel).toBe("fireworks/minimax-m2p5");
|
||||
expect(resolved.nextState.activeModel).toBe("deepinfra/moonshotai/Kimi-K2.5");
|
||||
expect(resolved.nextState.selectedModel).toBe("demo-primary/model-a");
|
||||
expect(resolved.nextState.activeModel).toBe("demo-fallback/model-b");
|
||||
});
|
||||
|
||||
it("normalizes fallback reason whitespace for summaries", () => {
|
||||
const resolved = resolveFallbackTransition({
|
||||
selectedProvider: "fireworks",
|
||||
selectedModel: "fireworks/minimax-m2p5",
|
||||
activeProvider: "deepinfra",
|
||||
activeModel: "moonshotai/Kimi-K2.5",
|
||||
selectedProvider: "demo-primary",
|
||||
selectedModel: "model-a",
|
||||
activeProvider: "demo-fallback",
|
||||
activeModel: "model-b",
|
||||
attempts: [{ ...baseAttempt, reason: "rate_limit\n\tburst" }],
|
||||
state: {},
|
||||
});
|
||||
|
|
@ -81,14 +81,14 @@ describe("fallback-state", () => {
|
|||
|
||||
it("refreshes reason when fallback remains active with same model pair", () => {
|
||||
const resolved = resolveFallbackTransition({
|
||||
selectedProvider: "fireworks",
|
||||
selectedModel: "fireworks/minimax-m2p5",
|
||||
activeProvider: "deepinfra",
|
||||
activeModel: "moonshotai/Kimi-K2.5",
|
||||
selectedProvider: "demo-primary",
|
||||
selectedModel: "model-a",
|
||||
activeProvider: "demo-fallback",
|
||||
activeModel: "model-b",
|
||||
attempts: [{ ...baseAttempt, reason: "timeout" }],
|
||||
state: {
|
||||
fallbackNoticeSelectedModel: "fireworks/minimax-m2p5",
|
||||
fallbackNoticeActiveModel: "deepinfra/moonshotai/Kimi-K2.5",
|
||||
fallbackNoticeSelectedModel: "demo-primary/model-a",
|
||||
fallbackNoticeActiveModel: "demo-fallback/model-b",
|
||||
fallbackNoticeReason: "rate limit",
|
||||
},
|
||||
});
|
||||
|
|
@ -100,14 +100,14 @@ describe("fallback-state", () => {
|
|||
|
||||
it("marks fallback as cleared when runtime returns to selected model", () => {
|
||||
const resolved = resolveFallbackTransition({
|
||||
selectedProvider: "fireworks",
|
||||
selectedModel: "fireworks/minimax-m2p5",
|
||||
activeProvider: "fireworks",
|
||||
activeModel: "fireworks/minimax-m2p5",
|
||||
selectedProvider: "demo-primary",
|
||||
selectedModel: "model-a",
|
||||
activeProvider: "demo-primary",
|
||||
activeModel: "model-a",
|
||||
attempts: [],
|
||||
state: {
|
||||
fallbackNoticeSelectedModel: "fireworks/minimax-m2p5",
|
||||
fallbackNoticeActiveModel: "deepinfra/moonshotai/Kimi-K2.5",
|
||||
fallbackNoticeSelectedModel: "demo-primary/model-a",
|
||||
fallbackNoticeActiveModel: "demo-fallback/model-b",
|
||||
fallbackNoticeReason: "rate limit",
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ describe("channel registry pinning", () => {
|
|||
|
||||
it("preserves pinned channel registry across setActivePluginRegistry calls", () => {
|
||||
const startup = createEmptyPluginRegistry();
|
||||
startup.channels = [{ plugin: { id: "slack" } }] as never;
|
||||
startup.channels = [{ plugin: { id: "demo-channel" } }] as never;
|
||||
setActivePluginRegistry(startup);
|
||||
pinActivePluginChannelRegistry(startup);
|
||||
|
||||
|
|
@ -39,19 +39,19 @@ describe("channel registry pinning", () => {
|
|||
|
||||
it("re-pin invalidates cached channel lookups", () => {
|
||||
const setup = createEmptyPluginRegistry();
|
||||
const setupPlugin = { id: "slack", meta: {} } as never;
|
||||
const setupPlugin = { id: "demo-channel", meta: {} } as never;
|
||||
setup.channels = [{ plugin: setupPlugin }] as never;
|
||||
setActivePluginRegistry(setup);
|
||||
pinActivePluginChannelRegistry(setup);
|
||||
|
||||
expect(getChannelPlugin("slack")).toBe(setupPlugin);
|
||||
expect(getChannelPlugin("demo-channel")).toBe(setupPlugin);
|
||||
|
||||
const full = createEmptyPluginRegistry();
|
||||
const fullPlugin = { id: "slack", meta: {} } as never;
|
||||
const fullPlugin = { id: "demo-channel", meta: {} } as never;
|
||||
full.channels = [{ plugin: fullPlugin }] as never;
|
||||
setActivePluginRegistry(full);
|
||||
|
||||
expect(getChannelPlugin("slack")).toBe(setupPlugin);
|
||||
expect(getChannelPlugin("demo-channel")).toBe(setupPlugin);
|
||||
|
||||
const activeVersionBeforeRepin = getActivePluginRegistryVersion();
|
||||
const channelVersionBeforeRepin = getActivePluginChannelRegistryVersion();
|
||||
|
|
@ -59,7 +59,7 @@ describe("channel registry pinning", () => {
|
|||
|
||||
expect(getActivePluginRegistryVersion()).toBe(activeVersionBeforeRepin);
|
||||
expect(getActivePluginChannelRegistryVersion()).toBe(channelVersionBeforeRepin + 1);
|
||||
expect(getChannelPlugin("slack")).toBe(fullPlugin);
|
||||
expect(getChannelPlugin("demo-channel")).toBe(fullPlugin);
|
||||
});
|
||||
|
||||
it("updates channel registry on swap when not pinned", () => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue