mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 07:20:43 +00:00
refactor: delete unused test helper code
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-types";
|
||||
import type { MockInstance } from "vitest";
|
||||
|
||||
export function createWhatsAppPollFixture() {
|
||||
const cfg = { marker: "resolved-cfg" } as OpenClawConfig;
|
||||
@@ -15,29 +14,3 @@ export function createWhatsAppPollFixture() {
|
||||
accountId: "work",
|
||||
};
|
||||
}
|
||||
|
||||
export function expectWhatsAppPollSent(
|
||||
sendPollWhatsApp: MockInstance,
|
||||
params: {
|
||||
cfg: OpenClawConfig;
|
||||
poll: { question: string; options: string[]; maxSelections: number };
|
||||
to?: string;
|
||||
accountId?: string;
|
||||
},
|
||||
) {
|
||||
const expected = [
|
||||
params.to ?? "+1555",
|
||||
params.poll,
|
||||
{
|
||||
verbose: false,
|
||||
accountId: params.accountId ?? "work",
|
||||
cfg: params.cfg,
|
||||
},
|
||||
];
|
||||
const actual = sendPollWhatsApp.mock.calls.at(-1);
|
||||
if (JSON.stringify(actual) !== JSON.stringify(expected)) {
|
||||
throw new Error(
|
||||
`Expected WhatsApp poll send ${JSON.stringify(expected)}, got ${JSON.stringify(actual)}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,52 +87,6 @@ export function buildOpenAICodexForwardCompatExpectation(
|
||||
};
|
||||
}
|
||||
|
||||
const GOOGLE_GEMINI_CLI_PRO_TEMPLATE_MODEL = {
|
||||
id: "gemini-3-pro-preview",
|
||||
name: "Gemini 3 Pro Preview (Cloud Code Assist)",
|
||||
provider: "google-gemini-cli",
|
||||
api: "google-gemini-cli",
|
||||
baseUrl: "https://cloudcode-pa.googleapis.com",
|
||||
reasoning: true,
|
||||
input: ["text", "image"] as const,
|
||||
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
||||
contextWindow: 200000,
|
||||
maxTokens: 64000,
|
||||
};
|
||||
|
||||
const GOOGLE_GEMINI_CLI_FLASH_TEMPLATE_MODEL = {
|
||||
id: "gemini-3-flash-preview",
|
||||
name: "Gemini 3 Flash Preview (Cloud Code Assist)",
|
||||
provider: "google-gemini-cli",
|
||||
api: "google-gemini-cli",
|
||||
baseUrl: "https://cloudcode-pa.googleapis.com",
|
||||
reasoning: false,
|
||||
input: ["text", "image"] as const,
|
||||
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
||||
contextWindow: 200000,
|
||||
maxTokens: 64000,
|
||||
};
|
||||
|
||||
export function mockGoogleGeminiCliProTemplateModel(discoverModelsMock: DiscoverModelsMock): void {
|
||||
mockTemplateModel(
|
||||
discoverModelsMock,
|
||||
"google-gemini-cli",
|
||||
"gemini-3-pro-preview",
|
||||
GOOGLE_GEMINI_CLI_PRO_TEMPLATE_MODEL,
|
||||
);
|
||||
}
|
||||
|
||||
export function mockGoogleGeminiCliFlashTemplateModel(
|
||||
discoverModelsMock: DiscoverModelsMock,
|
||||
): void {
|
||||
mockTemplateModel(
|
||||
discoverModelsMock,
|
||||
"google-gemini-cli",
|
||||
"gemini-3-flash-preview",
|
||||
GOOGLE_GEMINI_CLI_FLASH_TEMPLATE_MODEL,
|
||||
);
|
||||
}
|
||||
|
||||
export function resetMockDiscoverModels(discoverModelsMock: DiscoverModelsMock): void {
|
||||
vi.mocked(discoverModelsMock).mockReturnValue({
|
||||
find: vi.fn(() => null),
|
||||
|
||||
@@ -877,14 +877,6 @@ export const testModel = {
|
||||
input: ["text"],
|
||||
} as unknown as Model<Api>;
|
||||
|
||||
export const cacheTtlEligibleModel = {
|
||||
api: "anthropic",
|
||||
provider: "anthropic",
|
||||
compat: {},
|
||||
contextWindow: 8192,
|
||||
input: ["text"],
|
||||
} as unknown as Model<Api>;
|
||||
|
||||
const testAuthStorage = {
|
||||
getApiKey: async () => undefined,
|
||||
};
|
||||
|
||||
@@ -86,10 +86,6 @@ export function getDockerArg(args: string[], position: number): string {
|
||||
return args[DOCKER_FIRST_SCRIPT_ARG_INDEX + position - 1] ?? "";
|
||||
}
|
||||
|
||||
export function getDockerPathArg(args: string[]): string {
|
||||
return getDockerArg(args, 1);
|
||||
}
|
||||
|
||||
export function getScriptsFromCalls(): string[] {
|
||||
return mockedExecDockerRaw.mock.calls.map(([args]) => getDockerScript(args));
|
||||
}
|
||||
|
||||
@@ -23,20 +23,3 @@ export function createTranscriptFixtureSync(params: {
|
||||
);
|
||||
return { dir, transcriptPath };
|
||||
}
|
||||
|
||||
export function createMockSessionEntry(params: {
|
||||
transcriptPath: string;
|
||||
sessionId: string;
|
||||
canonicalKey?: string;
|
||||
cfg?: Record<string, unknown>;
|
||||
}) {
|
||||
return {
|
||||
cfg: params.cfg ?? {},
|
||||
storePath: path.join(path.dirname(params.transcriptPath), "sessions.json"),
|
||||
entry: {
|
||||
sessionId: params.sessionId,
|
||||
sessionFile: params.transcriptPath,
|
||||
},
|
||||
canonicalKey: params.canonicalKey ?? "main",
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
export const PROCESS_TEST_TIMEOUT_MS = {
|
||||
tiny: 25,
|
||||
short: 100,
|
||||
standard: 3_000,
|
||||
medium: 5_000,
|
||||
long: 10_000,
|
||||
extraLong: 15_000,
|
||||
} as const;
|
||||
|
||||
export const PROCESS_TEST_SCRIPT_DELAY_MS = {
|
||||
silentProcess: 120,
|
||||
streamingInterval: 1_800,
|
||||
streamingDuration: 9_000,
|
||||
} as const;
|
||||
|
||||
export const PROCESS_TEST_NO_OUTPUT_TIMEOUT_MS = {
|
||||
exec: 120,
|
||||
supervisor: 100,
|
||||
streamingAllowance: 6_000,
|
||||
} as const;
|
||||
Reference in New Issue
Block a user