test: tighten mattermost config assertions

This commit is contained in:
Shakker
2026-05-08 18:56:24 +01:00
parent f29327b65d
commit 7f5df0b97d
3 changed files with 24 additions and 13 deletions

View File

@@ -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");
},
},
{

View File

@@ -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<string, unknown> }
| undefined
)?.network,
).toEqual({
const workAccount = mattermostConfig.accounts?.work as { network?: Record<string, unknown> };
expect(workAccount).toBeDefined();
expect(workAccount.network).toEqual({
dangerouslyAllowPrivateNetwork: false,
});
});

View File

@@ -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);
});
});