test: tighten mattermost config assertions · openclaw/openclaw@7f5df0b
shakkernerd
·
2026-05-09
·
via Recent Commits to openclaw:main
File tree
extensions/mattermost/src
| Original file line number | Diff line number | Diff line change |
|---|
@@ -70,9 +70,14 @@ describe("mattermost setup contract", () => {
|
70 | 70 | }, |
71 | 71 | expectedAccountId: "default", |
72 | 72 | assertPatchedConfig: (cfg) => { |
73 | | -expect(cfg.channels?.mattermost?.enabled).toBe(true); |
74 | | -expect(cfg.channels?.mattermost?.botToken).toBe("test-token"); |
75 | | -expect(cfg.channels?.mattermost?.baseUrl).toBe("https://chat.example.com"); |
| 73 | +const mattermostConfig = cfg.channels?.mattermost; |
| 74 | +expect(mattermostConfig).toBeDefined(); |
| 75 | +if (!mattermostConfig) { |
| 76 | +throw new Error("expected Mattermost config patch"); |
| 77 | +} |
| 78 | +expect(mattermostConfig.enabled).toBe(true); |
| 79 | +expect(mattermostConfig.botToken).toBe("test-token"); |
| 80 | +expect(mattermostConfig.baseUrl).toBe("https://chat.example.com"); |
76 | 81 | }, |
77 | 82 | }, |
78 | 83 | { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -30,16 +30,17 @@ describe("mattermost doctor", () => {
|
30 | 30 | } as never, |
31 | 31 | }); |
32 | 32 | |
33 | | -expect(result.config.channels?.mattermost?.network).toEqual({ |
| 33 | +const mattermostConfig = result.config.channels?.mattermost; |
| 34 | +expect(mattermostConfig).toBeDefined(); |
| 35 | +if (!mattermostConfig) { |
| 36 | +throw new Error("expected normalized Mattermost config"); |
| 37 | +} |
| 38 | +expect(mattermostConfig.network).toEqual({ |
34 | 39 | dangerouslyAllowPrivateNetwork: true, |
35 | 40 | }); |
36 | | -expect( |
37 | | -( |
38 | | -result.config.channels?.mattermost?.accounts?.work as |
39 | | -| { network?: Record<string, unknown> } |
40 | | -| undefined |
41 | | -)?.network, |
42 | | -).toEqual({ |
| 41 | +const workAccount = mattermostConfig.accounts?.work as { network?: Record<string, unknown> }; |
| 42 | +expect(workAccount).toBeDefined(); |
| 43 | +expect(workAccount.network).toEqual({ |
43 | 44 | dangerouslyAllowPrivateNetwork: false, |
44 | 45 | }); |
45 | 46 | }); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -391,8 +391,13 @@ describe("mattermost setup", () => {
|
391 | 391 | ([params]) => (params as { message: string }).message, |
392 | 392 | ); |
393 | 393 | expect(textMessages).toEqual(["Enter Mattermost bot token", "Enter Mattermost base URL"]); |
394 | | -expect(result.cfg.channels?.mattermost?.botToken).toBe("bot-token"); |
395 | | -expect(result.cfg.channels?.mattermost?.baseUrl).toBe("https://chat.example.com"); |
| 394 | +const mattermostConfig = result.cfg.channels?.mattermost; |
| 395 | +expect(mattermostConfig).toBeDefined(); |
| 396 | +if (!mattermostConfig) { |
| 397 | +throw new Error("expected Mattermost config"); |
| 398 | +} |
| 399 | +expect(mattermostConfig.botToken).toBe("bot-token"); |
| 400 | +expect(mattermostConfig.baseUrl).toBe("https://chat.example.com"); |
396 | 401 | expect(result.accountId).toBe(DEFAULT_ACCOUNT_ID); |
397 | 402 | }); |
398 | 403 | }); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。