mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 05:50:43 +00:00
test: stabilize matrix block streaming prompt
This commit is contained in:
@@ -87,12 +87,10 @@ export function buildMatrixBlockStreamingPrompt(
|
||||
secondText: string,
|
||||
) {
|
||||
return [
|
||||
sutUserId,
|
||||
"Block streaming QA check:",
|
||||
"emit exactly two assistant message blocks in order.",
|
||||
`First exact marker: \`${firstText}\`.`,
|
||||
`Second exact marker: \`${secondText}\`.`,
|
||||
].join(" ");
|
||||
`${sutUserId} Block streaming QA check: reply with exactly this two-line body and no extra text:`,
|
||||
firstText,
|
||||
secondText,
|
||||
].join("\n");
|
||||
}
|
||||
|
||||
export function isMatrixQaMessageLikeKind(kind: MatrixQaObservedEvent["kind"]) {
|
||||
|
||||
@@ -2246,10 +2246,11 @@ describe("matrix live qa scenarios", () => {
|
||||
it("preserves separate finalized block events when Matrix block streaming is enabled", async () => {
|
||||
const primeRoom = vi.fn().mockResolvedValue("driver-sync-start");
|
||||
const sendTextMessage = vi.fn().mockResolvedValue("$block-stream-trigger");
|
||||
const readBlockText = (label: "First" | "Second") =>
|
||||
new RegExp(`${label} exact marker: \`([^\\\`]+)\``).exec(
|
||||
String(sendTextMessage.mock.calls[0]?.[0]?.body),
|
||||
)?.[1] ?? `MATRIX_QA_BLOCK_${label.toUpperCase()}_FIXED`;
|
||||
const readBlockText = (label: "ONE" | "TWO") =>
|
||||
String(sendTextMessage.mock.calls[0]?.[0]?.body)
|
||||
.split("\n")
|
||||
.find((line) => line.startsWith(`MATRIX_QA_BLOCK_${label}_`)) ??
|
||||
`MATRIX_QA_BLOCK_${label}_FIXED`;
|
||||
const waitForRoomEvent = vi
|
||||
.fn()
|
||||
.mockImplementationOnce(async () => ({
|
||||
@@ -2259,7 +2260,7 @@ describe("matrix live qa scenarios", () => {
|
||||
eventId: "$block-one",
|
||||
sender: "@sut:matrix-qa.test",
|
||||
type: "m.room.message",
|
||||
body: readBlockText("First"),
|
||||
body: readBlockText("ONE"),
|
||||
},
|
||||
since: "driver-sync-block-one",
|
||||
}))
|
||||
@@ -2270,7 +2271,7 @@ describe("matrix live qa scenarios", () => {
|
||||
eventId: "$block-two",
|
||||
sender: "@sut:matrix-qa.test",
|
||||
type: "m.room.message",
|
||||
body: readBlockText("Second"),
|
||||
body: readBlockText("TWO"),
|
||||
},
|
||||
since: "driver-sync-next",
|
||||
}));
|
||||
@@ -2333,6 +2334,10 @@ describe("matrix live qa scenarios", () => {
|
||||
mentionUserIds: ["@sut:matrix-qa.test"],
|
||||
roomId: "!block:matrix-qa.test",
|
||||
});
|
||||
const body = String(sendTextMessage.mock.calls[0]?.[0]?.body);
|
||||
expect(body).toMatch(
|
||||
/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}$/,
|
||||
);
|
||||
expect(waitForRoomEvent).toHaveBeenNthCalledWith(
|
||||
2,
|
||||
expect.objectContaining({
|
||||
|
||||
Reference in New Issue
Block a user