mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-18 14:54:46 +00:00
test: guard mixed extension mock calls
This commit is contained in:
@@ -93,7 +93,7 @@ describe("createMattermostDirectChannelWithRetry", () => {
|
||||
expect(result.id).toBe("dm-channel-456");
|
||||
expect(mockFetch).toHaveBeenCalledTimes(2);
|
||||
expect(onRetry).toHaveBeenCalledTimes(1);
|
||||
const retryCall = onRetry.mock.calls[0];
|
||||
const retryCall = onRetry.mock.calls.at(0);
|
||||
expect(retryCall?.[0]).toBe(1);
|
||||
expect(retryCall?.[1]).toBeGreaterThanOrEqual(10);
|
||||
expect(retryCall?.[1]).toBeLessThanOrEqual(20);
|
||||
|
||||
@@ -236,7 +236,7 @@ describe("mattermost websocket monitor", () => {
|
||||
post_id: "post-1",
|
||||
emoji_name: "thumbsup",
|
||||
});
|
||||
const payload = onReaction.mock.calls[0]?.[0];
|
||||
const payload = onReaction.mock.calls.at(0)?.[0];
|
||||
expect(payload).toEqual({
|
||||
event: "reaction_added",
|
||||
data: { reaction },
|
||||
|
||||
@@ -246,7 +246,7 @@ describe("mattermost setup", () => {
|
||||
}
|
||||
|
||||
expect(registerHttpRoute).toHaveBeenCalledTimes(1);
|
||||
const [route] = registerHttpRoute.mock.calls[0] ?? [];
|
||||
const [route] = registerHttpRoute.mock.calls.at(0) ?? [];
|
||||
expect(route?.path).toBe("/api/channels/mattermost/command");
|
||||
expect(route?.auth).toBe("plugin");
|
||||
expect(typeof route?.handler).toBe("function");
|
||||
|
||||
@@ -2249,7 +2249,7 @@ describe("short-term dreaming trigger", () => {
|
||||
const dreamsText = await fs.readFile(path.join(workspaceDir, "DREAMS.md"), "utf-8");
|
||||
expect(dreamsText).toContain("A diary entry.");
|
||||
});
|
||||
expect(subagent.run.mock.calls[0]?.[0]?.model).toBe("anthropic/claude-sonnet-4-6");
|
||||
expect(subagent.run.mock.calls.at(0)?.[0]?.model).toBe("anthropic/claude-sonnet-4-6");
|
||||
});
|
||||
|
||||
it("skips dreaming promotion cleanly when limit is zero", async () => {
|
||||
|
||||
@@ -411,7 +411,7 @@ describe("searchKeyword FTS MATCH fallback", () => {
|
||||
});
|
||||
|
||||
expect(warnSpy).toHaveBeenCalledTimes(1);
|
||||
const [warning] = warnSpy.mock.calls[0] ?? [];
|
||||
const [warning] = warnSpy.mock.calls.at(0) ?? [];
|
||||
expect(typeof warning).toBe("string");
|
||||
expect(
|
||||
(warning as string | undefined)?.startsWith(
|
||||
|
||||
@@ -448,7 +448,7 @@ describe("memory plugin e2e", () => {
|
||||
expect(providerOptions.provider).toBe("openai");
|
||||
expect(providerOptions.fallback).toBe("none");
|
||||
expect(providerOptions.model).toBe("text-embedding-3-small");
|
||||
expect(createProvider.mock.calls[0][0]).not.toHaveProperty("remote");
|
||||
expect(createProvider.mock.calls.at(0)?.[0]).not.toHaveProperty("remote");
|
||||
expect(embedQuery).toHaveBeenCalledWith("project memory");
|
||||
} finally {
|
||||
vi.doUnmock("openclaw/plugin-sdk/memory-core-host-engine-embeddings");
|
||||
|
||||
@@ -49,7 +49,7 @@ describe("memory-wiki plugin", () => {
|
||||
"wiki_get",
|
||||
]);
|
||||
expect(registerCli).toHaveBeenCalledTimes(1);
|
||||
expect(registerCli.mock.calls[0]?.[1]).toStrictEqual({
|
||||
expect(registerCli.mock.calls.at(0)?.[1]).toStrictEqual({
|
||||
descriptors: [
|
||||
{
|
||||
name: "wiki",
|
||||
|
||||
@@ -270,7 +270,7 @@ describe("nextcloud-talk send cfg threading", () => {
|
||||
accountId: "work",
|
||||
});
|
||||
expect(result?.receipt.platformMessageIds).toEqual(["22346"]);
|
||||
const mediaSendCall = fetchMock.mock.calls[1];
|
||||
const mediaSendCall = fetchMock.mock.calls.at(1);
|
||||
expect(mediaSendCall?.[0]).toBe(
|
||||
"https://nextcloud.example.com/ocs/v2.php/apps/spreed/api/v1/bot/abc123/message",
|
||||
);
|
||||
|
||||
@@ -1205,7 +1205,7 @@ function createControlledNdjsonFetch(): {
|
||||
}
|
||||
|
||||
function getGuardedFetchCall(fetchMock: typeof fetchWithSsrFGuardMock): GuardedFetchCall {
|
||||
return (fetchMock.mock.calls[0]?.[0] as GuardedFetchCall | undefined) ?? { url: "" };
|
||||
return (fetchMock.mock.calls.at(0)?.[0] as GuardedFetchCall | undefined) ?? { url: "" };
|
||||
}
|
||||
|
||||
async function createOllamaTestStream(params: {
|
||||
|
||||
@@ -119,7 +119,7 @@ describe("wsl2 crash-loop check", () => {
|
||||
await checkWsl2CrashLoopRisk(logger);
|
||||
|
||||
expect(logger.warn).toHaveBeenCalledTimes(1);
|
||||
const message = String(logger.warn.mock.calls[0]?.[0]);
|
||||
const message = String(logger.warn.mock.calls.at(0)?.[0]);
|
||||
expect(message).toContain("WSL2 crash-loop risk");
|
||||
expect(message).toContain("sudo systemctl disable ollama");
|
||||
expect(message).toContain("autoMemoryReclaim=disabled");
|
||||
|
||||
@@ -224,7 +224,7 @@ describe("openrouter provider hooks", () => {
|
||||
);
|
||||
|
||||
expect(baseStreamFn).toHaveBeenCalledOnce();
|
||||
const firstCall = baseStreamFn.mock.calls[0];
|
||||
const firstCall = baseStreamFn.mock.calls.at(0);
|
||||
const firstModel = firstCall?.[0];
|
||||
const compat = (firstModel as { compat?: { openRouterRouting?: { order?: unknown } } }).compat;
|
||||
expect(compat?.openRouterRouting?.order).toEqual(["moonshot"]);
|
||||
|
||||
@@ -90,7 +90,7 @@ describe("openrouter media understanding provider", () => {
|
||||
},
|
||||
}),
|
||||
);
|
||||
const headers = postJsonRequestMock.mock.calls[0]?.[0]?.headers as Headers;
|
||||
const headers = postJsonRequestMock.mock.calls.at(0)?.[0]?.headers as Headers;
|
||||
expect(headers.get("authorization")).toBe("Bearer sk-openrouter");
|
||||
expect(headers.get("http-referer")).toBe("https://openclaw.ai");
|
||||
expect(headers.get("x-openrouter-title")).toBe("OpenClaw");
|
||||
|
||||
@@ -227,7 +227,7 @@ describe("qa suite runtime flow", () => {
|
||||
|
||||
expect(result).toEqual({ api: "ok" });
|
||||
expect(createQaScenarioRuntimeApi).toHaveBeenCalledTimes(1);
|
||||
const call = createQaScenarioRuntimeApi.mock.calls[0]?.[0] as {
|
||||
const call = createQaScenarioRuntimeApi.mock.calls.at(0)?.[0] as {
|
||||
env: typeof env;
|
||||
scenario: typeof scenario;
|
||||
deps: {
|
||||
|
||||
Reference in New Issue
Block a user