test: dedupe shared setup in channel and doctor config tests

This commit is contained in:
Peter Steinberger
2026-02-18 03:38:06 +00:00
parent d1ab852972
commit e57628165a
5 changed files with 62 additions and 114 deletions

View File

@@ -23,6 +23,19 @@ async function runDoctorConfigWithInput(params: {
});
}
function expectGoogleChatDmAllowFromRepaired(cfg: unknown) {
const typed = cfg as {
channels: {
googlechat: {
dm: { allowFrom: string[] };
allowFrom?: string[];
};
};
};
expect(typed.channels.googlechat.dm.allowFrom).toEqual(["*"]);
expect(typed.channels.googlechat.allowFrom).toBeUndefined();
}
describe("doctor config flow", () => {
it("preserves invalid config for doctor repairs", async () => {
const result = await runDoctorConfigWithInput({
@@ -361,20 +374,7 @@ describe("doctor config flow", () => {
},
});
const cfg = result.cfg as unknown as {
channels: {
googlechat: {
dm: {
policy: string;
allowFrom: string[];
};
allowFrom?: string[];
};
};
};
expect(cfg.channels.googlechat.dm.allowFrom).toEqual(["*"]);
expect(cfg.channels.googlechat.allowFrom).toBeUndefined();
expectGoogleChatDmAllowFromRepaired(result.cfg);
});
it("repairs googlechat account dm.policy open by setting dm.allowFrom on repair", async () => {
@@ -430,19 +430,6 @@ describe("doctor config flow", () => {
},
});
const cfg = result.cfg as unknown as {
channels: {
googlechat: {
dm: {
policy: string;
allowFrom: string[];
};
allowFrom?: string[];
};
};
};
expect(cfg.channels.googlechat.dm.allowFrom).toEqual(["*"]);
expect(cfg.channels.googlechat.allowFrom).toBeUndefined();
expectGoogleChatDmAllowFromRepaired(result.cfg);
});
});