mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-27 04:47:03 -06:00
test: verify doctor and identity output
This commit is contained in:
@@ -120,7 +120,9 @@ describe("agents set-identity command", () => {
|
||||
|
||||
await agentsSetIdentityCommand({ workspace }, runtime);
|
||||
|
||||
expect(runtime.error).toHaveBeenCalledWith(expect.stringContaining("Multiple agents match"));
|
||||
expect(runtime.error).toHaveBeenCalledWith(
|
||||
`Multiple agents match ${workspace}: main, ops. Pass --agent to choose one.`,
|
||||
);
|
||||
expect(runtime.exit).toHaveBeenCalledWith(1);
|
||||
expect(configMocks.writeConfigFile).not.toHaveBeenCalled();
|
||||
});
|
||||
@@ -216,7 +218,9 @@ describe("agents set-identity command", () => {
|
||||
|
||||
await runIdentityCommandFromWorkspace(workspace);
|
||||
|
||||
expect(runtime.error).toHaveBeenCalledWith(expect.stringContaining("No identity data found"));
|
||||
expect(runtime.error).toHaveBeenCalledWith(
|
||||
`No identity data found in ${path.join(workspace, "IDENTITY.md")}.`,
|
||||
);
|
||||
expect(runtime.exit).toHaveBeenCalledWith(1);
|
||||
expect(configMocks.writeConfigFile).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -118,7 +118,7 @@ describe("maybeInstallDaemon", () => {
|
||||
});
|
||||
|
||||
expect(note).toHaveBeenCalledWith(
|
||||
expect.stringContaining("Gateway install blocked"),
|
||||
"Gateway service install failed: Gateway install blocked: gateway.auth.token SecretRef is configured but unresolved (boom). Fix gateway auth config/token input and rerun configure.",
|
||||
"Gateway",
|
||||
);
|
||||
expect(buildGatewayInstallPlan).not.toHaveBeenCalled();
|
||||
|
||||
@@ -17,7 +17,7 @@ describe("collectMissingExplicitDefaultAccountWarnings", () => {
|
||||
|
||||
const warnings = collectMissingExplicitDefaultAccountWarnings(cfg);
|
||||
expect(warnings).toEqual([
|
||||
expect.stringContaining("channels.telegram: multiple accounts are configured"),
|
||||
"- channels.telegram: multiple accounts are configured but no explicit default is set. Set channels.telegram.defaultAccount or add channels.telegram.accounts.default to avoid fallback routing.",
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -97,7 +97,7 @@ describe("collectMissingExplicitDefaultAccountWarnings", () => {
|
||||
|
||||
const warnings = collectMissingExplicitDefaultAccountWarnings(cfg);
|
||||
expect(warnings).toEqual([
|
||||
expect.stringContaining('channels.telegram: defaultAccount is set to "missing"'),
|
||||
'- channels.telegram: defaultAccount is set to "missing" but does not match configured accounts (alerts, work). Set channels.telegram.defaultAccount to one of these accounts, or add channels.telegram.accounts.default to avoid fallback routing.',
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
@@ -98,10 +98,12 @@ describe("root memory repair", () => {
|
||||
} as unknown as DoctorPrompter;
|
||||
|
||||
await noteWorkspaceMemoryHealth(cfg);
|
||||
expect(note).toHaveBeenCalledWith(
|
||||
expect.stringContaining("Split root durable memory"),
|
||||
"Workspace memory",
|
||||
);
|
||||
const detection = await detectRootMemoryFiles(tmpDir);
|
||||
const expectedWarning = formatRootMemoryFilesWarning(detection);
|
||||
if (!expectedWarning) {
|
||||
throw new Error("expected split root memory warning");
|
||||
}
|
||||
expect(note).toHaveBeenCalledWith(expectedWarning, "Workspace memory");
|
||||
note.mockClear();
|
||||
|
||||
await maybeRepairWorkspaceMemoryHealth({ cfg, prompter });
|
||||
@@ -113,9 +115,15 @@ describe("root memory repair", () => {
|
||||
const canonical = await fs.readFile(path.join(tmpDir, "MEMORY.md"), "utf8");
|
||||
expect(canonical).toContain("# Legacy");
|
||||
await expectPathMissing(path.join(tmpDir, "memory.md"));
|
||||
expect(note).toHaveBeenCalledWith(
|
||||
expect.stringContaining("Workspace memory root merged:"),
|
||||
"Doctor changes",
|
||||
expect(note).toHaveBeenCalledTimes(1);
|
||||
const repairMessage = String(note.mock.calls[0]?.[0] ?? "");
|
||||
const repairLines = repairMessage.split("\n");
|
||||
expect(repairLines[0]).toBe("Workspace memory root merged:");
|
||||
expect(repairLines).toContain(`- canonical: ${path.join(tmpDir, "MEMORY.md")}`);
|
||||
expect(repairLines).toContain(
|
||||
`- merged legacy content from: ${path.join(tmpDir, "memory.md")}`,
|
||||
);
|
||||
expect(repairLines).toContain(`- removed legacy file: ${path.join(tmpDir, "memory.md")}`);
|
||||
expect(note.mock.calls[0]?.[1]).toBe("Doctor changes");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -191,7 +191,7 @@ describe("promptCustomApiConfig", () => {
|
||||
await runPromptCustomApi(prompter);
|
||||
|
||||
expect(prompter.note).toHaveBeenCalledWith(
|
||||
expect.stringContaining("did not respond"),
|
||||
"This endpoint did not respond to OpenAI or Anthropic style requests.",
|
||||
"Endpoint detection",
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user