feat!: move msteams to plugin

This commit is contained in:
Peter Steinberger
2026-01-16 02:58:08 +00:00
parent dae34f3a61
commit d9f9e93dee
73 changed files with 711 additions and 243 deletions

View File

@@ -0,0 +1,57 @@
import { describe, expect, it, vi } from "vitest";
import type { MSTeamsConfig } from "../../../src/config/types.js";
const hostMockState = vi.hoisted(() => ({
tokenError: null as Error | null,
}));
vi.mock("@microsoft/agents-hosting", () => ({
getAuthConfigWithDefaults: (cfg: unknown) => cfg,
MsalTokenProvider: class {
async getAccessToken() {
if (hostMockState.tokenError) throw hostMockState.tokenError;
return "token";
}
},
}));
import { probeMSTeams } from "./probe.js";
describe("msteams probe", () => {
it("returns an error when credentials are missing", async () => {
const cfg = { enabled: true } as unknown as MSTeamsConfig;
await expect(probeMSTeams(cfg)).resolves.toMatchObject({
ok: false,
});
});
it("validates credentials by acquiring a token", async () => {
hostMockState.tokenError = null;
const cfg = {
enabled: true,
appId: "app",
appPassword: "pw",
tenantId: "tenant",
} as unknown as MSTeamsConfig;
await expect(probeMSTeams(cfg)).resolves.toMatchObject({
ok: true,
appId: "app",
});
});
it("returns a helpful error when token acquisition fails", async () => {
hostMockState.tokenError = new Error("bad creds");
const cfg = {
enabled: true,
appId: "app",
appPassword: "pw",
tenantId: "tenant",
} as unknown as MSTeamsConfig;
await expect(probeMSTeams(cfg)).resolves.toMatchObject({
ok: false,
appId: "app",
error: "bad creds",
});
});
});