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

推荐订阅源

S
SegmentFault 最新的问题
博客园 - 三生石上(FineUI控件)
WordPress大学
WordPress大学
博客园 - 【当耐特】
月光博客
月光博客
Vercel News
Vercel News
D
Docker
I
InfoQ
Apple Machine Learning Research
Apple Machine Learning Research
博客园 - 叶小钗
MongoDB | Blog
MongoDB | Blog
GbyAI
GbyAI
有赞技术团队
有赞技术团队
雷峰网
雷峰网
博客园 - 聂微东
小众软件
小众软件
Y
Y Combinator Blog
腾讯CDC
L
LangChain Blog
The GitHub Blog
The GitHub Blog
宝玉的分享
宝玉的分享
Stack Overflow Blog
Stack Overflow Blog
大猫的无限游戏
大猫的无限游戏
T
The Blog of Author Tim Ferriss

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 btw command assertions · openclaw/openclaw@...
steipete · 2026-05-11 · via Recent Commits to openclaw:main

@@ -23,6 +23,29 @@ function buildParams(commandBody: string) {

2323

return buildCommandTestParams(commandBody, cfg, undefined, { workspaceDir: "/tmp/workspace" });

2424

}

252526+

function mockCall(mock: unknown, index = 0): Array<unknown> {

27+

const calls = (mock as { mock?: { calls?: Array<Array<unknown>> } }).mock?.calls ?? [];

28+

const call = calls.at(index);

29+

expect(call, `mock call ${index + 1}`).toBeDefined();

30+

return call as Array<unknown>;

31+

}

32+33+

function mockFirstObjectArg(mock: unknown): Record<string, unknown> {

34+

const [arg] = mockCall(mock);

35+

expect(arg).toBeTypeOf("object");

36+

expect(arg).not.toBeNull();

37+

return arg as Record<string, unknown>;

38+

}

39+40+

function expectObjectFields(value: unknown, expected: Record<string, unknown>): void {

41+

expect(value).toBeTypeOf("object");

42+

expect(value).not.toBeNull();

43+

const record = value as Record<string, unknown>;

44+

for (const [key, expectedValue] of Object.entries(expected)) {

45+

expect(record[key], key).toEqual(expectedValue);

46+

}

47+

}

48+2649

