File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
typescript-sdk/apps/dojo/e2e2/tests Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change
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 ( / f o u r / 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
+ } ) ;
You can’t perform that action at this time.
0 commit comments