Skip to content

Commit c4c175e

Browse files
mefogleclaude
andcommitted
Add e2e tests for ADK middleware agentic chat
- Create Playwright test for ADK middleware integration - Test initial greeting message display - Test agent response to user question ("Four") - Properly wait for second assistant message with timeout - Verify complete conversation flow (3 messages total) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 20d8971 commit c4c175e

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { test, expect } from '@playwright/test';
2+
3+
test('responds to user message', async ({ page }) => {
4+
await page.goto('http://localhost:9999/adk-middleware/feature/agentic_chat');
5+
6+
// 1. Wait for the page to be fully ready by ensuring the initial message is visible.
7+
await expect(page.getByText("Hi, I'm an agent. Want to chat?")).toBeVisible({ timeout: 10000 });
8+
9+
// 2. Interact with the page to send the message.
10+
const textarea = page.getByPlaceholder('Type a message...');
11+
await textarea.fill('How many sides are in a square? Please answer in one word. Do not use any punctuation, just the number in word form.');
12+
await page.keyboard.press('Enter');
13+
14+
// 3. Assert the final state with a generous timeout.
15+
// This is the most important part. We target the *second* assistant message
16+
// and wait for it to contain the text "Four". Playwright handles all the waiting.
17+
const finalResponse = page.locator('.copilotKitMessage.copilotKitAssistantMessage').nth(1);
18+
await expect(finalResponse).toContainText(/four/i, { timeout: 15000 });
19+
20+
// 4. (Optional) For added certainty, verify the total message count.
21+
// This confirms there are exactly 3 messages: greeting, user query, and agent response.
22+
await expect(page.locator('.copilotKitMessage')).toHaveCount(3);
23+
});

0 commit comments

Comments
 (0)