Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(chat): enhance chat history and stream tests with persisted message checks

Steven Enamakel7e3def3acfe5
diff --git a/app/test/playwright/specs/chat-conversation-history.spec.ts b/app/test/playwright/specs/chat-conversation-history.spec.ts
index 24a948a706..b9baa5dccb 100644
--- a/app/test/playwright/specs/chat-conversation-history.spec.ts
+++ b/app/test/playwright/specs/chat-conversation-history.spec.ts
@@ -7,6 +7,7 @@ import {
waitForAppReady,
} from '../helpers/core-rpc';
import { selectedThreadTranscript } from '../helpers/chat-transcript';
+import { persistedThreadMessages } from '../helpers/chat-transcript';
const MOCK_ADMIN_BASE = `http://127.0.0.1:${process.env.E2E_MOCK_PORT || '18473'}`;
const USER_ID = 'pw-chat-conversation-history';
@@ -132,7 +133,7 @@ test.describe('Chat Conversation History', () => {
await setMockBehavior('llmStreamChunkDelayMs', '10');
await openChat(page);
- await createNewThread(page);
+ const threadId = await createNewThread(page);
await sendMessage(page, FIRST_PROMPT);
// The assistant bubble's Tailwind class carries an opacity modifier
@@ -221,5 +222,14 @@ test.describe('Chat Conversation History', () => {
expect(transcript.content).toContain(FIRST_RESPONSE);
expect(transcript.content).toContain(SECOND_PROMPT);
expect(transcript.content).toContain(TURN_TWO_CANARY);
+ await expect
+ .poll(async () => {
+ const messages = await persistedThreadMessages(threadId);
+ const content = messages.map(message => message.content).join('\n');
+ return [FIRST_PROMPT, FIRST_RESPONSE, SECOND_PROMPT, TURN_TWO_CANARY].every(text =>
+ content.includes(text)
+ );
+ })
+ .toBe(true);
});
});
diff --git a/app/test/playwright/specs/chat-harness-send-stream.spec.ts b/app/test/playwright/specs/chat-harness-send-stream.spec.ts
index c28471c607..dd35087913 100644
--- a/app/test/playwright/specs/chat-harness-send-stream.spec.ts
+++ b/app/test/playwright/specs/chat-harness-send-stream.spec.ts
@@ -7,6 +7,7 @@ import {
} from '../helpers/core-rpc';
import {
inFlightThreadKeys,
+ persistedThreadMessages,
selectedThreadTranscript,
} from '../helpers/chat-transcript';
@@ -138,7 +139,7 @@ test.describe('Chat Harness - Send Stream', () => {
await setMockBehavior('llmStreamScript', JSON.stringify(streamScript));
await openChat(page);
- await createNewThread(page);
+ const threadId = await createNewThread(page);
await sendMessage(page, PROMPT);
@@ -172,5 +173,12 @@ test.describe('Chat Harness - Send Stream', () => {
expect(durable.content).toContain(REPLY_PIECES.join(''));
expect(durable.total).toBeGreaterThan(0);
await expect.poll(inFlightThreadKeys).not.toContain(`::${durable.threadId}`);
+ await expect
+ .poll(async () => {
+ const messages = await persistedThreadMessages(threadId);
+ const content = messages.map(message => message.content).join('\n');
+ return content.includes(PROMPT) && content.includes(REPLY_PIECES.join(''));
+ })
+ .toBe(true);
});
});