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

推荐订阅源

博客园 - 叶小钗
Microsoft Azure Blog
Microsoft Azure Blog
Stack Overflow Blog
Stack Overflow Blog
Jina AI
Jina AI
Vercel News
Vercel News
H
Help Net Security
Martin Fowler
Martin Fowler
美团技术团队
云风的 BLOG
云风的 BLOG
Y
Y Combinator Blog
阮一峰的网络日志
阮一峰的网络日志
MyScale Blog
MyScale Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 三生石上(FineUI控件)
博客园 - 司徒正美
人人都是产品经理
人人都是产品经理
Engineering at Meta
Engineering at Meta
G
Google Developers Blog
Blog — PlanetScale
Blog — PlanetScale
MongoDB | Blog
MongoDB | Blog
宝玉的分享
宝玉的分享
小众软件
小众软件
T
Tailwind CSS Blog
WordPress大学
WordPress大学

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 discord rest proxy assertions · openclaw/op...
steipete · 2026-05-11 · via Recent Commits to openclaw:main

@@ -36,6 +36,29 @@ vi.mock("undici", () => {

36363737

let resolveDiscordRestFetch: typeof import("./rest-fetch.js").resolveDiscordRestFetch;

383839+

type MockWithCalls = {

40+

mock: { calls: unknown[][] };

41+

};

42+43+

function objectArgAt(

44+

mock: MockWithCalls,

45+

callIndex: number,

46+

argIndex: number,

47+

): Record<string, unknown> {

48+

const value = mock.mock.calls[callIndex]?.[argIndex];

49+

if (value === undefined || value === null || typeof value !== "object" || Array.isArray(value)) {

50+

throw new Error(`expected call ${callIndex} argument ${argIndex} to be an object`);

51+

}

52+

return value as Record<string, unknown>;

53+

}

54+55+

function recordField(value: unknown, field: string): Record<string, unknown> {

56+

if (value === undefined || value === null || typeof value !== "object" || Array.isArray(value)) {

57+

throw new Error(`expected ${field} to be an object`);

58+

}

59+

return value as Record<string, unknown>;

60+

}

61+3962

describe("resolveDiscordRestFetch", () => {

4063

beforeAll(async () => {

4164

({ resolveDiscordRestFetch } = await import("./rest-fetch.js"));

@@ -60,21 +83,16 @@ describe("resolveDiscordRestFetch", () => {

60836184

await fetcher("https://discord.com/api/v10/oauth2/applications/@me");

628563-

expect(proxyAgentSpy).toHaveBeenCalledWith(

64-

expect.objectContaining({

65-

uri: "http://127.0.0.1:8080",

66-

allowH2: false,

67-

}),

68-

);

69-

expect(undiciFetchMock).toHaveBeenCalledWith(

86+

const proxyOptions = objectArgAt(proxyAgentSpy, 0, 0);

87+

expect(proxyOptions.uri).toBe("http://127.0.0.1:8080");

88+

expect(proxyOptions.allowH2).toBe(false);

89+

expect(undiciFetchMock.mock.calls[0]?.[0]).toBe(

7090

"https://discord.com/api/v10/oauth2/applications/@me",

71-

expect.objectContaining({

72-

dispatcher: expect.objectContaining({

73-

uri: "http://127.0.0.1:8080",

74-

options: expect.objectContaining({ allowH2: false }),

75-

}),

76-

}),

7791

);

92+

const fetchOptions = objectArgAt(undiciFetchMock, 0, 1);

93+

const dispatcher = recordField(fetchOptions.dispatcher, "dispatcher");

94+

expect(dispatcher.uri).toBe("http://127.0.0.1:8080");

95+

expect(recordField(dispatcher.options, "dispatcher.options").allowH2).toBe(false);

7896

expect(runtime.log).toHaveBeenCalledWith("discord: rest proxy enabled");

7997

expect(runtime.error).not.toHaveBeenCalled();

8098

});

@@ -103,7 +121,7 @@ describe("resolveDiscordRestFetch", () => {

103121104122

expect(fetcher).toBe(fetch);

105123

expect(proxyAgentSpy).not.toHaveBeenCalled();

106-

expect(runtime.error).toHaveBeenCalledWith(expect.stringContaining("loopback host"));

124+

expect(String(runtime.error.mock.calls[0]?.[0])).toContain("loopback host");

107125

expect(runtime.log).not.toHaveBeenCalled();

108126

});

109127

@@ -119,12 +137,9 @@ describe("resolveDiscordRestFetch", () => {

119137120138

await fetcher("https://discord.com/api/v10/oauth2/applications/@me");

121139122-

expect(proxyAgentSpy).toHaveBeenCalledWith(

123-

expect.objectContaining({

124-

uri: "http://[::1]:8080",

125-

allowH2: false,

126-

}),

127-

);

140+

const proxyOptions = objectArgAt(proxyAgentSpy, 0, 0);

141+

expect(proxyOptions.uri).toBe("http://[::1]:8080");

142+

expect(proxyOptions.allowH2).toBe(false);

128143

expect(runtime.error).not.toHaveBeenCalled();

129144

});

130145

@@ -139,22 +154,20 @@ describe("resolveDiscordRestFetch", () => {

139154

const fetcher = resolveDiscordRestFetch(undefined, runtime);

140155

await fetcher("https://discord.com/api/v10/oauth2/applications/@me");

141156142-

expect(agentSpy).toHaveBeenCalledWith(

143-

expect.objectContaining({

144-

allowH2: false,

145-

connect: expect.objectContaining({ lookup: expect.any(Function) }),

146-

}),

147-

);

148-

expect(undiciFetchMock).toHaveBeenCalledWith(

157+

const agentOptions = objectArgAt(agentSpy, 0, 0);

158+

expect(agentOptions.allowH2).toBe(false);

159+

expect(typeof recordField(agentOptions.connect, "connect").lookup).toBe("function");

160+

expect(undiciFetchMock.mock.calls[0]?.[0]).toBe(

149161

"https://discord.com/api/v10/oauth2/applications/@me",

150-

expect.objectContaining({

151-

dispatcher: expect.objectContaining({

152-

options: expect.objectContaining({

153-

allowH2: false,

154-

connect: expect.objectContaining({ lookup: expect.any(Function) }),

155-

}),

156-

}),

157-

}),

162+

);

163+

const fetchOptions = objectArgAt(undiciFetchMock, 0, 1);

164+

const dispatcherOptions = recordField(

165+

recordField(fetchOptions.dispatcher, "dispatcher").options,

166+

"dispatcher.options",

167+

);

168+

expect(dispatcherOptions.allowH2).toBe(false);

169+

expect(typeof recordField(dispatcherOptions.connect, "dispatcher.options.connect").lookup).toBe(

170+

"function",

158171

);

159172

expect(runtime.log).not.toHaveBeenCalled();

160173

});

@@ -172,12 +185,9 @@ describe("resolveDiscordRestFetch", () => {

172185

const fetcher = resolveDiscordRestFetch(undefined, runtime);

173186

await fetcher("https://discord.com/api/v10/oauth2/applications/@me");

174187175-

expect(proxyAgentSpy).toHaveBeenCalledWith(

176-

expect.objectContaining({

177-

uri: "http://127.0.0.1:7777",

178-

allowH2: false,

179-

}),

180-

);

188+

const proxyOptions = objectArgAt(proxyAgentSpy, 0, 0);

189+

expect(proxyOptions.uri).toBe("http://127.0.0.1:7777");

190+

expect(proxyOptions.allowH2).toBe(false);

181191

expect(runtime.log).toHaveBeenCalledWith("discord: rest proxy enabled");

182192

});

183193

});