diff --git a/extensions/mattermost/src/channel-actions-setup-status.contract.test.ts b/extensions/mattermost/src/channel-actions-setup-status.contract.test.ts index cb32b3fa034..3ed1863efa9 100644 --- a/extensions/mattermost/src/channel-actions-setup-status.contract.test.ts +++ b/extensions/mattermost/src/channel-actions-setup-status.contract.test.ts @@ -70,9 +70,14 @@ describe("mattermost setup contract", () => { }, expectedAccountId: "default", assertPatchedConfig: (cfg) => { - expect(cfg.channels?.mattermost?.enabled).toBe(true); - expect(cfg.channels?.mattermost?.botToken).toBe("test-token"); - expect(cfg.channels?.mattermost?.baseUrl).toBe("https://chat.example.com"); + const mattermostConfig = cfg.channels?.mattermost; + expect(mattermostConfig).toBeDefined(); + if (!mattermostConfig) { + throw new Error("expected Mattermost config patch"); + } + expect(mattermostConfig.enabled).toBe(true); + expect(mattermostConfig.botToken).toBe("test-token"); + expect(mattermostConfig.baseUrl).toBe("https://chat.example.com"); }, }, { diff --git a/extensions/mattermost/src/doctor.test.ts b/extensions/mattermost/src/doctor.test.ts index e5e425d23ad..96ecd7b0357 100644 --- a/extensions/mattermost/src/doctor.test.ts +++ b/extensions/mattermost/src/doctor.test.ts @@ -30,16 +30,17 @@ describe("mattermost doctor", () => { } as never, }); - expect(result.config.channels?.mattermost?.network).toEqual({ + const mattermostConfig = result.config.channels?.mattermost; + expect(mattermostConfig).toBeDefined(); + if (!mattermostConfig) { + throw new Error("expected normalized Mattermost config"); + } + expect(mattermostConfig.network).toEqual({ dangerouslyAllowPrivateNetwork: true, }); - expect( - ( - result.config.channels?.mattermost?.accounts?.work as - | { network?: Record } - | undefined - )?.network, - ).toEqual({ + const workAccount = mattermostConfig.accounts?.work as { network?: Record }; + expect(workAccount).toBeDefined(); + expect(workAccount.network).toEqual({ dangerouslyAllowPrivateNetwork: false, }); }); diff --git a/extensions/mattermost/src/setup.test.ts b/extensions/mattermost/src/setup.test.ts index 231f6a7be96..361abb6b12d 100644 --- a/extensions/mattermost/src/setup.test.ts +++ b/extensions/mattermost/src/setup.test.ts @@ -391,8 +391,13 @@ describe("mattermost setup", () => { ([params]) => (params as { message: string }).message, ); expect(textMessages).toEqual(["Enter Mattermost bot token", "Enter Mattermost base URL"]); - expect(result.cfg.channels?.mattermost?.botToken).toBe("bot-token"); - expect(result.cfg.channels?.mattermost?.baseUrl).toBe("https://chat.example.com"); + const mattermostConfig = result.cfg.channels?.mattermost; + expect(mattermostConfig).toBeDefined(); + if (!mattermostConfig) { + throw new Error("expected Mattermost config"); + } + expect(mattermostConfig.botToken).toBe("bot-token"); + expect(mattermostConfig.baseUrl).toBe("https://chat.example.com"); expect(result.accountId).toBe(DEFAULT_ACCOUNT_ID); }); });