Skip to content

Commit 38655d5

Browse files
committed
test(qa-matrix): preserve reply preview semantics
1 parent 24b4c98 commit 38655d5

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

extensions/qa-matrix/src/runners/contract/scenario-runtime-shared.test.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
// Qa Matrix tests cover scenario runtime shared plugin behavior.
22
import { afterEach, describe, expect, it, vi } from "vitest";
3-
import { resolveMatrixQaNoReplyWindowMs } from "./scenario-runtime-shared.js";
3+
import {
4+
buildMatrixReplyArtifact,
5+
resolveMatrixQaNoReplyWindowMs,
6+
} from "./scenario-runtime-shared.js";
47

58
describe("matrix scenario runtime shared", () => {
69
afterEach(() => {
@@ -19,4 +22,18 @@ describe("matrix scenario runtime shared", () => {
1922
expect(resolveMatrixQaNoReplyWindowMs(30_000)).toBe(8_000);
2023
}
2124
});
25+
26+
it("keeps reply previews UTF-16 safe without changing empty-body artifacts", () => {
27+
const event = {
28+
kind: "message" as const,
29+
roomId: "!room:matrix-qa.test",
30+
eventId: "$event",
31+
sender: "@sut:matrix-qa.test",
32+
type: "m.room.message",
33+
};
34+
const prefix = "a".repeat(199);
35+
36+
expect(buildMatrixReplyArtifact({ ...event, body: `${prefix}😀tail` }).bodyPreview).toBe(prefix);
37+
expect(buildMatrixReplyArtifact({ ...event, body: " " }).bodyPreview).toBe("");
38+
});
2239
});

extensions/qa-matrix/src/runners/contract/scenario-runtime-shared.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ export function buildMatrixReplyArtifact(
190190
): MatrixQaReplyArtifact {
191191
const replyBody = event.body?.trim();
192192
return {
193-
bodyPreview: replyBody ? truncateUtf16Safe(replyBody, 200) : undefined,
193+
bodyPreview: replyBody === undefined ? undefined : truncateUtf16Safe(replyBody, 200),
194194
eventId: event.eventId,
195195
mentions: event.mentions,
196196
relatesTo: event.relatesTo,

0 commit comments

Comments
 (0)