describe("handleBtwCommand", () => {

2750

beforeEach(() => {

2851

runBtwSideQuestionMock.mockReset();

@@ -83,14 +106,12 @@ describe("handleBtwCommand", () => {

8310684107

const result = await handleBtwCommand(params, true);

8510886-

expect(runBtwSideQuestionMock).toHaveBeenCalledWith(

87-

expect.objectContaining({

88-

question: "what changed?",

89-

sessionEntry: params.sessionEntry,

90-

resolvedThinkLevel: "off",

91-

resolvedReasoningLevel: "off",

92-

}),

93-

);

109+

expectObjectFields(mockFirstObjectArg(runBtwSideQuestionMock), {

110+

question: "what changed?",

111+

sessionEntry: params.sessionEntry,

112+

resolvedThinkLevel: "off",

113+

resolvedReasoningLevel: "off",

114+

});

94115

expect(result).toEqual({

95116

shouldContinue: false,

96117

reply: { text: "snapshot answer", btw: { question: "what changed?" } },

@@ -124,15 +145,14 @@ describe("handleBtwCommand", () => {

124145125146

const result = await handleBtwCommand(params, true);

126147127-

expect(runBtwSideQuestionMock).toHaveBeenCalledWith(

128-

expect.objectContaining({

129-

question: "what changed?",

130-

agentDir: expect.stringContaining("/agents/main/agent"),

131-

sessionEntry: params.sessionEntry,

132-

resolvedThinkLevel: "off",

133-

resolvedReasoningLevel: "off",

134-

}),

135-

);

148+

const runnerArgs = mockFirstObjectArg(runBtwSideQuestionMock);

149+

expectObjectFields(runnerArgs, {

150+

question: "what changed?",

151+

sessionEntry: params.sessionEntry,

152+

resolvedThinkLevel: "off",

153+

resolvedReasoningLevel: "off",

154+

});

155+

expect(String(runnerArgs.agentDir)).toContain("/agents/main/agent");

136156

expect(result).toEqual({

137157

shouldContinue: false,

138158

reply: { text: "nothing important", btw: { question: "what changed?" } },

@@ -150,11 +170,7 @@ describe("handleBtwCommand", () => {

150170151171

const result = await handleBtwCommand(params, true);

152172153-

expect(runBtwSideQuestionMock).toHaveBeenCalledWith(

154-

expect.objectContaining({

155-

question: "what changed?",

156-

}),

157-

);

173+

expect(mockFirstObjectArg(runBtwSideQuestionMock).question).toBe("what changed?");

158174

expect(result).toEqual({

159175

shouldContinue: false,

160176

reply: { text: "alias answer", btw: { question: "what changed?" } },

@@ -174,10 +190,8 @@ describe("handleBtwCommand", () => {

174190175191

const result = await handleBtwCommand(params, true);

176192177-

expect(runBtwSideQuestionMock).toHaveBeenCalledWith(

178-

expect.objectContaining({

179-

agentDir: expect.stringContaining("/agents/worker-1/agent"),

180-

}),

193+

expect(String(mockFirstObjectArg(runBtwSideQuestionMock).agentDir)).toContain(

194+

"/agents/worker-1/agent",

181195

);

182196

expect(result).toEqual({

183197

shouldContinue: false,

@@ -199,14 +213,12 @@ describe("handleBtwCommand", () => {

199213200214

const result = await handleBtwCommand(params, true);

201215202-

expect(resolveSessionAgentIdMock).toHaveBeenCalledWith({

203-

sessionKey: "agent:worker-1:whatsapp:direct:12345",

204-

config: expect.any(Object),

205-

});

206-

expect(runBtwSideQuestionMock).toHaveBeenCalledWith(

207-

expect.objectContaining({

208-

agentDir: expect.stringContaining("/agents/worker-1/agent"),

209-

}),

216+

const sessionAgentArgs = mockFirstObjectArg(resolveSessionAgentIdMock);

217+

expect(sessionAgentArgs.sessionKey).toBe("agent:worker-1:whatsapp:direct:12345");

218+

expect(sessionAgentArgs.config).toBeTypeOf("object");

219+

expect(sessionAgentArgs.config).not.toBeNull();

220+

expect(String(mockFirstObjectArg(runBtwSideQuestionMock).agentDir)).toContain(

221+

"/agents/worker-1/agent",

210222

);

211223

expect(result).toEqual({

212224

shouldContinue: false,

@@ -229,16 +241,15 @@ describe("handleBtwCommand", () => {

229241230242

const result = await handleBtwCommand(params, true);

231243232-

expect(resolveSessionAgentIdMock).toHaveBeenCalledWith({

233-

sessionKey: "agent:worker-1:whatsapp:direct:12345",

234-

config: expect.any(Object),

235-

});

236-

expect(resolveAgentDirMock).toHaveBeenCalledWith(expect.any(Object), "worker-1");

237-

expect(runBtwSideQuestionMock).toHaveBeenCalledWith(

238-

expect.objectContaining({

239-

agentDir: "/tmp/worker-1-agent",

240-

}),

241-

);

244+

const canonicalAgentArgs = mockFirstObjectArg(resolveSessionAgentIdMock);

245+

expect(canonicalAgentArgs.sessionKey).toBe("agent:worker-1:whatsapp:direct:12345");

246+

expect(canonicalAgentArgs.config).toBeTypeOf("object");

247+

expect(canonicalAgentArgs.config).not.toBeNull();

248+

const resolveDirCall = mockCall(resolveAgentDirMock);

249+

expect(resolveDirCall[0]).toBeTypeOf("object");

250+

expect(resolveDirCall[0]).not.toBeNull();

251+

expect(resolveDirCall[1]).toBe("worker-1");

252+

expect(mockFirstObjectArg(runBtwSideQuestionMock).agentDir).toBe("/tmp/worker-1-agent");

242253

expect(result).toEqual({

243254

shouldContinue: false,

244255

reply: { text: "resolved fallback", btw: { question: "what changed?" } },

@@ -262,13 +273,8 @@ describe("handleBtwCommand", () => {

262273263274

const result = await handleBtwCommand(params, true);

264275265-

expect(runBtwSideQuestionMock).toHaveBeenCalledWith(

266-

expect.objectContaining({

267-

sessionEntry: expect.objectContaining({

268-

sessionId: "target-session",

269-

}),

270-

}),

271-

);

276+

const sideQuestionArgs = mockFirstObjectArg(runBtwSideQuestionMock);

277+

expectObjectFields(sideQuestionArgs.sessionEntry, { sessionId: "target-session" });

272278

expect(result).toEqual({

273279

shouldContinue: false,

274280

reply: { text: "target context", btw: { question: "what changed?" } },