test: trace stored attachment previews · openclaw/openclaw@5cefebd
shakkernerd
·
2026-05-13
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -954,6 +954,8 @@ describe("sendChatMessage", () => {
|
954 | 954 | dataUrl: `data:application/pdf;base64,${Buffer.from(pdfBytes).toString("base64")}`, |
955 | 955 | file, |
956 | 956 | }); |
| 957 | +const previewUrl = attachment.previewUrl; |
| 958 | +expect(previewUrl).toMatch(/^blob:nodedata:/u); |
957 | 959 | |
958 | 960 | const result = await sendChatMessage(state, "summarize", [attachment]); |
959 | 961 | |
@@ -968,9 +970,24 @@ describe("sendChatMessage", () => {
|
968 | 970 | const attachmentRecord = requireRecord(attachmentParam); |
969 | 971 | expect(attachmentRecord.type).toBe("file"); |
970 | 972 | expect(attachmentRecord.content).toBe(Buffer.from(pdfBytes).toString("base64")); |
971 | | -expect(JSON.stringify(state.chatMessages)).not.toContain( |
972 | | -Buffer.from(pdfBytes).toString("base64"), |
973 | | -); |
| 973 | +expect(state.chatMessages).toStrictEqual([ |
| 974 | +{ |
| 975 | +role: "user", |
| 976 | +content: [ |
| 977 | +{ type: "text", text: "summarize" }, |
| 978 | +{ |
| 979 | +type: "attachment", |
| 980 | +attachment: { |
| 981 | +url: previewUrl, |
| 982 | +kind: "document", |
| 983 | +label: "brief.pdf", |
| 984 | +mimeType: "application/pdf", |
| 985 | +}, |
| 986 | +}, |
| 987 | +], |
| 988 | +timestamp: expect.any(Number), |
| 989 | +}, |
| 990 | +]); |
974 | 991 | }); |
975 | 992 | |
976 | 993 | it("formats structured non-auth connect failures for chat send", async () => { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。