test: add doctor invalid default-account integration case

This commit is contained in:
Gustavo Madeira Santana
2026-03-03 03:20:01 -05:00
parent bf984f37fb
commit 8504d5cb84

View File

@@ -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",
);
});
});