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

推荐订阅源

雷峰网
雷峰网
博客园 - 聂微东
酷 壳 – CoolShell
酷 壳 – CoolShell
宝玉的分享
宝玉的分享
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
罗磊的独立博客
Hugging Face - Blog
Hugging Face - Blog
T
Tailwind CSS Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
IT之家
IT之家
博客园_首页
博客园 - 三生石上(FineUI控件)
博客园 - 叶小钗
Apple Machine Learning Research
Apple Machine Learning Research
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
量子位
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
人人都是产品经理
人人都是产品经理
美团技术团队
小众软件
小众软件
Jina AI
Jina AI
S
SegmentFault 最新的问题
博客园 - Franky
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com

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: guard session hook mock calls · openclaw/openclaw@b...
steipete · 2026-05-12 · via Recent Commits to openclaw:main

@@ -145,6 +145,24 @@ function expectFields(value: unknown, expected: Record<string, unknown>): void {

145145

}

146146

}

147147148+

function requireHookCall(

149+

mock: ReturnType<typeof vi.fn>,

150+

label: string,

151+

): readonly [Record<string, unknown>, Record<string, unknown> | undefined] {

152+

const call = mock.mock.calls.at(0);

153+

if (!call) {

154+

throw new Error(`expected ${label} hook call`);

155+

}

156+

const [event, context] = call;

157+

if (!event || typeof event !== "object") {

158+

throw new Error(`expected ${label} hook event`);

159+

}

160+

if (context !== undefined && (!context || typeof context !== "object")) {

161+

throw new Error(`expected ${label} hook context`);

162+

}

163+

return [event as Record<string, unknown>, context as Record<string, unknown> | undefined];

164+

}

165+148166

describe("session hook context wiring", () => {

149167

beforeEach(() => {

150168

hookRunnerMocks.hasHooks.mockReset();

@@ -177,7 +195,7 @@ describe("session hook context wiring", () => {

177195

});

178196179197

expect(hookRunnerMocks.runSessionStart).toHaveBeenCalledTimes(1);

180-

const [event, context] = hookRunnerMocks.runSessionStart.mock.calls[0] ?? [];

198+

const [event, context] = requireHookCall(hookRunnerMocks.runSessionStart, "session_start");

181199

expectFields(event, { sessionKey });

182200

expectFields(context, { sessionKey, agentId: "main", sessionId: event?.sessionId });

183201

});

@@ -199,7 +217,7 @@ describe("session hook context wiring", () => {

199217200218

expect(hookRunnerMocks.runSessionEnd).toHaveBeenCalledTimes(1);

201219

expect(hookRunnerMocks.runSessionStart).toHaveBeenCalledTimes(1);

202-

const [event, context] = hookRunnerMocks.runSessionEnd.mock.calls[0] ?? [];

220+

const [event, context] = requireHookCall(hookRunnerMocks.runSessionEnd, "session_end");

203221

expectFields(event, {

204222

sessionKey,

205223

reason: "new",

@@ -208,7 +226,10 @@ describe("session hook context wiring", () => {

208226

expectFields(context, { sessionKey, agentId: "main", sessionId: event?.sessionId });

209227

expect(event?.sessionFile).toContain(".jsonl.reset.");

210228211-

const [startEvent, startContext] = hookRunnerMocks.runSessionStart.mock.calls[0] ?? [];

229+

const [startEvent, startContext] = requireHookCall(

230+

hookRunnerMocks.runSessionStart,

231+

"session_start",

232+

);

212233

expectFields(startEvent, { resumedFrom: "old-session" });

213234

expect(event?.nextSessionId).toBe(startEvent?.sessionId);

214235

expectFields(startContext, { sessionId: startEvent?.sessionId });

@@ -230,7 +251,7 @@ describe("session hook context wiring", () => {

230251

commandAuthorized: true,

231252

});

232253233-

const [event] = hookRunnerMocks.runSessionEnd.mock.calls[0] ?? [];

254+

const [event] = requireHookCall(hookRunnerMocks.runSessionEnd, "session_end");

234255

expectFields(event, { reason: "reset" });

235256

});

236257

@@ -255,7 +276,7 @@ describe("session hook context wiring", () => {

255276

commandAuthorized: true,

256277

});

257278258-

const [event] = hookRunnerMocks.runSessionEnd.mock.calls[0] ?? [];

279+

const [event] = requireHookCall(hookRunnerMocks.runSessionEnd, "session_end");

259280

expectFields(event, { reason: "new" });

260281

});

261282

@@ -272,8 +293,8 @@ describe("session hook context wiring", () => {

272293

updatedAt: new Date(2026, 0, 18, 3, 0, 0).getTime(),

273294

});

274295275-

const [event] = hookRunnerMocks.runSessionEnd.mock.calls[0] ?? [];

276-

const [startEvent] = hookRunnerMocks.runSessionStart.mock.calls[0] ?? [];

296+

const [event] = requireHookCall(hookRunnerMocks.runSessionEnd, "session_end");

297+

const [startEvent] = requireHookCall(hookRunnerMocks.runSessionStart, "session_start");

277298

expectFields(event, {

278299

reason: "daily",

279300

transcriptArchived: true,

@@ -302,7 +323,7 @@ describe("session hook context wiring", () => {

302323

},

303324

});

304325305-

const [event] = hookRunnerMocks.runSessionEnd.mock.calls[0] ?? [];

326+

const [event] = requireHookCall(hookRunnerMocks.runSessionEnd, "session_end");

306327

expectFields(event, { reason: "idle" });

307328

} finally {

308329

vi.useRealTimers();

@@ -327,7 +348,7 @@ describe("session hook context wiring", () => {

327348

},

328349

});

329350330-

const [event] = hookRunnerMocks.runSessionEnd.mock.calls[0] ?? [];

351+

const [event] = requireHookCall(hookRunnerMocks.runSessionEnd, "session_end");

331352

expectFields(event, { reason: "idle" });

332353

} finally {

333354

vi.useRealTimers();