


























@@ -295,6 +295,90 @@ describe("telegramPlugin gateway startup", () => {
295295expect(latestMonitorOptions().botInfo).toEqual(startupBotInfo);
296296});
297297298+it("deletes cached startup botInfo when the account token changes", async () => {
299+await useTempStateDir();
300+await writeCachedTelegramBotInfo({
301+accountId: "ops",
302+botToken: "123456:bad-token",
303+botInfo: startupBotInfo,
304+});
305+306+await telegramPlugin.lifecycle?.onAccountConfigChanged?.({
307+accountId: "ops",
308+prevCfg: createTelegramConfig("ops"),
309+nextCfg: createTelegramConfig("ops", { botToken: "123456:new-token" }),
310+});
311+312+await expect(
313+readCachedTelegramBotInfo({
314+accountId: "ops",
315+botToken: "123456:bad-token",
316+}),
317+).resolves.toBeNull();
318+});
319+320+it("keeps cached startup botInfo when unrelated Telegram config changes", async () => {
321+await useTempStateDir();
322+await writeCachedTelegramBotInfo({
323+accountId: "ops",
324+botToken: "123456:bad-token",
325+botInfo: startupBotInfo,
326+});
327+328+await telegramPlugin.lifecycle?.onAccountConfigChanged?.({
329+accountId: "ops",
330+prevCfg: createTelegramConfig("ops"),
331+nextCfg: createTelegramConfig("ops", { timeoutSeconds: 60 }),
332+});
333+334+await expect(
335+readCachedTelegramBotInfo({
336+accountId: "ops",
337+botToken: "123456:bad-token",
338+}),
339+).resolves.toMatchObject({ botInfo: startupBotInfo });
340+});
341+342+it("deletes cached startup botInfo when the account is removed", async () => {
343+await useTempStateDir();
344+await writeCachedTelegramBotInfo({
345+accountId: "ops",
346+botToken: "123456:bad-token",
347+botInfo: startupBotInfo,
348+});
349+350+await telegramPlugin.lifecycle?.onAccountRemoved?.({ accountId: "ops" });
351+352+await expect(
353+readCachedTelegramBotInfo({
354+accountId: "ops",
355+botToken: "123456:bad-token",
356+}),
357+).resolves.toBeNull();
358+});
359+360+it("deletes cached startup botInfo when logout clears the account token", async () => {
361+await useTempStateDir();
362+installTelegramRuntime();
363+await writeCachedTelegramBotInfo({
364+accountId: "ops",
365+botToken: "123456:bad-token",
366+botInfo: startupBotInfo,
367+});
368+369+await telegramPlugin.gateway?.logoutAccount?.({
370+accountId: "ops",
371+cfg: createTelegramConfig("ops"),
372+});
373+374+await expect(
375+readCachedTelegramBotInfo({
376+accountId: "ops",
377+botToken: "123456:bad-token",
378+}),
379+).resolves.toBeNull();
380+});
381+298382it("honors higher per-account timeoutSeconds for startup probe", async () => {
299383installTelegramRuntime();
300384probeTelegram.mockResolvedValue({
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。