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

推荐订阅源

博客园 - 三生石上(FineUI控件)
S
SegmentFault 最新的问题
Jina AI
Jina AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
IT之家
IT之家
美团技术团队
V
Visual Studio Blog
人人都是产品经理
人人都是产品经理
博客园 - 叶小钗
有赞技术团队
有赞技术团队
GbyAI
GbyAI
宝玉的分享
宝玉的分享
腾讯CDC
M
MIT News - Artificial intelligence
博客园 - 【当耐特】
Google DeepMind News
Google DeepMind News
月光博客
月光博客
MyScale Blog
MyScale Blog
Last Week in AI
Last Week in AI
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 司徒正美
Recent Announcements
Recent Announcements
MongoDB | Blog
MongoDB | 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
test: clear route reply broad matchers · openclaw/opencla...
steipete · 2026-05-11 · via Recent Commits to openclaw:main

@@ -106,10 +106,29 @@ function createChannelPlugin(

106106

};

107107

}

108108109-

function expectLastDelivery(

110-

matcher: Partial<Parameters<(typeof mocks.deliverOutboundPayloads.mock.calls)[number][0]>[0]>,

111-

) {

112-

expect(mocks.deliverOutboundPayloads).toHaveBeenLastCalledWith(expect.objectContaining(matcher));

109+

function lastDelivery() {

110+

const call = mocks.deliverOutboundPayloads.mock.calls.at(-1);

111+

expect(call).toBeDefined();

112+

const delivery = call?.[0];

113+

expect(typeof delivery).toBe("object");

114+

expect(delivery).not.toBeNull();

115+

return delivery as Record<string, unknown>;

116+

}

117+118+

function expectLastDeliveryFields(fields: Record<string, unknown>) {

119+

const delivery = lastDelivery();

120+

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

121+

expect(delivery[key]).toEqual(expected);

122+

}

123+

}

124+125+

function lastDeliveryPayload(index = 0): Record<string, unknown> {

126+

const payloads = lastDelivery().payloads;

127+

expect(Array.isArray(payloads)).toBe(true);

128+

const payload = (payloads as unknown[])[index];

129+

expect(typeof payload).toBe("object");

130+

expect(payload).not.toBeNull();

131+

return payload as Record<string, unknown>;

113132

}

114133115134

