diff --git a/src/commands/doctor-config-flow.missing-default-account-bindings.integration.test.ts b/src/commands/doctor-config-flow.missing-default-account-bindings.integration.test.ts index a5e0be54d97..bbfe3063b23 100644 --- a/src/commands/doctor-config-flow.missing-default-account-bindings.integration.test.ts +++ b/src/commands/doctor-config-flow.missing-default-account-bindings.integration.test.ts @@ -1,4 +1,4 @@ -import { describe, expect, it, vi } from "vitest"; +import { beforeEach, describe, expect, it, vi } from "vitest"; import { note } from "../terminal/note.js"; import { withEnvAsync } from "../test-utils/env.js"; import { runDoctorConfigWithInput } from "./doctor-config-flow.test-utils.js"; @@ -23,6 +23,10 @@ import { loadAndMaybeMigrateDoctorConfig } from "./doctor-config-flow.js"; const noteSpy = vi.mocked(note); describe("doctor missing default account binding warning", () => { + beforeEach(() => { + noteSpy.mockClear(); + }); + it("emits a doctor warning when named accounts have no valid account-scoped bindings", async () => { await withEnvAsync( { @@ -83,4 +87,36 @@ describe("doctor missing default account binding warning", () => { "Doctor warnings", ); }); + + it("emits a warning when defaultAccount does not match configured accounts", async () => { + await withEnvAsync( + { + TELEGRAM_BOT_TOKEN: undefined, + TELEGRAM_BOT_TOKEN_FILE: undefined, + }, + async () => { + await runDoctorConfigWithInput({ + config: { + channels: { + telegram: { + defaultAccount: "missing", + accounts: { + alerts: {}, + work: {}, + }, + }, + }, + }, + run: loadAndMaybeMigrateDoctorConfig, + }); + }, + ); + + expect(noteSpy).toHaveBeenCalledWith( + expect.stringContaining( + 'channels.telegram: defaultAccount is set to "missing" but does not match configured accounts', + ), + "Doctor warnings", + ); + }); });