























@@ -57,14 +57,19 @@ describe("matrix observed event normalization", () => {
5757msgtype: "m.notice",
5858},
5959}),
60-).toEqual(
61-expect.objectContaining({
62-kind: "notice",
63-eventId: "$notice",
64-msgtype: "m.notice",
65-type: "m.room.message",
66-}),
67-);
60+).toEqual({
61+kind: "notice",
62+roomId: "!room:matrix-qa.test",
63+eventId: "$notice",
64+sender: "@sut:matrix-qa.test",
65+stateKey: undefined,
66+type: "m.room.message",
67+originServerTs: undefined,
68+body: "notice",
69+formattedBody: undefined,
70+msgtype: "m.notice",
71+membership: undefined,
72+});
6873});
69747075it("prefers m.new_content text for Matrix replacement events", () => {
@@ -86,18 +91,25 @@ describe("matrix observed event normalization", () => {
8691},
8792},
8893}),
89-).toEqual(
90-expect.objectContaining({
91-kind: "message",
92-eventId: "$replace",
93-body: "finalized",
94-msgtype: "m.text",
95-relatesTo: {
96-eventId: "$draft",
97-relType: "m.replace",
98-},
99-}),
100-);
94+).toEqual({
95+kind: "message",
96+roomId: "!room:matrix-qa.test",
97+eventId: "$replace",
98+sender: "@sut:matrix-qa.test",
99+stateKey: undefined,
100+type: "m.room.message",
101+originServerTs: undefined,
102+body: "finalized",
103+formattedBody: undefined,
104+msgtype: "m.text",
105+membership: undefined,
106+relatesTo: {
107+eventId: "$draft",
108+inReplyToId: undefined,
109+isFallingBack: undefined,
110+relType: "m.replace",
111+},
112+});
101113});
102114103115it("normalizes Matrix reaction events with target metadata", () => {
@@ -154,20 +166,29 @@ describe("matrix observed event normalization", () => {
154166},
155167},
156168}),
157-).toEqual(
158-expect.objectContaining({
159-approval: {
160-allowedDecisions: ["allow-once", "deny"],
161-commandTextPreview: commandText.slice(0, 160),
162-hasCommandText: true,
163-id: "approval-1",
164-kind: "exec",
165-state: "pending",
166-type: "approval.request",
167-version: 1,
168-},
169-}),
170-);
169+).toEqual({
170+kind: "message",
171+roomId: "!room:matrix-qa.test",
172+eventId: "$approval",
173+sender: "@sut:matrix-qa.test",
174+stateKey: undefined,
175+type: "m.room.message",
176+originServerTs: undefined,
177+body: "React here: ✅ Allow once, ❌ Deny",
178+formattedBody: undefined,
179+msgtype: "m.text",
180+membership: undefined,
181+approval: {
182+allowedDecisions: ["allow-once", "deny"],
183+commandTextPreview: commandText.slice(0, 160),
184+hasCommandText: true,
185+id: "approval-1",
186+kind: "exec",
187+state: "pending",
188+type: "approval.request",
189+version: 1,
190+},
191+});
171192});
172193173194it("summarizes Matrix plugin approval metadata fields", () => {
@@ -193,22 +214,31 @@ describe("matrix observed event normalization", () => {
193214},
194215},
195216}),
196-).toEqual(
197-expect.objectContaining({
198-approval: {
199-agentId: "qa",
200-allowedDecisions: ["allow-once", "deny"],
201-id: "plugin:approval-1",
202-kind: "plugin",
203-pluginId: "qa-plugin",
204-severity: "medium",
205-state: "pending",
206-toolName: "qa_tool",
207-type: "approval.request",
208-version: 1,
209-},
210-}),
211-);
217+).toEqual({
218+kind: "message",
219+roomId: "!room:matrix-qa.test",
220+eventId: "$plugin-approval",
221+sender: "@sut:matrix-qa.test",
222+stateKey: undefined,
223+type: "m.room.message",
224+originServerTs: undefined,
225+body: "Plugin approval required",
226+formattedBody: undefined,
227+msgtype: "m.text",
228+membership: undefined,
229+approval: {
230+agentId: "qa",
231+allowedDecisions: ["allow-once", "deny"],
232+id: "plugin:approval-1",
233+kind: "plugin",
234+pluginId: "qa-plugin",
235+severity: "medium",
236+state: "pending",
237+toolName: "qa_tool",
238+type: "approval.request",
239+version: 1,
240+},
241+});
212242});
213243214244it("normalizes Matrix image messages with attachment metadata", () => {
@@ -223,18 +253,24 @@ describe("matrix observed event normalization", () => {
223253msgtype: "m.image",
224254},
225255}),
226-).toEqual(
227-expect.objectContaining({
228-kind: "message",
229-eventId: "$image",
230-msgtype: "m.image",
231-attachment: {
232-kind: "image",
233-caption: "Protocol note: generated the QA lighthouse image successfully.",
234-filename: "qa-lighthouse.png",
235-},
236-}),
237-);
256+).toEqual({
257+kind: "message",
258+roomId: "!room:matrix-qa.test",
259+eventId: "$image",
260+sender: "@sut:matrix-qa.test",
261+stateKey: undefined,
262+type: "m.room.message",
263+originServerTs: undefined,
264+body: "Protocol note: generated the QA lighthouse image successfully.",
265+formattedBody: undefined,
266+msgtype: "m.image",
267+membership: undefined,
268+attachment: {
269+kind: "image",
270+caption: "Protocol note: generated the QA lighthouse image successfully.",
271+filename: "qa-lighthouse.png",
272+},
273+});
238274});
239275240276it("treats filename-like Matrix media bodies as attachment filenames", () => {
@@ -248,14 +284,23 @@ describe("matrix observed event normalization", () => {
248284msgtype: "m.image",
249285},
250286}),
251-).toEqual(
252-expect.objectContaining({
253-attachment: {
254-kind: "image",
255-filename: "qa-lighthouse.png",
256-},
257-}),
258-);
287+).toEqual({
288+kind: "message",
289+roomId: "!room:matrix-qa.test",
290+eventId: "$image",
291+sender: "@sut:matrix-qa.test",
292+stateKey: undefined,
293+type: "m.room.message",
294+originServerTs: undefined,
295+body: "qa-lighthouse.png",
296+formattedBody: undefined,
297+msgtype: "m.image",
298+membership: undefined,
299+attachment: {
300+kind: "image",
301+filename: "qa-lighthouse.png",
302+},
303+});
259304});
260305261306it("normalizes membership events with explicit membership kind", () => {
@@ -269,15 +314,19 @@ describe("matrix observed event normalization", () => {
269314membership: "leave",
270315},
271316}),
272-).toEqual(
273-expect.objectContaining({
274-kind: "membership",
275-eventId: "$membership",
276-membership: "leave",
277-stateKey: "@sut:matrix-qa.test",
278-type: "m.room.member",
279-}),
280-);
317+).toEqual({
318+kind: "membership",
319+roomId: "!room:matrix-qa.test",
320+eventId: "$membership",
321+sender: "@driver:matrix-qa.test",
322+stateKey: "@sut:matrix-qa.test",
323+type: "m.room.member",
324+originServerTs: undefined,
325+body: undefined,
326+formattedBody: undefined,
327+msgtype: undefined,
328+membership: "leave",
329+});
281330});
282331283332it("classifies Matrix redactions without needing raw event inspection", () => {
@@ -288,12 +337,18 @@ describe("matrix observed event normalization", () => {
288337type: "m.room.redaction",
289338content: {},
290339}),
291-).toEqual(
292-expect.objectContaining({
293-kind: "redaction",
294-eventId: "$redaction",
295-type: "m.room.redaction",
296-}),
297-);
340+).toEqual({
341+kind: "redaction",
342+roomId: "!room:matrix-qa.test",
343+eventId: "$redaction",
344+sender: "@driver:matrix-qa.test",
345+stateKey: undefined,
346+type: "m.room.redaction",
347+originServerTs: undefined,
348+body: undefined,
349+formattedBody: undefined,
350+msgtype: undefined,
351+membership: undefined,
352+});
298353});
299354});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。