async function expectSlackNoDelivery(

@@ -225,15 +244,11 @@ describe("routeReply", () => {

225244

cfg: {} as never,

226245

});

227246

expect(res.ok).toBe(true);

228-

expectLastDelivery({

247+

expectLastDeliveryFields({

229248

channel: "slack",

230249

to: "channel:C123",

231-

payloads: [

232-

expect.objectContaining({

233-

text: `${SILENT_REPLY_TOKEN} -- (why am I here?)`,

234-

}),

235-

],

236250

});

251+

expect(lastDeliveryPayload().text).toBe(`${SILENT_REPLY_TOKEN} -- (why am I here?)`);

237252

});

238253239254

it("passes policySessionKey through to outbound delivery targets", async () => {

@@ -263,15 +278,11 @@ describe("routeReply", () => {

263278

});

264279265280

expect(res.ok).toBe(true);

266-

expectLastDelivery({

267-

payloads: [expect.objectContaining({ text: "native command response" })],

268-

session: expect.objectContaining({

269-

key: "agent:main:main",

270-

policyKey: "agent:main:direct:U123",

271-

}),

272-

});

273-

const session = mocks.deliverOutboundPayloads.mock.calls.at(-1)?.[0]?.session;

274-

expect(session).not.toEqual(expect.objectContaining({ conversationType: "group" }));

281+

expect(lastDeliveryPayload().text).toBe("native command response");

282+

const session = lastDelivery().session as Record<string, unknown>;

283+

expect(session.key).toBe("agent:main:main");

284+

expect(session.policyKey).toBe("agent:main:direct:U123");

285+

expect(session.conversationType).toBeUndefined();

275286

});

276287277288

it("uses explicit policy conversation type to preserve routed direct silent replies", async () => {

@@ -300,14 +311,11 @@ describe("routeReply", () => {

300311

});

301312302313

expect(res.ok).toBe(true);

303-

expectLastDelivery({

304-

payloads: [expect.objectContaining({ text: SILENT_REPLY_TOKEN })],

305-

session: expect.objectContaining({

306-

key: "agent:main:main",

307-

policyKey: "agent:main:main",

308-

conversationType: "direct",

309-

}),

310-

});

314+

expect(lastDeliveryPayload().text).toBe(SILENT_REPLY_TOKEN);

315+

const session = lastDelivery().session as Record<string, unknown>;

316+

expect(session.key).toBe("agent:main:main");

317+

expect(session.policyKey).toBe("agent:main:main");

318+

expect(session.conversationType).toBe("direct");

311319

});

312320313321

it("applies responsePrefix when routing", async () => {

@@ -320,9 +328,7 @@ describe("routeReply", () => {

320328

to: "channel:C123",

321329

cfg,

322330

});

323-

expectLastDelivery({

324-

payloads: [expect.objectContaining({ text: "[openclaw] hi" })],

325-

});

331+

expect(lastDeliveryPayload().text).toBe("[openclaw] hi");

326332

});

327333328334

it("routes directive-only Slack replies when interactive replies are enabled", async () => {

@@ -339,13 +345,7 @@ describe("routeReply", () => {

339345

to: "channel:C123",

340346

cfg,

341347

});

342-

expectLastDelivery({

343-

payloads: [

344-

expect.objectContaining({

345-

text: "[[slack_select: Choose one | Alpha:alpha]]",

346-

}),

347-

],

348-

});

348+

expect(lastDeliveryPayload().text).toBe("[[slack_select: Choose one | Alpha:alpha]]");

349349

});

350350351351

it("does not bypass the empty-reply guard for invalid Slack blocks", async () => {

@@ -378,9 +378,7 @@ describe("routeReply", () => {

378378

sessionKey: "agent:rich:main",

379379

cfg,

380380

});

381-

expectLastDelivery({

382-

payloads: [expect.objectContaining({ text: "hi" })],

383-

});

381+

expect(lastDeliveryPayload().text).toBe("hi");

384382

});

385383386384

it("uses threadId for Slack when replyToId is missing", async () => {

@@ -391,7 +389,7 @@ describe("routeReply", () => {

391389

threadId: "456.789",

392390

cfg: {} as never,

393391

});

394-

expectLastDelivery({

392+

expectLastDeliveryFields({

395393

channel: "slack",

396394

replyToId: "456.789",

397395

threadId: null,

@@ -406,7 +404,7 @@ describe("routeReply", () => {

406404

threadId: 42,

407405

cfg: {} as never,

408406

});

409-

expectLastDelivery({

407+

expectLastDeliveryFields({

410408

channel: "telegram",

411409

to: "telegram:123",

412410

threadId: 42,

@@ -420,10 +418,10 @@ describe("routeReply", () => {

420418

to: "channel:C123",

421419

cfg: {} as never,

422420

});

423-

expectLastDelivery({

421+

expectLastDeliveryFields({

424422

channel: "slack",

425-

payloads: [expect.objectContaining({ text: "BTW\nQuestion: what is 17 * 19?\n\n323" })],

426423

});

424+

expect(lastDeliveryPayload().text).toBe("BTW\nQuestion: what is 17 * 19?\n\n323");

427425

});

428426429427

it("formats BTW replies prominently on routed discord sends", async () => {

@@ -433,10 +431,10 @@ describe("routeReply", () => {

433431

to: "channel:123456",

434432

cfg: {} as never,

435433

});

436-

expectLastDelivery({

434+

expectLastDeliveryFields({

437435

channel: "discord",

438-

payloads: [expect.objectContaining({ text: "BTW\nQuestion: what is 17 * 19?\n\n323" })],

439436

});

437+

expect(lastDeliveryPayload().text).toBe("BTW\nQuestion: what is 17 * 19?\n\n323");

440438

});

441439442440

it("passes replyToId to Telegram sends", async () => {

@@ -446,7 +444,7 @@ describe("routeReply", () => {

446444

to: "telegram:123",

447445

cfg: {} as never,

448446

});

449-

expectLastDelivery({

447+

expectLastDeliveryFields({

450448

channel: "telegram",

451449

to: "telegram:123",

452450

replyToId: "123",

@@ -461,17 +459,13 @@ describe("routeReply", () => {

461459

cfg: {} as never,

462460

});

463461

expect(mocks.deliverOutboundPayloads).toHaveBeenCalledTimes(1);

464-

expectLastDelivery({

462+

expectLastDeliveryFields({

465463

channel: "slack",

466464

to: "channel:C123",

467-

payloads: [

468-

expect.objectContaining({

469-

text: "voice caption",

470-

mediaUrl: "file:///tmp/clip.mp3",

471-

audioAsVoice: true,

472-

}),

473-

],

474465

});

466+

expect(lastDeliveryPayload().text).toBe("voice caption");

467+

expect(lastDeliveryPayload().mediaUrl).toBe("file:///tmp/clip.mp3");

468+

expect(lastDeliveryPayload().audioAsVoice).toBe(true);

475469

});

476470477471

it("uses replyToId as threadTs for Slack", async () => {

@@ -481,7 +475,7 @@ describe("routeReply", () => {

481475

to: "channel:C123",

482476

cfg: {} as never,

483477

});

484-

expectLastDelivery({

478+

expectLastDeliveryFields({

485479

channel: "slack",

486480

replyToId: "1710000000.0001",

487481

threadId: null,

@@ -496,7 +490,7 @@ describe("routeReply", () => {

496490

threadId: "1710000000.9999",

497491

cfg: {} as never,

498492

});

499-

expectLastDelivery({

493+

expectLastDeliveryFields({

500494

channel: "slack",

501495

replyToId: "1710000000.9999",

502496

threadId: null,

@@ -511,7 +505,7 @@ describe("routeReply", () => {

511505

threadId: "1710000000.9999",

512506

cfg: {} as never,

513507

});

514-

expectLastDelivery({

508+

expectLastDeliveryFields({

515509

channel: "slack",

516510

replyToId: "1710000000.9999",

517511

threadId: null,

@@ -534,7 +528,7 @@ describe("routeReply", () => {

534528

},

535529

} as unknown as OpenClawConfig,

536530

});

537-

expectLastDelivery({

531+

expectLastDeliveryFields({

538532

channel: "mattermost",

539533

to: "channel:CHAN1",

540534

replyToId: "post-root",

@@ -549,15 +543,11 @@ describe("routeReply", () => {

549543

to: "channel:C123",

550544

cfg: {} as never,

551545

});

552-

expectLastDelivery({

546+

expectLastDeliveryFields({

553547

channel: "slack",

554-

payloads: [

555-

expect.objectContaining({

556-

text: "caption",

557-

mediaUrls: ["a", "b"],

558-

}),

559-

],

560548

});

549+

expect(lastDeliveryPayload().text).toBe("caption");

550+

expect(lastDeliveryPayload().mediaUrls).toEqual(["a", "b"]);

561551

});

562552563553

it("routes WhatsApp with the account id intact", async () => {

@@ -568,7 +558,7 @@ describe("routeReply", () => {

568558

accountId: "acc-1",

569559

cfg: {} as never,

570560

});

571-

expectLastDelivery({

561+

expectLastDeliveryFields({

572562

channel: "whatsapp",

573563

to: "+15551234567",

574564

accountId: "acc-1",

@@ -589,12 +579,12 @@ describe("routeReply", () => {

589579

to: "conversation:19:abc@thread.tacv2",

590580

cfg,

591581

});

592-

expectLastDelivery({

582+

expectLastDeliveryFields({

593583

channel: "msteams",

594584

to: "conversation:19:abc@thread.tacv2",

595585

cfg,

596-

payloads: [expect.objectContaining({ text: "hi" })],

597586

});

587+

expect(lastDeliveryPayload().text).toBe("hi");

598588

});

599589600590

it("passes mirror data when sessionKey is set", async () => {

@@ -607,14 +597,11 @@ describe("routeReply", () => {

607597

groupId: "channel:C123",

608598

cfg: {} as never,

609599

});

610-

expectLastDelivery({

611-

mirror: expect.objectContaining({

612-

sessionKey: "agent:main:main",

613-

text: "hi",

614-

isGroup: true,

615-

groupId: "channel:C123",

616-

}),

617-

});

600+

const mirror = lastDelivery().mirror as Record<string, unknown>;

601+

expect(mirror.sessionKey).toBe("agent:main:main");

602+

expect(mirror.text).toBe("hi");

603+

expect(mirror.isGroup).toBe(true);

604+

expect(mirror.groupId).toBe("channel:C123");

618605

});

619606620607

it("skips mirror data when mirror is false", async () => {

@@ -626,7 +613,7 @@ describe("routeReply", () => {

626613

mirror: false,

627614

cfg: {} as never,

628615

});

629-

expectLastDelivery({

616+

expectLastDeliveryFields({

630617

mirror: undefined,

631618

});

632619

});