test: dedupe msteams policy route fixtures

This commit is contained in:
Peter Steinberger 2026-03-13 21:53:41 +00:00
parent b23bfef8cc
commit f2300f4522
1 changed files with 23 additions and 35 deletions

View File

@ -6,6 +6,27 @@ import {
resolveMSTeamsRouteConfig,
} from "./policy.js";
function resolveNamedTeamRouteConfig(allowNameMatching = false) {
const cfg: MSTeamsConfig = {
teams: {
"My Team": {
requireMention: true,
channels: {
"General Chat": { requireMention: false },
},
},
},
};
return resolveMSTeamsRouteConfig({
cfg,
teamName: "My Team",
channelName: "General Chat",
conversationId: "ignored",
allowNameMatching,
});
}
describe("msteams policy", () => {
describe("resolveMSTeamsRouteConfig", () => {
it("returns team and channel config when present", () => {
@ -51,23 +72,7 @@ describe("msteams policy", () => {
});
it("blocks team and channel name matches by default", () => {
const cfg: MSTeamsConfig = {
teams: {
"My Team": {
requireMention: true,
channels: {
"General Chat": { requireMention: false },
},
},
},
};
const res = resolveMSTeamsRouteConfig({
cfg,
teamName: "My Team",
channelName: "General Chat",
conversationId: "ignored",
});
const res = resolveNamedTeamRouteConfig();
expect(res.teamConfig).toBeUndefined();
expect(res.channelConfig).toBeUndefined();
@ -75,24 +80,7 @@ describe("msteams policy", () => {
});
it("matches team and channel by name when dangerous name matching is enabled", () => {
const cfg: MSTeamsConfig = {
teams: {
"My Team": {
requireMention: true,
channels: {
"General Chat": { requireMention: false },
},
},
},
};
const res = resolveMSTeamsRouteConfig({
cfg,
teamName: "My Team",
channelName: "General Chat",
conversationId: "ignored",
allowNameMatching: true,
});
const res = resolveNamedTeamRouteConfig(true);
expect(res.teamConfig?.requireMention).toBe(true);
expect(res.channelConfig?.requireMention).toBe(false);