mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 14:20:44 +00:00
test: trim process-backed agent assertions
This commit is contained in:
@@ -755,7 +755,7 @@ describe("exec backgrounded onUpdate suppression", () => {
|
||||
await execTool.execute(nextCallId(), { command }, undefined, onUpdateSpy);
|
||||
const callsAtExit = onUpdateSpy.mock.calls.length;
|
||||
// Allow a tick for any straggling stdout data events.
|
||||
await new Promise((r) => setTimeout(r, 50));
|
||||
await new Promise((r) => setTimeout(r, 5));
|
||||
expect(onUpdateSpy.mock.calls.length).toBe(callsAtExit);
|
||||
},
|
||||
isWin ? 10_000 : 5_000,
|
||||
@@ -782,8 +782,8 @@ describe("exec backgrounded onUpdate suppression", () => {
|
||||
onUpdateSpy,
|
||||
);
|
||||
const callsAtAbort = onUpdateSpy.mock.calls.length;
|
||||
// Allow extra time for any straggling stdout data events.
|
||||
await new Promise((r) => setTimeout(r, 100));
|
||||
// Allow a tick for any straggling stdout data events.
|
||||
await new Promise((r) => setTimeout(r, 5));
|
||||
// After abort, no new onUpdate calls should have been made.
|
||||
expect(onUpdateSpy.mock.calls.length).toBe(callsAtAbort);
|
||||
expect(result).toBeDefined();
|
||||
|
||||
@@ -266,7 +266,7 @@ describe("session MCP runtime", () => {
|
||||
const serverScriptPath = path.join(pluginRoot, "servers", "bundle-probe.mjs");
|
||||
await writeBundleProbeMcpServer(serverScriptPath, {
|
||||
startupCounterPath,
|
||||
startupDelayMs: 100,
|
||||
startupDelayMs: 10,
|
||||
pidPath,
|
||||
exitMarkerPath,
|
||||
});
|
||||
|
||||
@@ -1,35 +1,7 @@
|
||||
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
const state = vi.hoisted(() => ({
|
||||
normalizeModelRefMock: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock("../model-selection.js", async () => {
|
||||
const actual =
|
||||
await vi.importActual<typeof import("../model-selection.js")>("../model-selection.js");
|
||||
return {
|
||||
...actual,
|
||||
normalizeModelRef: (...args: Parameters<typeof actual.normalizeModelRef>) =>
|
||||
state.normalizeModelRefMock(...args),
|
||||
};
|
||||
});
|
||||
|
||||
let resolveModelFromRegistry: typeof import("./media-tool-shared.js").resolveModelFromRegistry;
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { resolveModelFromRegistry } from "./media-tool-shared.js";
|
||||
|
||||
describe("resolveModelFromRegistry", () => {
|
||||
beforeAll(async () => {
|
||||
({ resolveModelFromRegistry } = await import("./media-tool-shared.js"));
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
state.normalizeModelRefMock
|
||||
.mockReset()
|
||||
.mockImplementation((provider: string, model: string) => ({
|
||||
provider: provider.trim().toLowerCase(),
|
||||
model: model.trim().replace(/^ollama\//, ""),
|
||||
}));
|
||||
});
|
||||
|
||||
it("normalizes provider and model refs before registry lookup", () => {
|
||||
const foundModel = { provider: "ollama", id: "qwen3.5:397b-cloud" };
|
||||
const find = vi.fn(() => foundModel);
|
||||
@@ -37,13 +9,9 @@ describe("resolveModelFromRegistry", () => {
|
||||
const result = resolveModelFromRegistry({
|
||||
modelRegistry: { find },
|
||||
provider: " OLLAMA ",
|
||||
modelId: "ollama/qwen3.5:397b-cloud",
|
||||
modelId: " qwen3.5:397b-cloud ",
|
||||
});
|
||||
|
||||
expect(state.normalizeModelRefMock).toHaveBeenCalledWith(
|
||||
" OLLAMA ",
|
||||
"ollama/qwen3.5:397b-cloud",
|
||||
);
|
||||
expect(find).toHaveBeenCalledWith("ollama", "qwen3.5:397b-cloud");
|
||||
expect(result).toBe(foundModel);
|
||||
});
|
||||
@@ -55,7 +23,7 @@ describe("resolveModelFromRegistry", () => {
|
||||
resolveModelFromRegistry({
|
||||
modelRegistry: { find },
|
||||
provider: " OLLAMA ",
|
||||
modelId: "ollama/qwen3.5:397b-cloud",
|
||||
modelId: " qwen3.5:397b-cloud ",
|
||||
}),
|
||||
).toThrow("Unknown model: ollama/qwen3.5:397b-cloud");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user