From 8504d5cb84e9f5a566e0fbeaa95c1ca15add8492 Mon Sep 17 00:00:00 2001 From: Gustavo Madeira Santana Date: Tue, 3 Mar 2026 03:20:01 -0500 Subject: [PATCH] test: add doctor invalid default-account integration case --- ...fault-account-bindings.integration.test.ts | 38 ++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) 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", + ); + }); });