fix(doctor): repair googlechat open dm wildcard auto-fix

This commit is contained in:
Sebastian
2026-02-16 21:25:16 -05:00
parent 81741c37fd
commit f7e75d2c5c
3 changed files with 172 additions and 19 deletions

View File

@@ -346,4 +346,103 @@ describe("doctor config flow", () => {
};
expect(cfg.channels.discord.accounts.work.allowFrom).toEqual(["*"]);
});
it("repairs googlechat dm.policy open by setting dm.allowFrom on repair", async () => {
const result = await runDoctorConfigWithInput({
repair: true,
config: {
channels: {
googlechat: {
dm: {
policy: "open",
},
},
},
},
});
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();
});
it("repairs googlechat account dm.policy open by setting dm.allowFrom on repair", async () => {
const result = await runDoctorConfigWithInput({
repair: true,
config: {
channels: {
googlechat: {
accounts: {
work: {
dm: {
policy: "open",
},
},
},
},
},
},
});
const cfg = result.cfg as unknown as {
channels: {
googlechat: {
accounts: {
work: {
dm: {
policy: string;
allowFrom: string[];
};
allowFrom?: string[];
};
};
};
};
};
expect(cfg.channels.googlechat.accounts.work.dm.allowFrom).toEqual(["*"]);
expect(cfg.channels.googlechat.accounts.work.allowFrom).toBeUndefined();
});
it("recovers from stale googlechat top-level allowFrom by repairing dm.allowFrom", async () => {
const result = await runDoctorConfigWithInput({
repair: true,
config: {
channels: {
googlechat: {
allowFrom: ["*"],
dm: {
policy: "open",
},
},
},
},
});
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();
});
});