mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-19 12:32:59 +00:00
test: verify teams generated values
This commit is contained in:
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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`,
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -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")));
|
||||
});
|
||||
|
||||
@@ -372,7 +372,7 @@ describe("createMSTeamsReplyDispatcher", () => {
|
||||
await dispatcher.replyOptions.onToolStart?.({ name: "exec" });
|
||||
|
||||
expect(streamInstances[0]?.sendInformativeUpdate).toHaveBeenCalledWith(
|
||||
expect.stringMatching(/^[^\n]+\.\.\.$/),
|
||||
pickInformativeStatusText({ seed: "default:conv" }),
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user