test: verify diagnostics and session callbacks

This commit is contained in:
Shakker
2026-05-11 17:20:45 +01:00
parent 1f43e79a58
commit ac478b2c6a
5 changed files with 14 additions and 9 deletions

View File

@@ -20,7 +20,11 @@ describe("doctor include warning", () => {
});
expect(noteSpy).toHaveBeenCalledWith(
expect.stringContaining("$include paths must stay under:"),
[
"- $include paths must stay under: /tmp/openclaw-config",
'- Move shared include files under that directory and update to relative paths like "./shared/common.json".',
"- Error: Include path escapes config directory: /etc/passwd",
].join("\n"),
"Doctor warnings",
);
});

View File

@@ -104,6 +104,8 @@ describe("config.openFile", () => {
},
undefined,
);
expect(logGateway.warn).toHaveBeenCalledWith(expect.stringContaining("spawn xdg-open ENOENT"));
expect(logGateway.warn).toHaveBeenCalledWith(
"config.openFile failed path=/tmp/config.json: spawn xdg-open ENOENT",
);
});
});

View File

@@ -117,7 +117,10 @@ describe("resolveSessionKeyFromResolveParams", () => {
key: canonicalKey,
});
expect(hoisted.updateSessionStoreMock).toHaveBeenCalledWith(storePath, expect.any(Function));
expect(hoisted.updateSessionStoreMock).toHaveBeenCalledTimes(1);
const updateSessionStoreCall = hoisted.updateSessionStoreMock.mock.calls[0];
expect(updateSessionStoreCall?.[0]).toBe(storePath);
expect(typeof updateSessionStoreCall?.[1]).toBe("function");
expect(hoisted.listSessionsFromStoreMock).toHaveBeenCalledWith({
cfg: {},
storePath,

View File

@@ -626,9 +626,7 @@ describe("discoverOpenClawPlugins", () => {
discoverOpenClawPlugins({ env: buildDiscoveryEnv(stateDir) }),
);
expect(result.diagnostics.map((entry) => entry.message)).not.toContainEqual(
expect.stringContaining("pnpm install"),
);
expect(result.diagnostics.some((entry) => entry.message.includes("pnpm install"))).toBe(false);
});
it("does not treat repo-level live or test files as plugin entrypoints", () => {

View File

@@ -78,9 +78,7 @@ describe("hook correlation fields", () => {
await expect(run).resolves.toBeUndefined();
expect(logger.error).toHaveBeenCalledWith(
expect.stringContaining(
"[hooks] agent_end handler from plugin-a failed: timed out after 5ms",
),
"[hooks] agent_end handler from plugin-a failed: timed out after 5ms",
);
} finally {
vi.useRealTimers();