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

推荐订阅源

Martin Fowler
Martin Fowler
Blog — PlanetScale
Blog — PlanetScale
Vercel News
Vercel News
L
LangChain Blog
Google DeepMind News
Google DeepMind News
H
Hackread – Cybersecurity News, Data Breaches, AI and More
F
Fortinet All Blogs
The GitHub Blog
The GitHub Blog
Recent Announcements
Recent Announcements
D
DataBreaches.Net
云风的 BLOG
云风的 BLOG
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
A
About on SuperTechFans
博客园_首页
N
Netflix TechBlog - Medium
Y
Y Combinator Blog
Hugging Face - Blog
Hugging Face - Blog
Last Week in AI
Last Week in AI
酷 壳 – CoolShell
酷 壳 – CoolShell
B
Blog
Apple Machine Learning Research
Apple Machine Learning Research
罗磊的独立博客
美团技术团队
V
V2EX

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: clear outbound send service broad matchers · opencl...
steipete · 2026-05-10 · via Recent Commits to openclaw:main

@@ -99,6 +99,46 @@ type ExecuteSendContext = ExecuteSendInput["ctx"];

9999

let executePollAction: OutboundSendServiceModule["executePollAction"];

100100

let executeSendAction: OutboundSendServiceModule["executeSendAction"];

101101102+

type MockCalls = {

103+

mock: { calls: unknown[][] };

104+

};

105+106+

function requireRecord(value: unknown, label: string): Record<string, unknown> {

107+

expect(typeof value, label).toBe("object");

108+

expect(value, label).not.toBeNull();

109+

return value as Record<string, unknown>;

110+

}

111+112+

function requireArray(value: unknown, label: string): unknown[] {

113+

expect(Array.isArray(value), label).toBe(true);

114+

return value as unknown[];

115+

}

116+117+

function expectFields(record: Record<string, unknown>, expected: Record<string, unknown>) {

118+

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

119+

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

120+

}

121+

}

122+123+

function expectSingleCallFirstArg(

124+

mock: MockCalls,

125+

label = "mock first argument",

126+

): Record<string, unknown> {

127+

expect(mock.mock.calls).toHaveLength(1);

128+

const [firstArg] = mock.mock.calls[0] ?? [];

129+

return requireRecord(firstArg, label);

130+

}

131+132+

function expectSingleCallFields(

133+

mock: MockCalls,

134+

expected: Record<string, unknown>,

135+

label?: string,

136+

): Record<string, unknown> {

137+

const firstArg = expectSingleCallFirstArg(mock, label);

138+

expectFields(firstArg, expected);

139+

return firstArg;

140+

}

141+102142

