diff --git a/extensions/msteams/src/attachments.graph.test.ts b/extensions/msteams/src/attachments.graph.test.ts index 19ca0b5b434..cba3be2d9fb 100644 --- a/extensions/msteams/src/attachments.graph.test.ts +++ b/extensions/msteams/src/attachments.graph.test.ts @@ -3,7 +3,7 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; import type { PluginRuntime } from "../runtime-api.js"; import { readRemoteMediaResponse } from "./attachments.test-helpers.js"; import { downloadMSTeamsGraphMedia } from "./attachments/graph.js"; -import { resolveRequestUrl } from "./attachments/shared.js"; +import { encodeGraphShareId, resolveRequestUrl } from "./attachments/shared.js"; import { setMSTeamsRuntime } from "./runtime.js"; const GRAPH_HOST = "graph.microsoft.com"; @@ -316,11 +316,12 @@ describe("msteams graph attachments", () => { expectAttachmentMediaLength(media.media, 0); const calledUrls = fetchMock.mock.calls.map((call) => call[0]); + const expectedSharesUrl = `${GRAPH_SHARES_URL_PREFIX}${encodeGraphShareId(DEFAULT_SHARE_REFERENCE_URL)}/driveItem/content`; expect(calledUrls).toEqual([ DEFAULT_MESSAGE_URL, - expect.stringContaining(GRAPH_SHARES_URL_PREFIX), + expectedSharesUrl, `${DEFAULT_MESSAGE_URL}/hostedContents`, - expect.stringContaining(GRAPH_SHARES_URL_PREFIX), + expectedSharesUrl, ]); expect(calledUrls).not.toContain(escapedUrl); }); diff --git a/extensions/msteams/src/attachments/shared.test.ts b/extensions/msteams/src/attachments/shared.test.ts index 4fe4fc23eb0..eed46464267 100644 --- a/extensions/msteams/src/attachments/shared.test.ts +++ b/extensions/msteams/src/attachments/shared.test.ts @@ -455,20 +455,16 @@ describe("Graph shared-link helpers", () => { it("tryBuildGraphSharesUrlForSharedLink rewrites SharePoint URLs", () => { const url = "https://contoso.sharepoint.com/personal/user/Documents/report.pdf"; const result = tryBuildGraphSharesUrlForSharedLink(url); - expect(result).toEqual( - expect.stringMatching( - /^https:\/\/graph\.microsoft\.com\/v1\.0\/shares\/u![A-Za-z0-9_-]+\/driveItem\/content$/, - ), + expect(result).toBe( + `https://graph.microsoft.com/v1.0/shares/${encodeGraphShareId(url)}/driveItem/content`, ); }); it("tryBuildGraphSharesUrlForSharedLink rewrites OneDrive URLs", () => { const url = "https://1drv.ms/b/s!AkxYabcdefg"; const result = tryBuildGraphSharesUrlForSharedLink(url); - expect(result).toEqual( - expect.stringMatching( - /^https:\/\/graph\.microsoft\.com\/v1\.0\/shares\/u![A-Za-z0-9_-]+\/driveItem\/content$/, - ), + expect(result).toBe( + `https://graph.microsoft.com/v1.0/shares/${encodeGraphShareId(url)}/driveItem/content`, ); }); diff --git a/extensions/msteams/src/file-consent.test.ts b/extensions/msteams/src/file-consent.test.ts index 7ccb72e065c..847db93dbc6 100644 --- a/extensions/msteams/src/file-consent.test.ts +++ b/extensions/msteams/src/file-consent.test.ts @@ -5,6 +5,7 @@ import { uploadToConsentUrl, validateConsentUploadUrl, } from "./file-consent.js"; +import { buildUserAgent } from "./user-agent.js"; // Helper: a resolveFn that returns a public IP by default const publicResolve = async () => ({ address: "13.107.136.10" }); @@ -277,7 +278,7 @@ describe("uploadToConsentUrl", () => { expect(opts?.headers).toEqual({ "Content-Range": "bytes 0-4/5", "Content-Type": "application/octet-stream", - "User-Agent": expect.stringMatching(/^teams\.ts\[apps\]\/.+ OpenClaw\/.+$/), + "User-Agent": buildUserAgent(), }); expect(opts?.body).toEqual(new Uint8Array(Buffer.from("hello"))); }); diff --git a/extensions/msteams/src/reply-dispatcher.test.ts b/extensions/msteams/src/reply-dispatcher.test.ts index 5862f3129ad..9c5761e6452 100644 --- a/extensions/msteams/src/reply-dispatcher.test.ts +++ b/extensions/msteams/src/reply-dispatcher.test.ts @@ -372,7 +372,7 @@ describe("createMSTeamsReplyDispatcher", () => { await dispatcher.replyOptions.onToolStart?.({ name: "exec" }); expect(streamInstances[0]?.sendInformativeUpdate).toHaveBeenCalledWith( - expect.stringMatching(/^[^\n]+\.\.\.$/), + pickInformativeStatusText({ seed: "default:conv" }), ); });