@@ -5,6 +5,41 @@ import type { PluginManifestRecord } from "../../../plugins/manifest-registry.js
|
5 | 5 | import * as manifestRegistry from "../../../plugins/manifest-registry.js"; |
6 | 6 | import { collectDoctorPreviewWarnings } from "./preview-warnings.js"; |
7 | 7 | |
| 8 | +vi.mock("../channel-capabilities.js", () => { |
| 9 | +const fallback = { |
| 10 | +dmAllowFromMode: "topOnly", |
| 11 | +groupModel: "sender", |
| 12 | +groupAllowFromFallbackToAllowFrom: true, |
| 13 | +warnOnEmptyGroupSenderAllowlist: true, |
| 14 | +}; |
| 15 | +return { |
| 16 | +getDoctorChannelCapabilities: () => fallback, |
| 17 | +}; |
| 18 | +}); |
| 19 | + |
| 20 | +vi.mock("./channel-doctor.js", () => ({ |
| 21 | +collectChannelDoctorEmptyAllowlistExtraWarnings: vi.fn(() => []), |
| 22 | +collectChannelDoctorPreviewWarnings: vi.fn( |
| 23 | +async ({ cfg }: { cfg: { channels?: Record<string, unknown> } }) => { |
| 24 | +const telegram = cfg.channels?.telegram as { allowFrom?: unknown } | undefined; |
| 25 | +const usernames = Array.isArray(telegram?.allowFrom) |
| 26 | + ? telegram.allowFrom.filter( |
| 27 | +(entry): entry is string => typeof entry === "string" && entry.startsWith("@"), |
| 28 | +) |
| 29 | + : []; |
| 30 | +if (usernames.length === 0) { |
| 31 | +return []; |
| 32 | +} |
| 33 | +return [ |
| 34 | +`- Telegram allowFrom contains ${usernames.length} username entr${ |
| 35 | + usernames.length === 1 ? "y" : "ies" |
| 36 | + } (e.g. ${usernames[0]}).`, |
| 37 | +]; |
| 38 | +}, |
| 39 | +), |
| 40 | +shouldSkipChannelDoctorDefaultEmptyGroupAllowlistWarning: vi.fn(() => false), |
| 41 | +})); |
| 42 | + |
8 | 43 | function manifest(id: string): PluginManifestRecord { |
9 | 44 | return { |
10 | 45 | id, |
|