


















@@ -146,6 +146,14 @@ function createSdkStub(): MSTeamsTeamsSdk {
146146};
147147}
148148149+function requireFirstAppInstance(appInstances: Record<string, unknown>[]) {
150+const appInstance = appInstances[0];
151+if (!appInstance) {
152+throw new Error("expected sdk.App constructor call");
153+}
154+return appInstance;
155+}
156+149157describe("createMSTeamsApp", () => {
150158it("creates app without the Express 5 wildcard route regression (#55161)", async () => {
151159// Regression test for: https://github.com/openclaw/openclaw/issues/55161
@@ -199,15 +207,16 @@ describe("createMSTeamsAdapter", () => {
199207},
200208);
201209202-expect(fetchMock).toHaveBeenCalledWith(
210+expect(fetchMock).toHaveBeenCalledTimes(1);
211+const [url, options] = fetchMock.mock.calls[0] as unknown as [
212+string,
213+{ method?: string; headers?: { Authorization?: string } },
214+];
215+expect(url).toBe(
203216"https://example.com/v3/conversations/19%3Aconversation%40thread.tacv2/activities/activity-123",
204-expect.objectContaining({
205-method: "DELETE",
206-headers: expect.objectContaining({
207-Authorization: "Bearer bot-token",
208-}),
209-}),
210217);
218+expect(options.method).toBe("DELETE");
219+expect(options.headers?.Authorization).toBe("Bearer bot-token");
211220});
212221213222it("passes the OpenClaw User-Agent to the Bot Framework connector client", async () => {
@@ -238,14 +247,10 @@ describe("createMSTeamsAdapter", () => {
238247);
239248240249expect(clientConstructorState.calls).toHaveLength(1);
241-expect(clientConstructorState.calls[0]).toMatchObject({
242-serviceUrl: "https://service.example.com/",
243-options: {
244-headers: {
245-"User-Agent": expect.stringMatching(/^teams\.ts\[apps\]\/.+ OpenClaw\/.+$/),
246-},
247-},
248-});
250+const clientCall = clientConstructorState.calls[0];
251+expect(clientCall?.serviceUrl).toBe("https://service.example.com/");
252+const options = clientCall?.options as { headers?: { "User-Agent"?: string } } | undefined;
253+expect(options?.headers?.["User-Agent"]).toMatch(/^teams\.ts\[apps\]\/.+ OpenClaw\/.+$/);
249254});
250255});
251256@@ -442,11 +447,10 @@ describe("createMSTeamsApp – secret credentials", () => {
442447};
443448const app = await createMSTeamsApp(creds, sdk);
444449expect(app).toBeInstanceOf(FakeApp);
445-expect(appInstances[0]).toMatchObject({
446-clientId: "my-app-id",
447-clientSecret: "my-secret",
448-tenantId: "my-tenant",
449-});
450+const appInstance = requireFirstAppInstance(appInstances);
451+expect(appInstance.clientId).toBe("my-app-id");
452+expect(appInstance.clientSecret).toBe("my-secret");
453+expect(appInstance.tenantId).toBe("my-tenant");
450454});
451455});
452456@@ -468,11 +472,10 @@ describe("createMSTeamsApp – federated certificate credentials", () => {
468472};
469473await createMSTeamsApp(creds, sdk);
470474expect(fs.readFileSync).toHaveBeenCalledWith("/certs/bot.pem", "utf-8");
471-expect(appInstances[0]).toMatchObject({
472-clientId: "fed-app-id",
473-tenantId: "fed-tenant",
474-});
475-const tokenProvider = appInstances[0].token as ((scope: string) => Promise<string>) | undefined;
475+const appInstance = requireFirstAppInstance(appInstances);
476+expect(appInstance.clientId).toBe("fed-app-id");
477+expect(appInstance.tenantId).toBe("fed-tenant");
478+const tokenProvider = appInstance.token as ((scope: string) => Promise<string>) | undefined;
476479if (!tokenProvider) {
477480throw new Error("expected federated app to expose token provider");
478481}
@@ -520,8 +523,10 @@ describe("createMSTeamsApp – federated managed identity", () => {
520523managedIdentityClientId: "mi-client-id",
521524};
522525await createMSTeamsApp(creds, sdk);
523-expect(appInstances[0]).toMatchObject({ clientId: "mi-app-id", tenantId: "mi-tenant" });
524-const tokenProvider = appInstances[0].token as ((scope: string) => Promise<string>) | undefined;
526+const appInstance = requireFirstAppInstance(appInstances);
527+expect(appInstance.clientId).toBe("mi-app-id");
528+expect(appInstance.tenantId).toBe("mi-tenant");
529+const tokenProvider = appInstance.token as ((scope: string) => Promise<string>) | undefined;
525530if (!tokenProvider) {
526531throw new Error("expected managed-identity app to expose token provider");
527532}
@@ -608,9 +613,9 @@ describe("createMSTeamsAdapter – continueConversation", () => {
608613});
609614610615expect(createFn).toHaveBeenCalledTimes(1);
611-expect(createFn).toHaveBeenCalledWith(
612- expect.objectContaining({ type: "message", text: "hello from proactive send" }),
613-);
616+const activity = createFn.mock.calls[0]?.[0] as { type?: string; text?: string } | undefined;
617+expect(activity?.type).toBe("message");
618+expect(activity?.text).toBe("hello from proactive send");
614619});
615620616621it("provides deleteActivity via REST DELETE in logic callback", async () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。