describe("executeSendAction", () => {

103143

function pluginActionResult(messageId: string) {

104144

return {

@@ -121,9 +161,10 @@ describe("executeSendAction", () => {

121161

mediaUrls: string[];

122162

}>,

123163

) {

124-

expect(mocks.appendAssistantMessageToSessionTranscript).toHaveBeenCalledWith(

125-

expect.objectContaining({ ...expected, config: {} }),

126-

);

164+

expectSingleCallFields(mocks.appendAssistantMessageToSessionTranscript, {

165+

...expected,

166+

config: {},

167+

});

127168

}

128169129170

async function executePluginMirroredSend(params: {

@@ -213,14 +254,12 @@ describe("executeSendAction", () => {

213254

message: "hello",

214255

});

215256216-

expect(mocks.sendMessage).toHaveBeenCalledWith(

217-

expect.objectContaining({

218-

agentId: "work",

219-

channel: "demo-outbound",

220-

to: "channel:123",

221-

content: "hello",

222-

}),

223-

);

257+

expectSingleCallFields(mocks.sendMessage, {

258+

agentId: "work",

259+

channel: "demo-outbound",

260+

to: "channel:123",

261+

content: "hello",

262+

});

224263

});

225264226265

it("forwards requesterSenderId to sendMessage on core outbound path", async () => {

@@ -245,11 +284,9 @@ describe("executeSendAction", () => {

245284

message: "hello",

246285

});

247286248-

expect(mocks.sendMessage).toHaveBeenCalledWith(

249-

expect.objectContaining({

250-

requesterSenderId: "attacker",

251-

}),

252-

);

287+

expectSingleCallFields(mocks.sendMessage, {

288+

requesterSenderId: "attacker",

289+

});

253290

});

254291255292

it("forwards non-id requester sender fields to sendMessage on core outbound path", async () => {

@@ -276,13 +313,11 @@ describe("executeSendAction", () => {

276313

message: "hello",

277314

});

278315279-

expect(mocks.sendMessage).toHaveBeenCalledWith(

280-

expect.objectContaining({

281-

requesterSenderName: "Alice",

282-

requesterSenderUsername: "alice_u",

283-

requesterSenderE164: "+15551234567",

284-

}),

285-

);

316+

expectSingleCallFields(mocks.sendMessage, {

317+

requesterSenderName: "Alice",

318+

requesterSenderUsername: "alice_u",

319+

requesterSenderE164: "+15551234567",

320+

});

286321

});

287322288323

it("forwards requester session context to sendMessage on core outbound path", async () => {

@@ -309,26 +344,22 @@ describe("executeSendAction", () => {

309344

message: "hello",

310345

});

311346312-

expect(mocks.sendMessage).toHaveBeenCalledWith(

313-

expect.objectContaining({

314-

requesterSessionKey: "agent:main:directchat:group:ops",

315-

requesterAccountId: "source-account",

316-

requesterSenderId: "attacker",

317-

accountId: "destination-account",

318-

}),

319-

);

347+

expectSingleCallFields(mocks.sendMessage, {

348+

requesterSessionKey: "agent:main:directchat:group:ops",

349+

requesterAccountId: "source-account",

350+

requesterSenderId: "attacker",

351+

accountId: "destination-account",

352+

});

320353

});

321354322355

it("forwards requesterSenderId into outbound media access resolution", async () => {

323356

await executePluginMediaSend({

324357

requesterSenderId: "attacker",

325358

});

326359327-

expect(mocks.resolveAgentScopedOutboundMediaAccess).toHaveBeenCalledWith(

328-

expect.objectContaining({

329-

requesterSenderId: "attacker",

330-

}),

331-

);

360+

expectSingleCallFields(mocks.resolveAgentScopedOutboundMediaAccess, {

361+

requesterSenderId: "attacker",

362+

});

332363

});

333364334365

it("forwards non-id requester sender fields into outbound media access resolution", async () => {

@@ -338,26 +369,22 @@ describe("executeSendAction", () => {

338369

requesterSenderE164: "+15551234567",

339370

});

340371341-

expect(mocks.resolveAgentScopedOutboundMediaAccess).toHaveBeenCalledWith(

342-

expect.objectContaining({

343-

requesterSenderName: "Alice",

344-

requesterSenderUsername: "alice_u",

345-

requesterSenderE164: "+15551234567",

346-

}),

347-

);

372+

expectSingleCallFields(mocks.resolveAgentScopedOutboundMediaAccess, {

373+

requesterSenderName: "Alice",

374+

requesterSenderUsername: "alice_u",

375+

requesterSenderE164: "+15551234567",

376+

});

348377

});

349378350379

it("keeps requester session channel authoritative for media policy", async () => {

351380

await executePluginMediaSend({

352381

requesterSenderId: "attacker",

353382

});

354383355-

expect(mocks.resolveAgentScopedOutboundMediaAccess).toHaveBeenCalledWith(

356-

expect.objectContaining({

357-

sessionKey: "agent:main:directchat:group:ops",

358-

messageProvider: undefined,

359-

}),

360-

);

384+

expectSingleCallFields(mocks.resolveAgentScopedOutboundMediaAccess, {

385+

sessionKey: "agent:main:directchat:group:ops",

386+

messageProvider: undefined,

387+

});

361388

});

362389363390

it("uses requester account for media policy when session context is present", async () => {

@@ -367,12 +394,10 @@ describe("executeSendAction", () => {

367394

accountId: "destination-account",

368395

});

369396370-

expect(mocks.resolveAgentScopedOutboundMediaAccess).toHaveBeenCalledWith(

371-

expect.objectContaining({

372-

sessionKey: "agent:main:directchat:group:ops",

373-

accountId: "source-account",

374-

}),

375-

);

397+

expectSingleCallFields(mocks.resolveAgentScopedOutboundMediaAccess, {

398+

sessionKey: "agent:main:directchat:group:ops",

399+

accountId: "source-account",

400+

});

376401

});

377402378403

it("falls back to destination account for media policy when requester account is missing", async () => {

@@ -381,12 +406,10 @@ describe("executeSendAction", () => {

381406

accountId: "destination-account",

382407

});

383408384-

expect(mocks.resolveAgentScopedOutboundMediaAccess).toHaveBeenCalledWith(

385-

expect.objectContaining({

386-

sessionKey: "agent:main:directchat:group:ops",

387-

accountId: "destination-account",

388-

}),

389-

);

409+

expectSingleCallFields(mocks.resolveAgentScopedOutboundMediaAccess, {

410+

sessionKey: "agent:main:directchat:group:ops",

411+

accountId: "destination-account",

412+

});

390413

});

391414392415

it("falls back to destination account when forwarding requester context to sendMessage", async () => {

@@ -412,12 +435,10 @@ describe("executeSendAction", () => {

412435

message: "hello",

413436

});

414437415-

expect(mocks.sendMessage).toHaveBeenCalledWith(

416-

expect.objectContaining({

417-

requesterSessionKey: "agent:main:directchat:group:ops",

418-

requesterAccountId: "destination-account",

419-

}),

420-

);

438+

expectSingleCallFields(mocks.sendMessage, {

439+

requesterSessionKey: "agent:main:directchat:group:ops",

440+

requesterAccountId: "destination-account",

441+

});

421442

});

422443423444

it("uses plugin poll action when available", async () => {

@@ -488,12 +509,10 @@ describe("executeSendAction", () => {

488509

agentId: "agent-1",

489510

mediaSources: [],

490511

});

491-

expect(mocks.dispatchChannelMessageAction).toHaveBeenCalledWith(

492-

expect.objectContaining({

493-

mediaLocalRoots: ["/tmp/agent-roots"],

494-

mediaReadFile: mocks.createAgentScopedHostMediaReadFile.mock.results[0]?.value,

495-

}),

496-

);

512+

expectSingleCallFields(mocks.dispatchChannelMessageAction, {

513+

mediaLocalRoots: ["/tmp/agent-roots"],

514+

mediaReadFile: mocks.createAgentScopedHostMediaReadFile.mock.results[0]?.value,

515+

});

497516

});

498517499518

it("passes concrete media sources when widening plugin dispatch roots", async () => {

@@ -581,19 +600,17 @@ describe("executeSendAction", () => {

581600

});

582601583602

expect(mocks.dispatchChannelMessageAction).not.toHaveBeenCalled();

584-

expect(mocks.sendMessage).toHaveBeenCalledWith(

585-

expect.objectContaining({

586-

to: "channel:123",

587-

content: "hello",

588-

dryRun: true,

589-

silent: true,

590-

gateway: expect.objectContaining({

591-

url: "http://127.0.0.1:18789",

592-

token: "tok",

593-

timeoutMs: 5000,

594-

}),

595-

}),

596-

);

603+

const sendArgs = expectSingleCallFields(mocks.sendMessage, {

604+

to: "channel:123",

605+

content: "hello",

606+

dryRun: true,

607+

silent: true,

608+

});

609+

expectFields(requireRecord(sendArgs.gateway, "send gateway"), {

610+

url: "http://127.0.0.1:18789",

611+

token: "tok",

612+

timeoutMs: 5000,

613+

});

597614

});

598615599616

it("routes prepared plugin send payloads through core best-effort delivery by default", async () => {

@@ -631,13 +648,14 @@ describe("executeSendAction", () => {

631648632649

expect(prepareSendPayload).toHaveBeenCalled();

633650

expect(mocks.dispatchChannelMessageAction).not.toHaveBeenCalled();

634-

expect(mocks.sendMessage).toHaveBeenCalledWith(

635-

expect.objectContaining({

636-

channel: "discord",

637-

queuePolicy: "best_effort",

638-

payloads: [expect.objectContaining({ channelData: { prepared: true } })],

639-

}),

640-

);

651+

const sendArgs = expectSingleCallFields(mocks.sendMessage, {

652+

channel: "discord",

653+

queuePolicy: "best_effort",

654+

});

655+

const [payload] = requireArray(sendArgs.payloads, "send payloads");

656+

expectFields(requireRecord(payload, "prepared payload"), {

657+

channelData: { prepared: true },

658+

});

641659

});

642660643661

it("uses required core delivery only when the send action opts out of best-effort", async () => {

@@ -674,12 +692,10 @@ describe("executeSendAction", () => {

674692

bestEffort: false,

675693

});

676694677-

expect(mocks.sendMessage).toHaveBeenCalledWith(

678-

expect.objectContaining({

679-

channel: "discord",

680-

queuePolicy: "required",

681-

}),

682-

);

695+

expectSingleCallFields(mocks.sendMessage, {

696+

channel: "discord",

697+

queuePolicy: "required",

698+

});

683699

});

684700685701

it("forwards poll args to sendPoll on core outbound path", async () => {

@@ -714,19 +730,17 @@ describe("executeSendAction", () => {

714730

}),

715731

});

716732717-

expect(mocks.sendPoll).toHaveBeenCalledWith(

718-

expect.objectContaining({

719-

channel: "demo-outbound",

720-

accountId: "acc-1",

721-

to: "channel:123",

722-

question: "Lunch?",

723-

options: ["Pizza", "Sushi"],

724-

maxSelections: 1,

725-

durationSeconds: 300,

726-

threadId: "thread-1",

727-

isAnonymous: true,

728-

}),

729-

);

733+

expectSingleCallFields(mocks.sendPoll, {

734+

channel: "demo-outbound",

735+

accountId: "acc-1",

736+

to: "channel:123",

737+

question: "Lunch?",

738+

options: ["Pizza", "Sushi"],

739+

maxSelections: 1,

740+

durationSeconds: 300,

741+

threadId: "thread-1",

742+

isAnonymous: true,

743+

});

730744

});

731745732746

it("skips plugin dispatch during dry-run polls and forwards durationHours + silent", async () => {

@@ -766,19 +780,17 @@ describe("executeSendAction", () => {

766780

});

767781768782

expect(mocks.dispatchChannelMessageAction).not.toHaveBeenCalled();

769-

expect(mocks.sendPoll).toHaveBeenCalledWith(

770-

expect.objectContaining({

771-

to: "channel:123",

772-

question: "Lunch?",

773-

durationHours: 6,

774-

dryRun: true,

775-

silent: true,

776-

gateway: expect.objectContaining({

777-

url: "http://127.0.0.1:18789",

778-

token: "tok",

779-

timeoutMs: 5000,

780-

}),

781-

}),

782-

);

783+

const pollArgs = expectSingleCallFields(mocks.sendPoll, {

784+

to: "channel:123",

785+

question: "Lunch?",

786+

durationHours: 6,

787+

dryRun: true,

788+

silent: true,

789+

});

790+

expectFields(requireRecord(pollArgs.gateway, "poll gateway"), {

791+

url: "http://127.0.0.1:18789",

792+

token: "tok",

793+

timeoutMs: 5000,

794+

});

783795

});

784796

});