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

推荐订阅源

雷峰网
雷峰网
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
大猫的无限游戏
大猫的无限游戏
Google DeepMind News
Google DeepMind News
V
V2EX
T
The Blog of Author Tim Ferriss
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Hugging Face - Blog
Hugging Face - Blog
Stack Overflow Blog
Stack Overflow Blog
I
InfoQ
博客园_首页
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Last Week in AI
Last Week in AI
Recent Announcements
Recent Announcements
Vercel News
Vercel News
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
Tailwind CSS Blog
美团技术团队
Martin Fowler
Martin Fowler
宝玉的分享
宝玉的分享
Blog — PlanetScale
Blog — PlanetScale
GbyAI
GbyAI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
J
Java Code Geeks

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: align zalo fixtures with open dm policy · openclaw/...
steipete · 2026-04-29 · via Recent Commits to openclaw:main

@@ -24,39 +24,43 @@ vi.mock("../infra/file-lock.js", () => ({

2424

withFileLock: async (_path: string, _options: unknown, fn: () => unknown) => await fn(),

2525

}));

262627-

vi.mock("../plugin-sdk/json-store.js", async () => {

28-

const fs = await import("node:fs/promises");

29-

const path = await import("node:path");

30-31-

return {

32-

readJsonFileWithFallback: async <T>(filePath: string, fallback: T) => {

33-

let raw: string;

34-

try {

35-

raw = await fs.readFile(filePath, "utf8");

36-

} catch (err) {

37-

if ((err as { code?: string }).code === "ENOENT") {

38-

return { value: fallback, exists: false };

39-

}

27+

const jsonStoreMocks = vi.hoisted(() => ({

28+

readJsonFileWithFallback: vi.fn(async <T>(filePath: string, fallback: T) => {

29+

const fs = await import("node:fs/promises");

30+

let raw: string;

31+

try {

32+

raw = await fs.readFile(filePath, "utf8");

33+

} catch (err) {

34+

if ((err as { code?: string }).code === "ENOENT") {

4035

return { value: fallback, exists: false };

4136

}

42-

try {

43-

const parsed = JSON.parse(raw) as T;

44-

return {

45-

value: parsed ?? fallback,

46-

exists: true,

47-

};

48-

} catch {

49-

return { value: fallback, exists: true };

50-

}

51-

},

52-

writeJsonFileAtomically: async (filePath: string, value: unknown) => {

53-

await fs.mkdir(path.dirname(filePath), { recursive: true });

54-

await fs.writeFile(filePath, `${JSON.stringify(value, null, 2)}\n`, "utf8");

55-

},

37+

return { value: fallback, exists: false };

38+

}

39+

try {

40+

const parsed = JSON.parse(raw) as T;

41+

return {

42+

value: parsed ?? fallback,

43+

exists: true,

44+

};

45+

} catch {

46+

return { value: fallback, exists: true };

47+

}

48+

}),

49+

writeJsonFileAtomically: vi.fn(async (filePath: string, value: unknown) => {

50+

const fs = await import("node:fs/promises");

51+

const path = await import("node:path");

52+

await fs.mkdir(path.dirname(filePath), { recursive: true });

53+

await fs.writeFile(filePath, `${JSON.stringify(value, null, 2)}\n`, "utf8");

54+

}),

55+

}));

56+57+

vi.mock("../plugin-sdk/json-store.js", () => {

58+

return {

59+

readJsonFileWithFallback: jsonStoreMocks.readJsonFileWithFallback,

60+

writeJsonFileAtomically: jsonStoreMocks.writeJsonFileAtomically,

5661

};

5762

});

586359-

import * as jsonStore from "../plugin-sdk/json-store.js";

6064

import {

6165

addChannelAllowFromStoreEntry,

6266

clearPairingAllowFromReadCacheForTest,

@@ -73,6 +77,7 @@ import {

7377

let fixtureRoot = "";

7478

let caseId = 0;

7579

type RandomIntSync = (minOrMax: number, max?: number) => number;

80+

type ReadSpy = ReturnType<typeof vi.fn> | MockInstance;

76817782

let randomIntSpy: MockInstance<RandomIntSync>;

7883

let nextRandomInt = 0;

@@ -176,9 +181,7 @@ async function seedTelegramAllowFromFixtures(params: {

176181

async function assertAllowFromCacheInvalidation(params: {

177182

stateDir: string;

178183

readAllowFrom: () => Promise<string[]>;

179-

readSpy: {

180-

mockRestore: () => void;

181-

};

184+

readSpy: ReadSpy;

182185

}) {

183186

const first = await params.readAllowFrom();

184187

const second = await params.readAllowFrom();

@@ -206,9 +209,8 @@ async function expectAccountScopedEntryIsolated(entry: string, accountId = "yy")

206209207210

async function withAllowFromCacheReadSpy(params: {

208211

stateDir: string;

209-

createReadSpy: () => {

210-

mockRestore: () => void;

211-

};

212+

createReadSpy: () => ReadSpy;

213+

cleanupReadSpy?: (readSpy: ReadSpy) => void;

212214

readAllowFrom: () => Promise<string[]>;

213215

}) {

214216

await writeAllowFromFixture({

@@ -218,12 +220,15 @@ async function withAllowFromCacheReadSpy(params: {

218220

allowFrom: ["1001"],

219221

});

220222

const readSpy = params.createReadSpy();

221-

await assertAllowFromCacheInvalidation({

222-

stateDir: params.stateDir,

223-

readAllowFrom: params.readAllowFrom,

224-

readSpy,

225-

});

226-

readSpy.mockRestore();

223+

try {

224+

await assertAllowFromCacheInvalidation({

225+

stateDir: params.stateDir,

226+

readAllowFrom: params.readAllowFrom,

227+

readSpy,

228+

});

229+

} finally {

230+

params.cleanupReadSpy?.(readSpy);

231+

}

227232

}

228233229234

async function seedDefaultAccountAllowFromFixture(stateDir: string) {

@@ -577,23 +582,25 @@ describe("pairing store", () => {

577582578583

it("reuses cached allowFrom reads and invalidates on file updates", async () => {

579584

await withTempStateDir(async (stateDir) => {

580-

for (const variant of [

581-

{

582-

createReadSpy: () => vi.spyOn(jsonStore, "readJsonFileWithFallback"),

583-

readAllowFrom: () => readChannelAllowFromStore("telegram", process.env, "yy"),

585+

clearOAuthFixtures(stateDir);

586+

await withAllowFromCacheReadSpy({

587+

stateDir,

588+

createReadSpy: () => {

589+

jsonStoreMocks.readJsonFileWithFallback.mockClear();

590+

return jsonStoreMocks.readJsonFileWithFallback;

584591

},

585-

{

586-

createReadSpy: () => vi.spyOn(fsSync, "readFileSync"),

587-

readAllowFrom: async () => readChannelAllowFromStoreSync("telegram", process.env, "yy"),

592+

readAllowFrom: () => readChannelAllowFromStore("telegram", process.env, "yy"),

593+

});

594+595+

clearOAuthFixtures(stateDir);

596+

await withAllowFromCacheReadSpy({

597+

stateDir,

598+

createReadSpy: () => vi.spyOn(fsSync, "readFileSync"),

599+

cleanupReadSpy: (readSpy) => {

600+

readSpy.mockRestore();

588601

},

589-

]) {

590-

clearOAuthFixtures(stateDir);

591-

await withAllowFromCacheReadSpy({

592-

stateDir,

593-

createReadSpy: variant.createReadSpy,

594-

readAllowFrom: variant.readAllowFrom,

595-

});

596-

}

602+

readAllowFrom: async () => readChannelAllowFromStoreSync("telegram", process.env, "yy"),

603+

});

597604

});

598605

});

599606

});