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

推荐订阅源

雷峰网
雷峰网
WordPress大学
WordPress大学
MyScale Blog
MyScale Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
T
The Blog of Author Tim Ferriss
U
Unit 42
罗磊的独立博客
G
Google Developers Blog
Microsoft Azure Blog
Microsoft Azure Blog
The Cloudflare Blog
aimingoo的专栏
aimingoo的专栏
Vercel News
Vercel News
N
Netflix TechBlog - Medium
H
Hackread – Cybersecurity News, Data Breaches, AI and More
云风的 BLOG
云风的 BLOG
Hugging Face - Blog
Hugging Face - Blog
大猫的无限游戏
大猫的无限游戏
F
Fortinet All Blogs
博客园 - 聂微东
Stack Overflow Blog
Stack Overflow Blog
小众软件
小众软件
博客园 - 【当耐特】
H
Help Net Security
The GitHub Blog
The GitHub 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
refactor: share tasks handler test helpers · openclaw/ope...
vincentkoc · 2026-06-01 · via Recent Commits to openclaw:main

@@ -60,6 +60,32 @@ function createContext() {

6060

} as never;

6161

}

626263+

async function runTaskHandler(

64+

method: "tasks.list" | "tasks.get" | "tasks.cancel",

65+

params: Record<string, unknown>,

66+

) {

67+

const { calls, respond } = captureRespond();

68+

await tasksHandlers[method]({

69+

req: { type: "req", id: `req-${method}`, method },

70+

params,

71+

respond,

72+

context: createContext(),

73+

client: null,

74+

isWebchatConnect: () => false,

75+

});

76+

return {

77+

calls,

78+

payload: calls[0]?.[1] as TaskResponsePayload | undefined,

79+

};

80+

}

81+82+

async function getTaskPayload(taskId: string) {

83+

const { calls, payload } = await runTaskHandler("tasks.get", { taskId });

84+

expect(calls[0]?.[0]).toBe(true);

85+

expect(payload?.task?.id).toBe(taskId);

86+

return { calls, payload };

87+

}

88+6389

describe("tasks gateway handlers", () => {

6490

it("lists task summaries with SDK-facing statuses and filters", async () => {

6591

const running = createTaskRecord({

@@ -86,22 +112,13 @@ describe("tasks gateway handlers", () => {

86112

deliveryStatus: "pending",

87113

});

8811489-

const { calls, respond } = captureRespond();

90-

await tasksHandlers["tasks.list"]({

91-

req: { type: "req", id: "req-1", method: "tasks.list" },

92-

params: {

93-

status: "running",

94-

agentId: "main",

95-

sessionKey: "agent:main:main",

96-

},

97-

respond,

98-

context: createContext(),

99-

client: null,

100-

isWebchatConnect: () => false,

115+

const { calls, payload } = await runTaskHandler("tasks.list", {

116+

status: "running",

117+

agentId: "main",

118+

sessionKey: "agent:main:main",

101119

});

102120103121

expect(calls[0]?.[0]).toBe(true);

104-

const payload = calls[0]?.[1] as TaskResponsePayload | undefined;

105122

expect(payload?.tasks).toHaveLength(1);

106123

const listedTask = payload?.tasks?.[0];

107124

expect(listedTask?.id).toBe(running.taskId);

@@ -128,19 +145,8 @@ describe("tasks gateway handlers", () => {

128145

deliveryStatus: "not_applicable",

129146

});

130147131-

const { calls, respond } = captureRespond();

132-

await tasksHandlers["tasks.get"]({

133-

req: { type: "req", id: "req-2", method: "tasks.get" },

134-

params: { taskId: task.taskId },

135-

respond,

136-

context: createContext(),

137-

client: null,

138-

isWebchatConnect: () => false,

139-

});

148+

const { payload } = await getTaskPayload(task.taskId);

140149141-

expect(calls[0]?.[0]).toBe(true);

142-

const payload = calls[0]?.[1] as TaskResponsePayload | undefined;

143-

expect(payload?.task?.id).toBe(task.taskId);

144150

expect(payload?.task?.status).toBe("completed");

145151

expect(payload?.task?.title).toBe("Done task");

146152

});

@@ -172,19 +178,8 @@ describe("tasks gateway handlers", () => {

172178

error: "Tool failed\nOpenClaw runtime context (internal): Keep internal details private.",

173179

});

174180175-

const { calls, respond } = captureRespond();

176-

await tasksHandlers["tasks.get"]({

177-

req: { type: "req", id: "req-sanitized", method: "tasks.get" },

178-

params: { taskId: task.taskId },

179-

respond,

180-

context: createContext(),

181-

client: null,

182-

isWebchatConnect: () => false,

183-

});

181+

const { calls, payload } = await getTaskPayload(task.taskId);

184182185-

expect(calls[0]?.[0]).toBe(true);

186-

const payload = calls[0]?.[1] as TaskResponsePayload | undefined;

187-

expect(payload?.task?.id).toBe(task.taskId);

188183

expect(payload?.task?.title).toBe("Compile artifact");

189184

expect(payload?.task?.terminalSummary).toBe("Failed after build");

190185

expect(payload?.task?.error).toBe("Tool failed");

@@ -203,18 +198,12 @@ describe("tasks gateway handlers", () => {

203198

deliveryStatus: "pending",

204199

});

205200206-

const { calls, respond } = captureRespond();

207-

await tasksHandlers["tasks.cancel"]({

208-

req: { type: "req", id: "req-3", method: "tasks.cancel" },

209-

params: { taskId: task.taskId, reason: "user stopped task" },

210-

respond,

211-

context: createContext(),

212-

client: null,

213-

isWebchatConnect: () => false,

201+

const { calls, payload } = await runTaskHandler("tasks.cancel", {

202+

taskId: task.taskId,

203+

reason: "user stopped task",

214204

});

215205216206

expect(calls[0]?.[0]).toBe(true);

217-

const payload = calls[0]?.[1] as TaskResponsePayload | undefined;

218207

expect(payload?.found).toBe(true);

219208

expect(payload?.cancelled).toBe(true);

220209

expect(payload?.task?.id).toBe(task.taskId);