chatbot-template/tests/e2e/reasoning.test.ts

63 lines
2.1 KiB
TypeScript
Raw Normal View History

import { ChatPage } from '../pages/chat';
import { test, expect } from '../fixtures';
2025-03-09 21:02:19 -07:00
test.describe('chat activity with reasoning', () => {
2025-03-09 21:02:19 -07:00
let chatPage: ChatPage;
2025-04-25 23:40:15 -07:00
test.beforeEach(async ({ curieContext }) => {
chatPage = new ChatPage(curieContext.page);
2025-03-09 21:02:19 -07:00
await chatPage.createNewChat();
});
test('Curie can send message and generate response with reasoning', async () => {
await chatPage.sendUserMessage('Why is the sky blue?');
await chatPage.isGenerationComplete();
2025-03-09 21:02:19 -07:00
const assistantMessage = await chatPage.getRecentAssistantMessage();
2025-03-11 14:39:36 -07:00
expect(assistantMessage.content).toBe("It's just blue duh!");
2025-03-09 21:02:19 -07:00
expect(assistantMessage.reasoning).toBe(
'The sky is blue because of rayleigh scattering!',
2025-03-09 21:02:19 -07:00
);
});
test('Curie can toggle reasoning visibility', async () => {
await chatPage.sendUserMessage('Why is the sky blue?');
await chatPage.isGenerationComplete();
2025-03-09 21:02:19 -07:00
const assistantMessage = await chatPage.getRecentAssistantMessage();
const reasoningElement =
assistantMessage.element.getByTestId('message-reasoning');
2025-03-09 21:02:19 -07:00
expect(reasoningElement).toBeVisible();
await assistantMessage.toggleReasoningVisibility();
await expect(reasoningElement).not.toBeVisible();
await assistantMessage.toggleReasoningVisibility();
await expect(reasoningElement).toBeVisible();
});
test('Curie can edit message and resubmit', async () => {
await chatPage.sendUserMessage('Why is the sky blue?');
await chatPage.isGenerationComplete();
2025-03-09 21:02:19 -07:00
const assistantMessage = await chatPage.getRecentAssistantMessage();
const reasoningElement =
assistantMessage.element.getByTestId('message-reasoning');
2025-03-09 21:02:19 -07:00
expect(reasoningElement).toBeVisible();
const userMessage = await chatPage.getRecentUserMessage();
await userMessage.edit('Why is grass green?');
await chatPage.isGenerationComplete();
2025-03-09 21:02:19 -07:00
const updatedAssistantMessage = await chatPage.getRecentAssistantMessage();
2025-03-11 14:39:36 -07:00
expect(updatedAssistantMessage.content).toBe("It's just green duh!");
2025-03-09 21:02:19 -07:00
expect(updatedAssistantMessage.reasoning).toBe(
'Grass is green because of chlorophyll absorption!',
2025-03-09 21:02:19 -07:00
);
});
});