mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-12 15:30:39 +00:00
refactor(test): remove duplicate cron tool harnesses
This commit is contained in:
@@ -13,13 +13,12 @@ function createConnection(): AgentSideConnection {
|
||||
}
|
||||
|
||||
describe("acp prompt cwd prefix", () => {
|
||||
it("redacts home directory in prompt prefix", async () => {
|
||||
async function runPromptWithCwd(cwd: string) {
|
||||
const sessionStore = createInMemorySessionStore();
|
||||
const homeCwd = path.join(os.homedir(), "openclaw-test");
|
||||
sessionStore.createSession({
|
||||
sessionId: "session-1",
|
||||
sessionKey: "agent:main:main",
|
||||
cwd: homeCwd,
|
||||
cwd,
|
||||
});
|
||||
|
||||
const requestSpy = vi.fn(async (method: string) => {
|
||||
@@ -44,7 +43,11 @@ describe("acp prompt cwd prefix", () => {
|
||||
_meta: {},
|
||||
} as unknown as PromptRequest),
|
||||
).rejects.toThrow("stop-after-send");
|
||||
return requestSpy;
|
||||
}
|
||||
|
||||
it("redacts home directory in prompt prefix", async () => {
|
||||
const requestSpy = await runPromptWithCwd(path.join(os.homedir(), "openclaw-test"));
|
||||
expect(requestSpy).toHaveBeenCalledWith(
|
||||
"chat.send",
|
||||
expect.objectContaining({
|
||||
@@ -53,4 +56,15 @@ describe("acp prompt cwd prefix", () => {
|
||||
{ expectFinal: true },
|
||||
);
|
||||
});
|
||||
|
||||
it("keeps backslash separators when cwd uses them", async () => {
|
||||
const requestSpy = await runPromptWithCwd(`${os.homedir()}\\openclaw-test`);
|
||||
expect(requestSpy).toHaveBeenCalledWith(
|
||||
"chat.send",
|
||||
expect.objectContaining({
|
||||
message: expect.stringContaining("[Working directory: ~\\openclaw-test]"),
|
||||
}),
|
||||
{ expectFinal: true },
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
import { vi } from "vitest";
|
||||
import type { MockFn } from "../../test-utils/vitest-mock-fn.js";
|
||||
|
||||
export const callGatewayMock = vi.fn() as unknown as MockFn;
|
||||
|
||||
vi.mock("../../gateway/call.js", () => ({
|
||||
callGateway: (opts: unknown) => callGatewayMock(opts),
|
||||
}));
|
||||
|
||||
vi.mock("../agent-scope.js", () => ({
|
||||
resolveSessionAgentId: () => "agent-123",
|
||||
}));
|
||||
@@ -1,21 +0,0 @@
|
||||
import { vi } from "vitest";
|
||||
|
||||
type GatewayMockFn = ((opts: unknown) => unknown) & {
|
||||
mockReset: () => void;
|
||||
mockResolvedValue: (value: unknown) => void;
|
||||
};
|
||||
|
||||
export const callGatewayMock = vi.fn() as GatewayMockFn;
|
||||
|
||||
vi.mock("../../gateway/call.js", () => ({
|
||||
callGateway: (opts: unknown) => callGatewayMock(opts),
|
||||
}));
|
||||
|
||||
vi.mock("../agent-scope.js", () => ({
|
||||
resolveSessionAgentId: () => "agent-123",
|
||||
}));
|
||||
|
||||
export function resetCronToolGatewayMock() {
|
||||
callGatewayMock.mockReset();
|
||||
callGatewayMock.mockResolvedValue({ ok: true });
|
||||
}
|
||||
Reference in New Issue
Block a user