惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

U
Unit 42
T
The Blog of Author Tim Ferriss
H
Help Net Security
博客园 - 叶小钗
云风的 BLOG
云风的 BLOG
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
D
DataBreaches.Net
博客园 - 聂微东
A
About on SuperTechFans
大猫的无限游戏
大猫的无限游戏
P
Proofpoint News Feed
Martin Fowler
Martin Fowler
博客园 - 【当耐特】
S
SegmentFault 最新的问题
Blog — PlanetScale
Blog — PlanetScale
酷 壳 – CoolShell
酷 壳 – CoolShell
G
Google Developers Blog
I
InfoQ
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
GbyAI
GbyAI
B
Blog
Engineering at Meta
Engineering at Meta
V
V2EX
Hugging Face - Blog
Hugging Face - Blog

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
test: tighten msteams graph upload assertions · openclaw/...
steipete · 2026-05-11 · via Recent Commits to openclaw:main

@@ -3,6 +3,25 @@ import { describe, expect, it, vi } from "vitest";

33

import { buildTeamsFileInfoCard } from "./graph-chat.js";

44

import { resolveGraphChatId, uploadToOneDrive, uploadToSharePoint } from "./graph-upload.js";

556+

type FetchCall = [string, { method?: string; headers?: Record<string, string> } | undefined];

7+8+

function requireFetchCall(fetchFn: ReturnType<typeof vi.fn>, index = 0): FetchCall {

9+

const call = fetchFn.mock.calls[index] as unknown as FetchCall | undefined;

10+

if (!call) {

11+

throw new Error(`fetch call ${index} missing`);

12+

}

13+

return call;

14+

}

15+16+

function expectGraphUploadFetch(fetchFn: ReturnType<typeof vi.fn>, expectedUrl: string): void {

17+

const [url, init] = requireFetchCall(fetchFn);

18+

expect(url).toBe(expectedUrl);

19+

expect(init?.method).toBe("PUT");

20+

expect(init?.headers?.Authorization).toBe("Bearer graph-token");

21+

expect(init?.headers?.["Content-Type"]).toBe("application/octet-stream");

22+

expect(init?.headers?.["User-Agent"]).toMatch(/^teams\.ts\[apps\]\/.+ OpenClaw\/.+$/);

23+

}

24+625

describe("graph upload helpers", () => {

726

const tokenProvider = {

827

getAccessToken: vi.fn(async () => "graph-token"),

@@ -27,16 +46,9 @@ describe("graph upload helpers", () => {

2746

fetchFn: withFetchPreconnect(fetchFn),

2847

});

294830-

expect(fetchFn).toHaveBeenCalledWith(

49+

expectGraphUploadFetch(

50+

fetchFn,

3151

"https://graph.microsoft.com/v1.0/me/drive/root:/OpenClawShared/a.txt:/content",

32-

expect.objectContaining({

33-

method: "PUT",

34-

headers: expect.objectContaining({

35-

Authorization: "Bearer graph-token",

36-

"Content-Type": "application/octet-stream",

37-

"User-Agent": expect.stringMatching(/^teams\.ts\[apps\]\/.+ OpenClaw\/.+$/),

38-

}),

39-

}),

4052

);

4153

expect(result).toEqual({

4254

id: "item-1",

@@ -65,16 +77,9 @@ describe("graph upload helpers", () => {

6577

fetchFn: withFetchPreconnect(fetchFn),

6678

});

677968-

expect(fetchFn).toHaveBeenCalledWith(

80+

expectGraphUploadFetch(

81+

fetchFn,

6982

"https://graph.microsoft.com/v1.0/sites/site-123/drive/root:/OpenClawShared/b.txt:/content",

70-

expect.objectContaining({

71-

method: "PUT",

72-

headers: expect.objectContaining({

73-

Authorization: "Bearer graph-token",

74-

"Content-Type": "application/octet-stream",

75-

"User-Agent": expect.stringMatching(/^teams\.ts\[apps\]\/.+ OpenClaw\/.+$/),

76-

}),

77-

}),

7883

);

7984

expect(result).toEqual({

8085

id: "item-2",

@@ -137,20 +142,10 @@ describe("resolveGraphChatId", () => {

137142

fetchFn: withFetchPreconnect(fetchFn),

138143

});

139144140-

expect(fetchFn).toHaveBeenCalledWith(

141-

expect.stringContaining("/me/chats"),

142-

expect.objectContaining({

143-

headers: expect.objectContaining({

144-

Authorization: "Bearer graph-token",

145-

"User-Agent": expect.stringMatching(/^teams\.ts\[apps\]\/.+ OpenClaw\/.+$/),

146-

}),

147-

}),

148-

);

149-

const firstCall = fetchFn.mock.calls[0];

150-

if (!firstCall) {

151-

throw new Error("expected Graph chat lookup request");

152-

}

153-

const [callUrlRaw] = firstCall as unknown as [string, RequestInit?];

145+

expect(fetchFn).toHaveBeenCalledTimes(1);

146+

const [callUrlRaw, init] = requireFetchCall(fetchFn);

147+

expect(init?.headers?.Authorization).toBe("Bearer graph-token");

148+

expect(init?.headers?.["User-Agent"]).toMatch(/^teams\.ts\[apps\]\/.+ OpenClaw\/.+$/);

154149

const callUrl = new URL(callUrlRaw);

155150

expect(callUrl.origin).toBe("https://graph.microsoft.com");

156151

expect(callUrl.pathname).toBe("/v1.0/me/chats");