From cff8e32aa4aca7beab82bdb80e7baab9d0777c27 Mon Sep 17 00:00:00 2001 From: Shakker Date: Mon, 11 May 2026 17:29:23 +0100 Subject: [PATCH] test: verify doctor and identity output --- src/commands/agents.identity.test.ts | 8 +++++-- src/commands/configure.daemon.test.ts | 2 +- ...w.missing-explicit-default-account.test.ts | 4 ++-- src/commands/doctor-workspace.test.ts | 22 +++++++++++++------ src/commands/onboard-custom.test.ts | 2 +- 5 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/commands/agents.identity.test.ts b/src/commands/agents.identity.test.ts index e5ef4d8bc93d..4f05e8896b09 100644 --- a/src/commands/agents.identity.test.ts +++ b/src/commands/agents.identity.test.ts @@ -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(); }); diff --git a/src/commands/configure.daemon.test.ts b/src/commands/configure.daemon.test.ts index 8c074ac7017b..29ef40434ca3 100644 --- a/src/commands/configure.daemon.test.ts +++ b/src/commands/configure.daemon.test.ts @@ -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(); diff --git a/src/commands/doctor-config-flow.missing-explicit-default-account.test.ts b/src/commands/doctor-config-flow.missing-explicit-default-account.test.ts index 6d896727ea97..d6a2068bcc7b 100644 --- a/src/commands/doctor-config-flow.missing-explicit-default-account.test.ts +++ b/src/commands/doctor-config-flow.missing-explicit-default-account.test.ts @@ -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.', ]); }); diff --git a/src/commands/doctor-workspace.test.ts b/src/commands/doctor-workspace.test.ts index 22ea81cd706d..a7eccfeabfb1 100644 --- a/src/commands/doctor-workspace.test.ts +++ b/src/commands/doctor-workspace.test.ts @@ -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"); }); }); diff --git a/src/commands/onboard-custom.test.ts b/src/commands/onboard-custom.test.ts index 95b8cc84b64a..45f0efc65971 100644 --- a/src/commands/onboard-custom.test.ts +++ b/src/commands/onboard-custom.test.ts @@ -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", ); });