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

推荐订阅源

Y
Y Combinator Blog
有赞技术团队
有赞技术团队
J
Java Code Geeks
H
Hackread – Cybersecurity News, Data Breaches, AI and More
美团技术团队
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Hugging Face - Blog
Hugging Face - Blog
人人都是产品经理
人人都是产品经理
酷 壳 – CoolShell
酷 壳 – CoolShell
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
C
Check Point Blog
博客园 - 【当耐特】
The GitHub Blog
The GitHub Blog
Recent Announcements
Recent Announcements
The Cloudflare Blog
Microsoft Azure Blog
Microsoft Azure Blog
腾讯CDC
Vercel News
Vercel News
IT之家
IT之家
MyScale Blog
MyScale Blog
博客园_首页
Martin Fowler
Martin Fowler
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 whatsapp session assertions · openclaw/open...
steipete · 2026-05-11 · via Recent Commits to openclaw:main

@@ -165,6 +165,27 @@ function requireValue<T>(value: T | undefined, label: string): T {

165165

return value;

166166

}

167167168+

function firstWriteFileCall(writeFileSpy: ReturnType<typeof vi.fn>): {

169+

data: unknown;

170+

options: { flag?: string; mode?: number };

171+

path: string;

172+

} {

173+

const [filePath, data, options] = writeFileSpy.mock.calls[0] ?? [];

174+

expect(typeof filePath).toBe("string");

175+

return {

176+

data,

177+

options: (options ?? {}) as { flag?: string; mode?: number },

178+

path: filePath as string,

179+

};

180+

}

181+182+

function expectRuntimeLogContaining(

183+

runtime: { log: ReturnType<typeof vi.fn> },

184+

text: string,

185+

): void {

186+

expect(runtime.log.mock.calls.some(([message]) => String(message).includes(text))).toBe(true);

187+

}

188+168189

describe("web session", () => {

169190

beforeAll(async () => {

170191

({

@@ -198,13 +219,11 @@ describe("web session", () => {

198219199220

await createWaSocket(true, false, { authDir });

200221

const makeWASocket = baileys.makeWASocket as ReturnType<typeof vi.fn>;

201-

expect(makeWASocket).toHaveBeenCalledWith(

202-

expect.objectContaining({

203-

printQRInTerminal: false,

204-

...DEFAULT_WHATSAPP_SOCKET_TIMING,

205-

}),

206-

);

207222

const passed = makeWASocket.mock.calls[0][0];

223+

expect(passed.printQRInTerminal).toBe(false);

224+

expect(passed.keepAliveIntervalMs).toBe(DEFAULT_WHATSAPP_SOCKET_TIMING.keepAliveIntervalMs);

225+

expect(passed.connectTimeoutMs).toBe(DEFAULT_WHATSAPP_SOCKET_TIMING.connectTimeoutMs);

226+

expect(passed.defaultQueryTimeoutMs).toBe(DEFAULT_WHATSAPP_SOCKET_TIMING.defaultQueryTimeoutMs);

208227

const passedLogger = (passed as { logger?: { level?: string; trace?: unknown } }).logger;

209228

expect(passedLogger?.level).toBe("silent");

210229

if (typeof passedLogger?.trace !== "function") {

@@ -213,11 +232,11 @@ describe("web session", () => {

213232

passedLogger.trace("ignored");

214233

await emitCredsUpdate(authDir);

215234216-

expect(openMock.writeFileSpy).toHaveBeenCalledWith(

217-

expect.stringContaining(path.join(authDir, ".creds.")),

218-

expect.any(String),

219-

expect.objectContaining({ mode: 0o600, flag: "wx" }),

220-

);

235+

const write = firstWriteFileCall(openMock.writeFileSpy);

236+

expect(write.path).toContain(path.join(authDir, ".creds."));

237+

expect(typeof write.data).toBe("string");

238+

expect(write.options.mode).toBe(0o600);

239+

expect(write.options.flag).toBe("wx");

221240

openMock.restore();

222241

});

223242

@@ -228,13 +247,10 @@ describe("web session", () => {

228247

defaultQueryTimeoutMs: 120_000,

229248

});

230249231-

expect(baileys.makeWASocket).toHaveBeenCalledWith(

232-

expect.objectContaining({

233-

keepAliveIntervalMs: 10_000,

234-

connectTimeoutMs: 90_000,

235-

defaultQueryTimeoutMs: 120_000,

236-

}),

237-

);

250+

const passed = (baileys.makeWASocket as ReturnType<typeof vi.fn>).mock.calls[0]?.[0];

251+

expect(passed.keepAliveIntervalMs).toBe(10_000);

252+

expect(passed.connectTimeoutMs).toBe(90_000);

253+

expect(passed.defaultQueryTimeoutMs).toBe(120_000);

238254

});

239255240256

it("uses ambient env proxy agent when HTTPS_PROXY is configured", async () => {

@@ -326,9 +342,7 @@ describe("web session", () => {

326342327343

logWebSelfId("/tmp/wa-creds", runtime as never, true);

328344329-

expect(runtime.log).toHaveBeenCalledWith(

330-

expect.stringContaining("Web Channel: +12345 (jid 12345@s.whatsapp.net)"),

331-

);

345+

expectRuntimeLogContaining(runtime, "Web Channel: +12345 (jid 12345@s.whatsapp.net)");

332346

creds.restore();

333347

});

334348

@@ -345,8 +359,9 @@ describe("web session", () => {

345359346360

logWebSelfId("/tmp/wa-creds", runtime as never, true);

347361348-

expect(runtime.log).toHaveBeenCalledWith(

349-

expect.stringContaining("Web Channel: +12345 (jid 12345@s.whatsapp.net, lid 777@lid)"),

362+

expectRuntimeLogContaining(

363+

runtime,

364+

"Web Channel: +12345 (jid 12345@s.whatsapp.net, lid 777@lid)",

350365

);

351366

creds.restore();

352367

});

@@ -515,13 +530,13 @@ describe("web session", () => {

515530

me: { id: "123@s.whatsapp.net" },

516531

});

517532518-

expect(openMock.writeFileSpy).toHaveBeenCalledWith(

519-

expect.stringContaining(

520-

path.join("/tmp", "openclaw-oauth", "whatsapp", "default", ".creds."),

521-

),

522-

expect.any(String),

523-

expect.objectContaining({ mode: 0o600, flag: "wx" }),

533+

const write = firstWriteFileCall(openMock.writeFileSpy);

534+

expect(write.path).toContain(

535+

path.join("/tmp", "openclaw-oauth", "whatsapp", "default", ".creds."),

524536

);

537+

expect(typeof write.data).toBe("string");

538+

expect(write.options.mode).toBe(0o600);

539+

expect(write.options.flag).toBe("wx");

525540

expect(openMock.tempHandles).toHaveLength(1);

526541

expect(openMock.tempHandles[0]?.sync).toHaveBeenCalledTimes(1);

527542

expect(openMock.tempHandles[0]?.close).toHaveBeenCalledTimes(1);

@@ -585,7 +600,7 @@ describe("web session", () => {

585600586601

expect(renameSpy).toHaveBeenCalledOnce();

587602

const parsedCreds = JSON.parse(raw) as unknown;

588-

expect(parsedCreds).toMatchObject(originalCreds);

603+

expect(parsedCreds).toEqual(originalCreds);

589604

expect(tempEntries).toHaveLength(0);

590605591606

renameSpy.mockRestore();