|
| 1 | +import { |
| 2 | + test, |
| 3 | + expect, |
| 4 | + waitForAIResponse, |
| 5 | + retryOnAIFailure, |
| 6 | +} from "../../test-isolation-helper"; |
| 7 | +import { AgenticChatPage } from "../../featurePages/AgenticChatPage"; |
| 8 | + |
| 9 | +test("[LangGraph] Agentic Chat sends and receives a message", async ({ |
| 10 | + page, |
| 11 | +}) => { |
| 12 | + await retryOnAIFailure(async () => { |
| 13 | + await page.goto( |
| 14 | + "/langgraph-typescript/feature/agentic_chat" |
| 15 | + ); |
| 16 | + |
| 17 | + const chat = new AgenticChatPage(page); |
| 18 | + |
| 19 | + await chat.openChat(); |
| 20 | + await chat.agentGreeting.isVisible; |
| 21 | + await chat.sendMessage("Hi, I am duaa"); |
| 22 | + |
| 23 | + await waitForAIResponse(page); |
| 24 | + await chat.assertUserMessageVisible("Hi, I am duaa"); |
| 25 | + await chat.assertAgentReplyVisible(/Hello/i); |
| 26 | + }); |
| 27 | +}); |
| 28 | + |
| 29 | +test("[LangGraph] Agentic Chat changes background on message and reset", async ({ |
| 30 | + page, |
| 31 | +}) => { |
| 32 | + await retryOnAIFailure(async () => { |
| 33 | + await page.goto( |
| 34 | + "/langgraph-typescript/feature/agentic_chat" |
| 35 | + ); |
| 36 | + |
| 37 | + const chat = new AgenticChatPage(page); |
| 38 | + |
| 39 | + await chat.openChat(); |
| 40 | + await chat.agentGreeting.waitFor({ state: "visible" }); |
| 41 | + |
| 42 | + // Store initial background color |
| 43 | + const initialBackground = await chat.getBackground(); |
| 44 | + console.log("Initial background color:", initialBackground); |
| 45 | + |
| 46 | + // 1. Send message to change background to blue |
| 47 | + await chat.sendMessage("Hi change the background color to blue"); |
| 48 | + await chat.assertUserMessageVisible( |
| 49 | + "Hi change the background color to blue" |
| 50 | + ); |
| 51 | + await waitForAIResponse(page); |
| 52 | + |
| 53 | + const backgroundBlue = await chat.getBackground(); |
| 54 | + expect(backgroundBlue).not.toBe(initialBackground); |
| 55 | + // Check if background is blue (string color name or contains blue) |
| 56 | + expect(backgroundBlue.toLowerCase()).toMatch(/blue|rgb\(.*,.*,.*\)|#[0-9a-f]{6}/); |
| 57 | + |
| 58 | + // 2. Change to pink |
| 59 | + await chat.sendMessage("Hi change the background color to pink"); |
| 60 | + await chat.assertUserMessageVisible( |
| 61 | + "Hi change the background color to pink" |
| 62 | + ); |
| 63 | + await waitForAIResponse(page); |
| 64 | + |
| 65 | + const backgroundPink = await chat.getBackground(); |
| 66 | + expect(backgroundPink).not.toBe(backgroundBlue); |
| 67 | + // Check if background is pink (string color name or contains pink) |
| 68 | + expect(backgroundPink.toLowerCase()).toMatch(/pink|rgb\(.*,.*,.*\)|#[0-9a-f]{6}/); |
| 69 | + }); |
| 70 | +}); |
| 71 | + |
| 72 | +test("[LangGraph] Agentic Chat retains memory of user messages during a conversation", async ({ |
| 73 | + page, |
| 74 | +}) => { |
| 75 | + await retryOnAIFailure(async () => { |
| 76 | + await page.goto( |
| 77 | + "/langgraph-typescript/feature/agentic_chat" |
| 78 | + ); |
| 79 | + |
| 80 | + const chat = new AgenticChatPage(page); |
| 81 | + await chat.openChat(); |
| 82 | + await chat.agentGreeting.click(); |
| 83 | + |
| 84 | + await chat.sendMessage("Hey there"); |
| 85 | + await chat.assertUserMessageVisible("Hey there"); |
| 86 | + await waitForAIResponse(page); |
| 87 | + await chat.assertAgentReplyVisible(/how can I assist you/i); |
| 88 | + |
| 89 | + const favFruit = "Mango"; |
| 90 | + await chat.sendMessage(`My favorite fruit is ${favFruit}`); |
| 91 | + await chat.assertUserMessageVisible(`My favorite fruit is ${favFruit}`); |
| 92 | + await waitForAIResponse(page); |
| 93 | + await chat.assertAgentReplyVisible(new RegExp(favFruit, "i")); |
| 94 | + |
| 95 | + await chat.sendMessage("and I love listening to Kaavish"); |
| 96 | + await chat.assertUserMessageVisible("and I love listening to Kaavish"); |
| 97 | + await waitForAIResponse(page); |
| 98 | + await chat.assertAgentReplyVisible(/Kaavish/i); |
| 99 | + |
| 100 | + await chat.sendMessage("tell me an interesting fact about Moon"); |
| 101 | + await chat.assertUserMessageVisible( |
| 102 | + "tell me an interesting fact about Moon" |
| 103 | + ); |
| 104 | + await waitForAIResponse(page); |
| 105 | + await chat.assertAgentReplyVisible(/Moon/i); |
| 106 | + |
| 107 | + await chat.sendMessage("Can you remind me what my favorite fruit is?"); |
| 108 | + await chat.assertUserMessageVisible( |
| 109 | + "Can you remind me what my favorite fruit is?" |
| 110 | + ); |
| 111 | + await waitForAIResponse(page); |
| 112 | + await chat.assertAgentReplyVisible(new RegExp(favFruit, "i")); |
| 113 | + }); |
| 114 | +}); |
0 commit comments