mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-12 17:51:22 +00:00
test: avoid plugin fallback in agents tests
This commit is contained in:
@@ -1,21 +1,12 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
vi.unmock("../../plugins/provider-runtime.js");
|
||||
vi.unmock("../../plugins/provider-runtime.runtime.js");
|
||||
vi.mock("../../plugins/provider-runtime.js", () => ({
|
||||
resolveProviderCacheTtlEligibility: () => undefined,
|
||||
}));
|
||||
|
||||
let isCacheTtlEligibleProvider: typeof import("./cache-ttl.js").isCacheTtlEligibleProvider;
|
||||
import { isCacheTtlEligibleProvider } from "./cache-ttl.js";
|
||||
|
||||
describe("kilocode cache-ttl eligibility", () => {
|
||||
beforeEach(async () => {
|
||||
vi.doUnmock("../../plugins/provider-runtime.js");
|
||||
vi.doUnmock("../../plugins/provider-runtime.runtime.js");
|
||||
vi.resetModules();
|
||||
const { resetProviderRuntimeHookCacheForTest } =
|
||||
await import("../../plugins/provider-runtime.js");
|
||||
resetProviderRuntimeHookCacheForTest();
|
||||
({ isCacheTtlEligibleProvider } = await import("./cache-ttl.js"));
|
||||
});
|
||||
|
||||
it("allows anthropic models", () => {
|
||||
for (const modelId of ["anthropic/claude-opus-4.6", "anthropic/claude-sonnet-4"] as const) {
|
||||
expect(isCacheTtlEligibleProvider("kilocode", modelId)).toBe(true);
|
||||
|
||||
@@ -141,6 +141,7 @@ describe("subagent registry seam flow", () => {
|
||||
mod.__testing.setDepsForTest({
|
||||
callGateway: mocks.callGateway,
|
||||
captureSubagentCompletionReply: mocks.captureSubagentCompletionReply,
|
||||
cleanupBrowserSessionsForLifecycleEnd: async () => {},
|
||||
onAgentEvent: mocks.onAgentEvent,
|
||||
persistSubagentRunsToDisk: mocks.persistSubagentRunsToDisk,
|
||||
resolveAgentTimeoutMs: mocks.resolveAgentTimeoutMs,
|
||||
|
||||
@@ -1,5 +1,18 @@
|
||||
import { parseThreadSessionSuffix } from "../sessions/session-key-utils.js";
|
||||
import { createTestRegistry } from "./channel-plugins.js";
|
||||
|
||||
function resolveGenericSessionConversation(params: { rawId: string }) {
|
||||
const parsed = parseThreadSessionSuffix(params.rawId);
|
||||
const id = parsed.baseSessionKey ?? params.rawId;
|
||||
return {
|
||||
id,
|
||||
threadId: parsed.threadId,
|
||||
baseConversationId: id,
|
||||
parentConversationCandidates:
|
||||
parsed.threadId && parsed.baseSessionKey ? [parsed.baseSessionKey] : [],
|
||||
};
|
||||
}
|
||||
|
||||
function resolveTelegramSessionConversation(params: { kind: "group" | "channel"; rawId: string }) {
|
||||
if (params.kind !== "group") {
|
||||
return null;
|
||||
@@ -52,6 +65,7 @@ export function createSessionConversationTestRegistry() {
|
||||
},
|
||||
capabilities: { chatTypes: ["direct", "channel", "thread"] },
|
||||
messaging: {
|
||||
resolveSessionConversation: resolveGenericSessionConversation,
|
||||
resolveSessionTarget: ({ id }: { id: string }) => `channel:${id}`,
|
||||
},
|
||||
config: {
|
||||
@@ -74,6 +88,7 @@ export function createSessionConversationTestRegistry() {
|
||||
},
|
||||
capabilities: { chatTypes: ["direct", "channel", "thread"] },
|
||||
messaging: {
|
||||
resolveSessionConversation: resolveGenericSessionConversation,
|
||||
resolveSessionTarget: ({ id }: { id: string }) => `channel:${id}`,
|
||||
},
|
||||
config: {
|
||||
@@ -96,6 +111,7 @@ export function createSessionConversationTestRegistry() {
|
||||
},
|
||||
capabilities: { chatTypes: ["direct", "channel", "thread"] },
|
||||
messaging: {
|
||||
resolveSessionConversation: resolveGenericSessionConversation,
|
||||
resolveSessionTarget: ({ id }: { id: string }) => `channel:${id}`,
|
||||
},
|
||||
config: {
|
||||
|
||||
Reference in New Issue
Block a user