



























@@ -60,9 +60,14 @@ describe("zalo setup wizard", () => {
6060});
61616262expect(result.accountId).toBe("default");
63-expect(result.cfg.channels?.zalo?.enabled).toBe(true);
64-expect(result.cfg.channels?.zalo?.botToken).toBe("12345689:abc-xyz");
65-expect(result.cfg.channels?.zalo?.webhookUrl).toBeUndefined();
63+const zaloConfig = result.cfg.channels?.zalo;
64+expect(zaloConfig).toBeDefined();
65+if (!zaloConfig) {
66+throw new Error("expected Zalo config");
67+}
68+expect(zaloConfig.enabled).toBe(true);
69+expect(zaloConfig.botToken).toBe("12345689:abc-xyz");
70+expect(zaloConfig.webhookUrl).toBeUndefined();
6671});
67726873it("reads the named-account DM policy instead of the channel root", () => {
@@ -117,11 +122,20 @@ describe("zalo setup wizard", () => {
117122});
118123119124const next = zaloDmPolicy.setPolicy(cfg, "open");
120-expect(next.channels?.zalo?.dmPolicy).toBe("disabled");
125+const zaloConfig = next.channels?.zalo;
126+expect(zaloConfig).toBeDefined();
127+if (!zaloConfig) {
128+throw new Error("expected Zalo config");
129+}
130+expect(zaloConfig.dmPolicy).toBe("disabled");
121131const workAccount = next.channels?.zalo?.accounts?.work as
122132| { dmPolicy?: string; allowFrom?: Array<string | number> }
123133| undefined;
124-expect(workAccount?.dmPolicy).toBe("open");
134+expect(workAccount).toBeDefined();
135+if (!workAccount) {
136+throw new Error("expected Zalo work account");
137+}
138+expect(workAccount.dmPolicy).toBe("open");
125139});
126140127141it('writes open policy state to the named account and preserves inherited allowFrom with "*"', () => {
@@ -142,12 +156,21 @@ describe("zalo setup wizard", () => {
142156"work",
143157);
144158145-expect(next.channels?.zalo?.dmPolicy).toBeUndefined();
159+const zaloConfig = next.channels?.zalo;
160+expect(zaloConfig).toBeDefined();
161+if (!zaloConfig) {
162+throw new Error("expected Zalo config");
163+}
164+expect(zaloConfig.dmPolicy).toBeUndefined();
146165const workAccount = next.channels?.zalo?.accounts?.work as
147166| { dmPolicy?: string; allowFrom?: Array<string | number> }
148167| undefined;
149-expect(workAccount?.dmPolicy).toBe("open");
150-expect(workAccount?.allowFrom).toEqual(["123456789", "*"]);
168+expect(workAccount).toBeDefined();
169+if (!workAccount) {
170+throw new Error("expected Zalo work account");
171+}
172+expect(workAccount.dmPolicy).toBe("open");
173+expect(workAccount.allowFrom).toEqual(["123456789", "*"]);
151174});
152175153176it("uses configured defaultAccount for omitted setup configured state", async () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。