
























@@ -171,6 +171,10 @@ function mockObjectArg(source: MockCallSource, label: string, callIndex = 0, arg
171171return arg as Record<string, unknown>;
172172}
173173174+function mockMessageBody(source: MockCallSource, label: string, callIndex = 0) {
175+return String(mockObjectArg(source, label, callIndex).body);
176+}
177+174178function expectSentTextMessage(
175179source: MockCallSource,
176180expected: {
@@ -1132,7 +1136,7 @@ describe("matrix live qa scenarios", () => {
11321136eventId: "$sut-reply",
11331137sender: "@sut:matrix-qa.test",
11341138type: "m.room.message",
1135-body: String(sendTextMessage.mock.calls.at(0)?.[0]?.body).replace(
1139+body: mockMessageBody(sendTextMessage, "sendTextMessage").replace(
11361140"@sut:matrix-qa.test reply with only this exact marker: ",
11371141"",
11381142),
@@ -1198,7 +1202,7 @@ describe("matrix live qa scenarios", () => {
11981202eventId: "$sut-bot-reply",
11991203sender: "@sut:matrix-qa.test",
12001204type: "m.room.message",
1201-body: String(sendTextMessage.mock.calls.at(0)?.[0]?.body).replace(
1205+body: mockMessageBody(sendTextMessage, "sendTextMessage").replace(
12021206"@sut:matrix-qa.test reply with only this exact marker: ",
12031207"",
12041208),
@@ -1914,7 +1918,7 @@ describe("matrix live qa scenarios", () => {
1914191819151919const sendTextMessage = vi.fn().mockResolvedValue("$driver-trigger");
19161920const waitForRoomEvent = vi.fn().mockImplementation(async () => {
1917-const token = String(sendTextMessage.mock.calls.at(0)?.[0]?.body).replace(
1921+const token = mockMessageBody(sendTextMessage, "sendTextMessage").replace(
19181922"@sync-gateway:matrix-qa.test reply with only this exact marker: ",
19191923"",
19201924);
@@ -2304,7 +2308,7 @@ describe("matrix live qa scenarios", () => {
23042308eventId: "$sut-reply",
23052309sender: "@sut:matrix-qa.test",
23062310type: "m.room.message",
2307-body: String(sendTextMessage.mock.calls.at(0)?.[0]?.body).replace(
2311+body: mockMessageBody(sendTextMessage, "sendTextMessage").replace(
23082312"reply with only this exact marker: ",
23092313"",
23102314),
@@ -2383,7 +2387,7 @@ describe("matrix live qa scenarios", () => {
23832387eventId: "$sut-reply",
23842388sender: "@sut:matrix-qa.test",
23852389type: "m.room.message",
2386-body: String(sendTextMessage.mock.calls.at(0)?.[0]?.body).replace(
2390+body: mockMessageBody(sendTextMessage, "sendTextMessage").replace(
23872391"@sut:matrix-qa.test reply with only this exact marker: ",
23882392"",
23892393),
@@ -2439,7 +2443,7 @@ describe("matrix live qa scenarios", () => {
24392443.mockImplementationOnce(async () => {
24402444const childToken =
24412445/task="Finish with exactly ([^".]+)\./.exec(
2442-String(sendTextMessage.mock.calls.at(0)?.[0]?.body),
2446+mockMessageBody(sendTextMessage, "sendTextMessage"),
24432447)?.[1] ?? "MATRIX_QA_SUBAGENT_CHILD_FIXED";
24442448return {
24452449event: {
@@ -2605,7 +2609,7 @@ describe("matrix live qa scenarios", () => {
26052609const primeRoom = vi.fn().mockResolvedValue("driver-sync-start");
26062610const sendTextMessage = vi.fn().mockResolvedValue("$quiet-stream-trigger");
26072611const readFinalText = () =>
2608-/reply exactly `([^`]+)`/.exec(String(sendTextMessage.mock.calls.at(0)?.[0]?.body))?.[1] ??
2612+/reply exactly `([^`]+)`/.exec(mockMessageBody(sendTextMessage, "sendTextMessage"))?.[1] ??
26092613"MATRIX_QA_QUIET_STREAM_PREVIEW_COMPLETE";
26102614const waitForRoomEvent = vi
26112615.fn()
@@ -2703,7 +2707,7 @@ describe("matrix live qa scenarios", () => {
27032707kind: "message",
27042708eventId: "$partial-final",
27052709body: readMatrixQaReplyDirective(
2706-sendTextMessage.mock.calls.at(0)?.[0]?.body,
2710+mockMessageBody(sendTextMessage, "sendTextMessage"),
27072711fallbackFinalText,
27082712),
27092713relatesTo: {
@@ -2754,7 +2758,7 @@ describe("matrix live qa scenarios", () => {
27542758kind: "notice",
27552759eventId: "$tool-progress-final",
27562760body: readMatrixQaReplyDirective(
2757-sendTextMessage.mock.calls.at(0)?.[0]?.body,
2761+mockMessageBody(sendTextMessage, "sendTextMessage"),
27582762"MATRIX_QA_TOOL_PROGRESS_FIXED",
27592763),
27602764relatesTo: {
@@ -2782,7 +2786,7 @@ describe("matrix live qa scenarios", () => {
27822786);
27832787expect(artifacts.previewEventId).toBe("$tool-progress-preview");
27842788expect(artifacts.reply?.eventId).toBe("$tool-progress-final");
2785-const prompt = String(sendTextMessage.mock.calls.at(0)?.[0]?.body);
2789+const prompt = mockMessageBody(sendTextMessage, "sendTextMessage");
27862790expect(prompt).toContain("use the read tool exactly once on `QA_KICKOFF_TASK.md`");
27872791expect(prompt).toContain("Do not read `HEARTBEAT.md`");
27882792expect(prompt).toContain("reply with only this exact marker and no other text");
@@ -2819,7 +2823,7 @@ describe("matrix live qa scenarios", () => {
28192823kind: "notice",
28202824eventId: "$tool-progress-generic-final",
28212825body: readMatrixQaReplyDirective(
2822-sendTextMessage.mock.calls.at(0)?.[0]?.body,
2826+mockMessageBody(sendTextMessage, "sendTextMessage"),
28232827"MATRIX_QA_TOOL_PROGRESS_FIXED",
28242828),
28252829relatesTo: {
@@ -2952,7 +2956,7 @@ describe("matrix live qa scenarios", () => {
29522956kind: "message",
29532957eventId: "$tool-progress-optout-final",
29542958body: readMatrixQaReplyDirective(
2955-sendTextMessage.mock.calls.at(0)?.[0]?.body,
2959+mockMessageBody(sendTextMessage, "sendTextMessage"),
29562960"MATRIX_QA_TOOL_PROGRESS_OPTOUT_FIXED",
29572961),
29582962}),
@@ -2998,7 +3002,7 @@ describe("matrix live qa scenarios", () => {
29983002kind: "notice",
29993003eventId: "$tool-progress-error-final",
30003004body: readMatrixQaReplyDirective(
3001-sendTextMessage.mock.calls.at(0)?.[0]?.body,
3005+mockMessageBody(sendTextMessage, "sendTextMessage"),
30023006"MATRIX_QA_TOOL_PROGRESS_ERROR_FIXED",
30033007),
30043008relatesTo: {
@@ -3063,7 +3067,7 @@ describe("matrix live qa scenarios", () => {
30633067kind: "notice",
30643068eventId: "$tool-progress-error-short-final",
30653069body: readMatrixQaReplyDirective(
3066-sendTextMessage.mock.calls.at(0)?.[0]?.body,
3070+mockMessageBody(sendTextMessage, "sendTextMessage"),
30673071"MATRIX_QA_TOOL_PROGRESS_ERROR_SHORT_FIXED",
30683072),
30693073relatesTo: {
@@ -3135,7 +3139,7 @@ describe("matrix live qa scenarios", () => {
31353139kind: "message",
31363140eventId: "$tool-progress-mention-final",
31373141body: readMatrixQaReplyDirective(
3138-sendTextMessage.mock.calls.at(0)?.[0]?.body,
3142+mockMessageBody(sendTextMessage, "sendTextMessage"),
31393143"MATRIX_QA_TOOL_PROGRESS_MENTION_SAFE_FIXED",
31403144),
31413145relatesTo: {
@@ -3167,7 +3171,7 @@ describe("matrix live qa scenarios", () => {
31673171const primeRoom = vi.fn().mockResolvedValue("driver-sync-start");
31683172const sendTextMessage = vi.fn().mockResolvedValue("$block-stream-trigger");
31693173const readBlockText = (label: "ONE" | "TWO") =>
3170-String(sendTextMessage.mock.calls.at(0)?.[0]?.body)
3174+mockMessageBody(sendTextMessage, "sendTextMessage")
31713175.split("\n")
31723176.find((line) => line.startsWith(`MATRIX_QA_BLOCK_${label}_`)) ??
31733177`MATRIX_QA_BLOCK_${label}_FIXED`;
@@ -3250,7 +3254,7 @@ describe("matrix live qa scenarios", () => {
32503254mentionUserIds: ["@sut:matrix-qa.test"],
32513255roomId: "!block:matrix-qa.test",
32523256});
3253-const body = String(sendTextMessage.mock.calls.at(0)?.[0]?.body);
3257+const body = mockMessageBody(sendTextMessage, "sendTextMessage");
32543258expect(body).toMatch(
32553259/reply with exactly this two-line body and no extra text:\nMATRIX_QA_BLOCK_ONE_[A-F0-9]{8}\nMATRIX_QA_BLOCK_TWO_[A-F0-9]{8}$/,
32563260);
@@ -3557,7 +3561,7 @@ describe("matrix live qa scenarios", () => {
35573561}
35583562const firstReplyWait = waitForRoomEvent.mock.calls.at(1)?.[0];
35593563const firstToken =
3560-String(sendMediaMessage.mock.calls.at(0)?.[0]?.body).match(
3564+mockMessageBody(sendMediaMessage, "sendMediaMessage").match(
35613565/MATRIX_QA_MEDIA_[A-Z]+_[A-Z0-9]+/,
35623566)?.[0] ?? "";
35633567expect(
@@ -3592,7 +3596,7 @@ describe("matrix live qa scenarios", () => {
35923596eventId: "$sut-reply",
35933597sender: "@sut:matrix-qa.test",
35943598type: "m.room.message",
3595-body: String(sendTextMessage.mock.calls.at(0)?.[0]?.body).replace(
3599+body: mockMessageBody(sendTextMessage, "sendTextMessage").replace(
35963600"reply with only this exact marker: ",
35973601"",
35983602),
@@ -3668,7 +3672,7 @@ describe("matrix live qa scenarios", () => {
36683672eventId: "$sut-primary-reply",
36693673sender: "@sut:matrix-qa.test",
36703674type: "m.room.message",
3671-body: String(sendPrimaryTextMessage.mock.calls.at(0)?.[0]?.body).replace(
3675+body: mockMessageBody(sendPrimaryTextMessage, "sendPrimaryTextMessage").replace(
36723676"reply with only this exact marker: ",
36733677"",
36743678),
@@ -3684,7 +3688,7 @@ describe("matrix live qa scenarios", () => {
36843688eventId: "$sut-secondary-reply",
36853689sender: "@sut:matrix-qa.test",
36863690type: "m.room.message",
3687-body: String(sendSecondaryTextMessage.mock.calls.at(0)?.[0]?.body).replace(
3691+body: mockMessageBody(sendSecondaryTextMessage, "sendSecondaryTextMessage").replace(
36883692"reply with only this exact marker: ",
36893693"",
36903694),
@@ -3792,7 +3796,7 @@ describe("matrix live qa scenarios", () => {
37923796eventId: "$sut-primary-reply",
37933797sender: "@sut:matrix-qa.test",
37943798type: "m.room.message",
3795-body: String(sendPrimaryTextMessage.mock.calls.at(0)?.[0]?.body).replace(
3799+body: mockMessageBody(sendPrimaryTextMessage, "sendPrimaryTextMessage").replace(
37963800"reply with only this exact marker: ",
37973801"",
37983802),
@@ -3808,7 +3812,7 @@ describe("matrix live qa scenarios", () => {
38083812eventId: "$sut-secondary-reply",
38093813sender: "@sut:matrix-qa.test",
38103814type: "m.room.message",
3811-body: String(sendSecondaryTextMessage.mock.calls.at(0)?.[0]?.body).replace(
3815+body: mockMessageBody(sendSecondaryTextMessage, "sendSecondaryTextMessage").replace(
38123816"reply with only this exact marker: ",
38133817"",
38143818),
@@ -3911,7 +3915,7 @@ describe("matrix live qa scenarios", () => {
39113915eventId: "$sut-autojoin-reply",
39123916sender: "@sut:matrix-qa.test",
39133917type: "m.room.message",
3914-body: String(sendTextMessage.mock.calls.at(0)?.[0]?.body).replace(
3918+body: mockMessageBody(sendTextMessage, "sendTextMessage").replace(
39153919"@sut:matrix-qa.test reply with only this exact marker: ",
39163920"",
39173921),
@@ -3977,7 +3981,7 @@ describe("matrix live qa scenarios", () => {
39773981eventId: "$sut-reply",
39783982sender: "@sut:matrix-qa.test",
39793983type: "m.room.message",
3980-body: String(sendTextMessage.mock.calls.at(0)?.[0]?.body).replace(
3984+body: mockMessageBody(sendTextMessage, "sendTextMessage").replace(
39813985"@sut:matrix-qa.test reply with only this exact marker: ",
39823986"",
39833987),
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。