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

推荐订阅源

N
Netflix TechBlog - Medium
T
The Blog of Author Tim Ferriss
aimingoo的专栏
aimingoo的专栏
A
About on SuperTechFans
Stack Overflow Blog
Stack Overflow Blog
B
Blog RSS Feed
Microsoft Security Blog
Microsoft Security Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
人人都是产品经理
人人都是产品经理
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
J
Java Code Geeks
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
B
Blog
MongoDB | Blog
MongoDB | Blog
L
LangChain Blog
WordPress大学
WordPress大学
小众软件
小众软件
IT之家
IT之家
腾讯CDC
月光博客
月光博客
量子位
Blog — PlanetScale
Blog — PlanetScale
P
Proofpoint News Feed
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

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 gateway chat assertions · openclaw/openclaw...
steipete · 2026-05-11 · via Recent Commits to openclaw:main

@@ -130,6 +130,23 @@ describe("gateway server chat", () => {

130130

})

131131

.filter((value): value is string => typeof value === "string");

132132133+

const expectRecordFields = (value: unknown, expected: Record<string, unknown>) => {

134+

expect(value).toBeDefined();

135+

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

136+

expect(value).not.toBeNull();

137+

const actual = value as Record<string, unknown>;

138+

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

139+

expect(actual[key]).toEqual(expectedValue);

140+

}

141+

return actual;

142+

};

143+144+

const expectStringRunId = (payload: unknown) => {

145+

const actual = expectRecordFields(payload, {});

146+

expect(typeof actual.runId).toBe("string");

147+

return actual.runId as string;

148+

};

149+133150

const expectAgentWaitTimeout = (res: Awaited<ReturnType<typeof rpcReq>>) => {

134151

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

135152

expect(res.payload?.status).toBe("timeout");

@@ -308,7 +325,7 @@ describe("gateway server chat", () => {

308325

if (abortRes.payload?.status === "aborted") {

309326

expect(abortRes.payload?.abortedRunId).toBe("idem-sessions-abort-1");

310327

const cancelledEvent = await cancelledEventP;

311-

expect(cancelledEvent.payload?.data).toMatchObject({

328+

expectRecordFields(cancelledEvent.payload?.data, {

312329

phase: "end",

313330

status: "cancelled",

314331

aborted: true,

@@ -319,7 +336,7 @@ describe("gateway server chat", () => {

319336

timeoutMs: 0,

320337

});

321338

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

322-

expect(waitRes.payload).toMatchObject({

339+

expectRecordFields(waitRes.payload, {

323340

runId: "idem-sessions-abort-1",

324341

status: "timeout",

325342

stopReason: "rpc",

@@ -539,7 +556,7 @@ describe("gateway server chat", () => {

539556

CHAT_RESPONSE_TIMEOUT_MS,

540557

);

541558

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

542-

expect(imgRes.payload).toEqual(expect.objectContaining({ runId: expect.any(String) }));

559+

expectStringRunId(imgRes.payload);

543560

const reqIdOnly = "chat-img-only";

544561

ws.send(

545562

JSON.stringify({

@@ -568,7 +585,7 @@ describe("gateway server chat", () => {

568585

CHAT_RESPONSE_TIMEOUT_MS,

569586

);

570587

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

571-

expect(imgOnlyRes.payload).toEqual(expect.objectContaining({ runId: expect.any(String) }));

588+

expectStringRunId(imgOnlyRes.payload);

572589573590

const historyDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-gw-"));

574591

tempDirs.push(historyDir);

@@ -804,14 +821,14 @@ describe("gateway server chat", () => {

804821

});

805822

const sideResult = await sideResultPromise;

806823

const finalEvent = await finalPromise;

807-

expect(sideResult.payload).toMatchObject({

824+

expectRecordFields(sideResult.payload, {

808825

kind: "btw",

809826

runId: "idem-btw-1",

810827

sessionKey: "agent:main:main",

811828

question: "what is 17 * 19?",

812829

text: "323",

813830

});

814-

expect(finalEvent.payload).toMatchObject({

831+

expectRecordFields(finalEvent.payload, {

815832

runId: "idem-btw-1",

816833

sessionKey: "agent:main:main",

817834

state: "final",

@@ -886,7 +903,7 @@ describe("gateway server chat", () => {

886903

expect(dispatchInboundMessageMock).toHaveBeenCalled();

887904

});

888905

const sideResult = await sideResultPromise;

889-

expect(sideResult.payload).toMatchObject({

906+

expectRecordFields(sideResult.payload, {

890907

kind: "btw",

891908

runId: "idem-btw-block-1",

892909

question: "what changed?",

@@ -966,18 +983,17 @@ describe("gateway server chat", () => {

966983

throw new Error("expected assistant history message");

967984

}

968985

const assistantContent = (assistantMessage as { content?: unknown[] }).content ?? [];

969-

expect(assistantContent).toEqual([

970-

{ type: "text", text: "Image reply" },

971-

expect.objectContaining({

972-

type: "image",

973-

url: expect.stringContaining("/api/chat/media/outgoing/"),

974-

openUrl: expect.stringContaining("/full"),

975-

alt: "Generated image 1",

976-

mimeType: "image/png",

977-

width: 1,

978-

height: 1,

979-

}),

980-

]);

986+

expect(assistantContent).toHaveLength(2);

987+

expect(assistantContent[0]).toEqual({ type: "text", text: "Image reply" });

988+

const imageBlock = expectRecordFields(assistantContent[1], {

989+

type: "image",

990+

alt: "Generated image 1",

991+

mimeType: "image/png",

992+

width: 1,

993+

height: 1,

994+

});

995+

expect(String(imageBlock.url)).toContain("/api/chat/media/outgoing/");

996+

expect(String(imageBlock.openUrl)).toContain("/full");

981997

const serializedAssistant = JSON.stringify(assistantMessage);

982998

expect(serializedAssistant).not.toContain("data:image/png;base64");

983999

expect(serializedAssistant).not.toContain(pngB64);