diff --git a/typescript-sdk/apps/dojo/e2e/featurePages/ToolBaseGenUIPage.ts b/typescript-sdk/apps/dojo/e2e/featurePages/ToolBaseGenUIPage.ts index f2d648a5e..339c5448a 100644 --- a/typescript-sdk/apps/dojo/e2e/featurePages/ToolBaseGenUIPage.ts +++ b/typescript-sdk/apps/dojo/e2e/featurePages/ToolBaseGenUIPage.ts @@ -1,4 +1,4 @@ -import { Page, Locator, expect } from '@playwright/test'; +import { Page, Locator, expect } from "@playwright/test"; export class ToolBaseGenUIPage { readonly page: Page; @@ -13,10 +13,10 @@ export class ToolBaseGenUIPage { constructor(page: Page) { this.page = page; this.haikuAgentIntro = page.getByText("I'm a haiku generator 👋. How can I help you?"); - this.messageBox = page.getByRole('textbox', { name: 'Type a message...' }); + this.messageBox = page.getByRole("textbox", { name: "Type a message..." }); this.sendButton = page.locator('[data-test-id="copilot-chat-ready"]'); this.haikuBlock = page.locator('[data-testid="haiku-card"]'); - this.applyButton = page.getByRole('button', { name: 'Apply' }); + this.applyButton = page.getByRole("button", { name: "Apply" }); this.japaneseLines = page.locator('[data-testid="haiku-line"]'); } @@ -29,12 +29,15 @@ export class ToolBaseGenUIPage { async checkGeneratedHaiku() { await this.page.locator('[data-testid="haiku-card"]').last().isVisible(); const mostRecentCard = this.page.locator('[data-testid="haiku-card"]').last(); - await mostRecentCard.locator('[data-testid="haiku-line"]').first().waitFor({ state: 'visible', timeout: 10000 }); + await mostRecentCard + .locator('[data-testid="haiku-line"]') + .first() + .waitFor({ state: "visible", timeout: 10000 }); } async extractChatHaikuContent(page: Page): Promise { await page.waitForTimeout(3000); - await page.locator('[data-testid="haiku-card"]').first().waitFor({ state: 'visible' }); + await page.locator('[data-testid="haiku-card"]').first().waitFor({ state: "visible" }); const allHaikuCards = page.locator('[data-testid="haiku-card"]'); const cardCount = await allHaikuCards.count(); let chatHaikuContainer; @@ -47,7 +50,7 @@ export class ToolBaseGenUIPage { if (linesCount > 0) { try { - await chatHaikuLines.first().waitFor({ state: 'visible', timeout: 5000 }); + await chatHaikuLines.first().waitFor({ state: "visible", timeout: 5000 }); break; } catch (error) { continue; @@ -56,7 +59,7 @@ export class ToolBaseGenUIPage { } if (!chatHaikuLines) { - throw new Error('No haiku cards with visible lines found'); + throw new Error("No haiku cards with visible lines found"); } const count = await chatHaikuLines.count(); @@ -64,11 +67,11 @@ export class ToolBaseGenUIPage { for (let i = 0; i < count; i++) { const haikuLine = chatHaikuLines.nth(i); - const japaneseText = await haikuLine.locator('p').first().innerText(); + const japaneseText = await haikuLine.locator("p").first().innerText(); lines.push(japaneseText); } - const chatHaikuContent = lines.join('').replace(/\s/g, ''); + const chatHaikuContent = lines.join("").replace(/\s/g, ""); return chatHaikuContent; } @@ -80,12 +83,12 @@ export class ToolBaseGenUIPage { if (mainCount > 0) { for (let i = 0; i < mainCount; i++) { const haikuLine = mainDisplayLines.nth(i); - const japaneseText = await haikuLine.locator('p').first().innerText(); + const japaneseText = await haikuLine.locator("p").first().innerText(); lines.push(japaneseText); } } - const mainHaikuContent = lines.join('').replace(/\s/g, ''); + const mainHaikuContent = lines.join("").replace(/\s/g, ""); return mainHaikuContent; } @@ -96,7 +99,7 @@ export class ToolBaseGenUIPage { const mainHaikuContent = await this.extractMainDisplayHaikuContent(page); - if (mainHaikuContent === '') { + if (mainHaikuContent === "") { expect(chatHaikuContent.length).toBeGreaterThan(0); return; } @@ -111,4 +114,21 @@ export class ToolBaseGenUIPage { expect(updatedMainContent).toBe(chatHaikuContent); } } -} \ No newline at end of file + + async waitForMainDisplayHaiku(page: Page, expectedContent: string): Promise { + await page.waitForFunction( + (expectedContent) => { + const mainLines = Array.from( + document.querySelectorAll('[data-testid="main-haiku-line"] p:first-child'), + ); + const mainContent = mainLines + .map((el) => el.textContent) + .join("") + .replace(/\s/g, ""); + return mainContent === expectedContent; + }, + expectedContent, + { timeout: 10000 }, + ); + } +} diff --git a/typescript-sdk/apps/dojo/e2e/tests/adkMiddlewareTests/toolBasedGenUIPage.spec.ts b/typescript-sdk/apps/dojo/e2e/tests/adkMiddlewareTests/toolBasedGenUIPage.spec.ts index 15d3c768b..0e60a3c72 100644 --- a/typescript-sdk/apps/dojo/e2e/tests/adkMiddlewareTests/toolBasedGenUIPage.spec.ts +++ b/typescript-sdk/apps/dojo/e2e/tests/adkMiddlewareTests/toolBasedGenUIPage.spec.ts @@ -4,9 +4,7 @@ import { ToolBaseGenUIPage } from "../../featurePages/ToolBaseGenUIPage"; const pageURL = "/adk-middleware/feature/tool_based_generative_ui"; test.describe("Tool Based Generative UI Feature", () => { - test('[ADK Middleware] Haiku generation and display verification', async ({ - page, - }) => { + test("[ADK Middleware] Haiku generation and display verification", async ({ page }) => { await page.goto(pageURL); const genAIAgent = new ToolBaseGenUIPage(page); @@ -17,7 +15,7 @@ test.describe("Tool Based Generative UI Feature", () => { await genAIAgent.checkHaikuDisplay(page); }); - test('[ADK Middleware] Haiku generation and UI consistency for two different prompts', async ({ + test("[ADK Middleware] Haiku generation and UI consistency for two different prompts", async ({ page, }) => { await page.goto(pageURL); @@ -29,11 +27,17 @@ test.describe("Tool Based Generative UI Feature", () => { const prompt1 = 'Generate Haiku for "I will always win"'; await genAIAgent.generateHaiku(prompt1); await genAIAgent.checkGeneratedHaiku(); - await genAIAgent.checkHaikuDisplay(page); + const haiku1Content = await genAIAgent.extractChatHaikuContent(page); + await genAIAgent.waitForMainDisplayHaiku(page, haiku1Content); const prompt2 = 'Generate Haiku for "The moon shines bright"'; await genAIAgent.generateHaiku(prompt2); - await genAIAgent.checkGeneratedHaiku(); // Wait for second haiku to be generated - await genAIAgent.checkHaikuDisplay(page); // Now compare the second haiku + await genAIAgent.checkGeneratedHaiku(); + const haiku2Content = await genAIAgent.extractChatHaikuContent(page); + + // Verify haikus are different + expect(haiku1Content).not.toBe(haiku2Content); + + await genAIAgent.waitForMainDisplayHaiku(page, haiku2Content); }); -}); \ No newline at end of file +}); diff --git a/typescript-sdk/apps/dojo/e2e/tests/agnoTests/toolBasedGenUIPage.spec.ts b/typescript-sdk/apps/dojo/e2e/tests/agnoTests/toolBasedGenUIPage.spec.ts index 10380d93a..c32d61f9b 100644 --- a/typescript-sdk/apps/dojo/e2e/tests/agnoTests/toolBasedGenUIPage.spec.ts +++ b/typescript-sdk/apps/dojo/e2e/tests/agnoTests/toolBasedGenUIPage.spec.ts @@ -1,12 +1,9 @@ import { test, expect } from "@playwright/test"; import { ToolBaseGenUIPage } from "../../featurePages/ToolBaseGenUIPage"; -const pageURL = - "/agno/feature/tool_based_generative_ui"; +const pageURL = "/agno/feature/tool_based_generative_ui"; -test('[Agno] Haiku generation and display verification', async ({ - page, -}) => { +test("[Agno] Haiku generation and display verification", async ({ page }) => { await page.goto(pageURL); const genAIAgent = new ToolBaseGenUIPage(page); @@ -17,9 +14,7 @@ test('[Agno] Haiku generation and display verification', async ({ await genAIAgent.checkHaikuDisplay(page); }); -test('[Agno] Haiku generation and UI consistency for two different prompts', async ({ - page, -}) => { +test("[Agno] Haiku generation and UI consistency for two different prompts", async ({ page }) => { await page.goto(pageURL); const genAIAgent = new ToolBaseGenUIPage(page); @@ -29,10 +24,16 @@ test('[Agno] Haiku generation and UI consistency for two different prompts', asy const prompt1 = 'Generate Haiku for "I will always win"'; await genAIAgent.generateHaiku(prompt1); await genAIAgent.checkGeneratedHaiku(); - await genAIAgent.checkHaikuDisplay(page); + const haiku1Content = await genAIAgent.extractChatHaikuContent(page); + await genAIAgent.waitForMainDisplayHaiku(page, haiku1Content); const prompt2 = 'Generate Haiku for "The moon shines bright"'; await genAIAgent.generateHaiku(prompt2); - await genAIAgent.checkGeneratedHaiku(); // Wait for second haiku to be generated - await genAIAgent.checkHaikuDisplay(page); // Now compare the second haiku -}); \ No newline at end of file + await genAIAgent.checkGeneratedHaiku(); + const haiku2Content = await genAIAgent.extractChatHaikuContent(page); + + // Verify haikus are different + expect(haiku1Content).not.toBe(haiku2Content); + + await genAIAgent.waitForMainDisplayHaiku(page, haiku2Content); +}); diff --git a/typescript-sdk/apps/dojo/e2e/tests/crewAITests/toolBasedGenUIPage.spec.ts b/typescript-sdk/apps/dojo/e2e/tests/crewAITests/toolBasedGenUIPage.spec.ts index 398a1b80b..72c9b17eb 100644 --- a/typescript-sdk/apps/dojo/e2e/tests/crewAITests/toolBasedGenUIPage.spec.ts +++ b/typescript-sdk/apps/dojo/e2e/tests/crewAITests/toolBasedGenUIPage.spec.ts @@ -1,12 +1,9 @@ import { test, expect } from "@playwright/test"; import { ToolBaseGenUIPage } from "../../featurePages/ToolBaseGenUIPage"; -const pageURL = - "/crewai/feature/tool_based_generative_ui"; +const pageURL = "/crewai/feature/tool_based_generative_ui"; -test('[CrewAI] Haiku generation and display verification', async ({ - page, -}) => { +test("[CrewAI] Haiku generation and display verification", async ({ page }) => { await page.goto(pageURL); const genAIAgent = new ToolBaseGenUIPage(page); @@ -17,9 +14,7 @@ test('[CrewAI] Haiku generation and display verification', async ({ await genAIAgent.checkHaikuDisplay(page); }); -test('[CrewAI] Haiku generation and UI consistency for two different prompts', async ({ - page, -}) => { +test("[CrewAI] Haiku generation and UI consistency for two different prompts", async ({ page }) => { await page.goto(pageURL); const genAIAgent = new ToolBaseGenUIPage(page); @@ -29,10 +24,16 @@ test('[CrewAI] Haiku generation and UI consistency for two different prompts', a const prompt1 = 'Generate Haiku for "I will always win"'; await genAIAgent.generateHaiku(prompt1); await genAIAgent.checkGeneratedHaiku(); - await genAIAgent.checkHaikuDisplay(page); + const haiku1Content = await genAIAgent.extractChatHaikuContent(page); + await genAIAgent.waitForMainDisplayHaiku(page, haiku1Content); const prompt2 = 'Generate Haiku for "The moon shines bright"'; await genAIAgent.generateHaiku(prompt2); - await genAIAgent.checkGeneratedHaiku(); // Wait for second haiku to be generated - await genAIAgent.checkHaikuDisplay(page); // Now compare the second haiku -}); \ No newline at end of file + await genAIAgent.checkGeneratedHaiku(); + const haiku2Content = await genAIAgent.extractChatHaikuContent(page); + + // Verify haikus are different + expect(haiku1Content).not.toBe(haiku2Content); + + await genAIAgent.waitForMainDisplayHaiku(page, haiku2Content); +}); diff --git a/typescript-sdk/apps/dojo/e2e/tests/langgraphFastAPITests/toolBasedGenUIPage.spec.ts b/typescript-sdk/apps/dojo/e2e/tests/langgraphFastAPITests/toolBasedGenUIPage.spec.ts index 053d4715e..5c290c861 100644 --- a/typescript-sdk/apps/dojo/e2e/tests/langgraphFastAPITests/toolBasedGenUIPage.spec.ts +++ b/typescript-sdk/apps/dojo/e2e/tests/langgraphFastAPITests/toolBasedGenUIPage.spec.ts @@ -1,12 +1,9 @@ import { test, expect } from "@playwright/test"; import { ToolBaseGenUIPage } from "../../featurePages/ToolBaseGenUIPage"; -const pageURL = - "/langgraph-fastapi/feature/tool_based_generative_ui"; +const pageURL = "/langgraph-fastapi/feature/tool_based_generative_ui"; -test('[LangGraph FastAPI] Haiku generation and display verification', async ({ - page, -}) => { +test("[LangGraph FastAPI] Haiku generation and display verification", async ({ page }) => { await page.goto(pageURL); const genAIAgent = new ToolBaseGenUIPage(page); @@ -17,7 +14,7 @@ test('[LangGraph FastAPI] Haiku generation and display verification', async ({ await genAIAgent.checkHaikuDisplay(page); }); -test('[LangGraph FastAPI] Haiku generation and UI consistency for two different prompts', async ({ +test("[LangGraph FastAPI] Haiku generation and UI consistency for two different prompts", async ({ page, }) => { await page.goto(pageURL); @@ -29,10 +26,16 @@ test('[LangGraph FastAPI] Haiku generation and UI consistency for two different const prompt1 = 'Generate Haiku for "I will always win"'; await genAIAgent.generateHaiku(prompt1); await genAIAgent.checkGeneratedHaiku(); - await genAIAgent.checkHaikuDisplay(page); + const haiku1Content = await genAIAgent.extractChatHaikuContent(page); + await genAIAgent.waitForMainDisplayHaiku(page, haiku1Content); const prompt2 = 'Generate Haiku for "The moon shines bright"'; await genAIAgent.generateHaiku(prompt2); await genAIAgent.checkGeneratedHaiku(); - await genAIAgent.checkHaikuDisplay(page); -}); \ No newline at end of file + const haiku2Content = await genAIAgent.extractChatHaikuContent(page); + + // Verify haikus are different + expect(haiku1Content).not.toBe(haiku2Content); + + await genAIAgent.waitForMainDisplayHaiku(page, haiku2Content); +}); diff --git a/typescript-sdk/apps/dojo/e2e/tests/langgraphPythonTests/toolBasedGenUIPage.spec.ts b/typescript-sdk/apps/dojo/e2e/tests/langgraphPythonTests/toolBasedGenUIPage.spec.ts index 13d7d7e3d..9b76a181b 100644 --- a/typescript-sdk/apps/dojo/e2e/tests/langgraphPythonTests/toolBasedGenUIPage.spec.ts +++ b/typescript-sdk/apps/dojo/e2e/tests/langgraphPythonTests/toolBasedGenUIPage.spec.ts @@ -1,12 +1,9 @@ import { test, expect } from "@playwright/test"; import { ToolBaseGenUIPage } from "../../featurePages/ToolBaseGenUIPage"; -const pageURL = - "/langgraph/feature/tool_based_generative_ui"; +const pageURL = "/langgraph/feature/tool_based_generative_ui"; -test('[LangGraph] Haiku generation and display verification', async ({ - page, -}) => { +test("[LangGraph] Haiku generation and display verification", async ({ page }) => { await page.goto(pageURL); const genAIAgent = new ToolBaseGenUIPage(page); @@ -17,7 +14,7 @@ test('[LangGraph] Haiku generation and display verification', async ({ await genAIAgent.checkHaikuDisplay(page); }); -test('[LangGraph] Haiku generation and UI consistency for two different prompts', async ({ +test("[LangGraph] Haiku generation and UI consistency for two different prompts", async ({ page, }) => { await page.goto(pageURL); @@ -29,10 +26,16 @@ test('[LangGraph] Haiku generation and UI consistency for two different prompts' const prompt1 = 'Generate Haiku for "I will always win"'; await genAIAgent.generateHaiku(prompt1); await genAIAgent.checkGeneratedHaiku(); - await genAIAgent.checkHaikuDisplay(page); + const haiku1Content = await genAIAgent.extractChatHaikuContent(page); + await genAIAgent.waitForMainDisplayHaiku(page, haiku1Content); const prompt2 = 'Generate Haiku for "The moon shines bright"'; await genAIAgent.generateHaiku(prompt2); await genAIAgent.checkGeneratedHaiku(); - await genAIAgent.checkHaikuDisplay(page); -}); \ No newline at end of file + const haiku2Content = await genAIAgent.extractChatHaikuContent(page); + + // Verify haikus are different + expect(haiku1Content).not.toBe(haiku2Content); + + await genAIAgent.waitForMainDisplayHaiku(page, haiku2Content); +}); diff --git a/typescript-sdk/apps/dojo/e2e/tests/langgraphTypescriptTests/toolBasedGenUIPage.spec.ts b/typescript-sdk/apps/dojo/e2e/tests/langgraphTypescriptTests/toolBasedGenUIPage.spec.ts index f146f2b81..24c20909c 100644 --- a/typescript-sdk/apps/dojo/e2e/tests/langgraphTypescriptTests/toolBasedGenUIPage.spec.ts +++ b/typescript-sdk/apps/dojo/e2e/tests/langgraphTypescriptTests/toolBasedGenUIPage.spec.ts @@ -1,12 +1,9 @@ import { test, expect } from "@playwright/test"; import { ToolBaseGenUIPage } from "../../featurePages/ToolBaseGenUIPage"; -const pageURL = - "/langgraph-typescript/feature/tool_based_generative_ui"; +const pageURL = "/langgraph-typescript/feature/tool_based_generative_ui"; -test('[LangGraph] Haiku generation and display verification', async ({ - page, -}) => { +test("[LangGraph] Haiku generation and display verification", async ({ page }) => { await page.goto(pageURL); const genAIAgent = new ToolBaseGenUIPage(page); @@ -17,7 +14,7 @@ test('[LangGraph] Haiku generation and display verification', async ({ await genAIAgent.checkHaikuDisplay(page); }); -test('[LangGraph] Haiku generation and UI consistency for two different prompts', async ({ +test("[LangGraph] Haiku generation and UI consistency for two different prompts", async ({ page, }) => { await page.goto(pageURL); @@ -29,10 +26,16 @@ test('[LangGraph] Haiku generation and UI consistency for two different prompts' const prompt1 = 'Generate Haiku for "I will always win"'; await genAIAgent.generateHaiku(prompt1); await genAIAgent.checkGeneratedHaiku(); - await genAIAgent.checkHaikuDisplay(page); + const haiku1Content = await genAIAgent.extractChatHaikuContent(page); + await genAIAgent.waitForMainDisplayHaiku(page, haiku1Content); const prompt2 = 'Generate Haiku for "The moon shines bright"'; await genAIAgent.generateHaiku(prompt2); await genAIAgent.checkGeneratedHaiku(); - await genAIAgent.checkHaikuDisplay(page); -}); \ No newline at end of file + const haiku2Content = await genAIAgent.extractChatHaikuContent(page); + + // Verify haikus are different + expect(haiku1Content).not.toBe(haiku2Content); + + await genAIAgent.waitForMainDisplayHaiku(page, haiku2Content); +}); diff --git a/typescript-sdk/apps/dojo/e2e/tests/mastraAgentLocalTests/toolBasedGenUIPage.spec.ts b/typescript-sdk/apps/dojo/e2e/tests/mastraAgentLocalTests/toolBasedGenUIPage.spec.ts index c73388faf..5707afe8a 100644 --- a/typescript-sdk/apps/dojo/e2e/tests/mastraAgentLocalTests/toolBasedGenUIPage.spec.ts +++ b/typescript-sdk/apps/dojo/e2e/tests/mastraAgentLocalTests/toolBasedGenUIPage.spec.ts @@ -1,12 +1,9 @@ import { test, expect } from "@playwright/test"; import { ToolBaseGenUIPage } from "../../featurePages/ToolBaseGenUIPage"; -const pageURL = - "/mastra-agent-local/feature/tool_based_generative_ui"; +const pageURL = "/mastra-agent-local/feature/tool_based_generative_ui"; -test('[Mastra Agent Local] Haiku generation and display verification', async ({ - page, -}) => { +test("[Mastra Agent Local] Haiku generation and display verification", async ({ page }) => { await page.goto(pageURL); const genAIAgent = new ToolBaseGenUIPage(page); @@ -17,7 +14,7 @@ test('[Mastra Agent Local] Haiku generation and display verification', async ({ await genAIAgent.checkHaikuDisplay(page); }); -test('[Mastra Agent Local] Haiku generation and UI consistency for two different prompts', async ({ +test("[Mastra Agent Local] Haiku generation and UI consistency for two different prompts", async ({ page, }) => { await page.goto(pageURL); @@ -29,10 +26,16 @@ test('[Mastra Agent Local] Haiku generation and UI consistency for two different const prompt1 = 'Generate Haiku for "I will always win"'; await genAIAgent.generateHaiku(prompt1); await genAIAgent.checkGeneratedHaiku(); - await genAIAgent.checkHaikuDisplay(page); + const haiku1Content = await genAIAgent.extractChatHaikuContent(page); + await genAIAgent.waitForMainDisplayHaiku(page, haiku1Content); const prompt2 = 'Generate Haiku for "The moon shines bright"'; await genAIAgent.generateHaiku(prompt2); - await genAIAgent.checkGeneratedHaiku(); // Wait for second haiku to be generated - await genAIAgent.checkHaikuDisplay(page); // Now compare the second haiku -}); \ No newline at end of file + await genAIAgent.checkGeneratedHaiku(); + const haiku2Content = await genAIAgent.extractChatHaikuContent(page); + + // Verify haikus are different + expect(haiku1Content).not.toBe(haiku2Content); + + await genAIAgent.waitForMainDisplayHaiku(page, haiku2Content); +}); diff --git a/typescript-sdk/apps/dojo/e2e/tests/mastraTests/toolBasedGenUIPage.spec.ts b/typescript-sdk/apps/dojo/e2e/tests/mastraTests/toolBasedGenUIPage.spec.ts index 39352aba0..6590901ac 100644 --- a/typescript-sdk/apps/dojo/e2e/tests/mastraTests/toolBasedGenUIPage.spec.ts +++ b/typescript-sdk/apps/dojo/e2e/tests/mastraTests/toolBasedGenUIPage.spec.ts @@ -14,24 +14,26 @@ test("[Mastra] Haiku generation and display verification", async ({ page }) => { await genAIAgent.checkHaikuDisplay(page); }); -// test infra issue, not an integration issue -test.fixme( - "[Mastra] Haiku generation and UI consistency for two different prompts", - async ({ page }) => { - await page.goto(pageURL); - - const genAIAgent = new ToolBaseGenUIPage(page); - - await expect(genAIAgent.haikuAgentIntro).toBeVisible(); - - const prompt1 = 'Generate Haiku for "I will always win"'; - await genAIAgent.generateHaiku(prompt1); - await genAIAgent.checkGeneratedHaiku(); - await genAIAgent.checkHaikuDisplay(page); - - const prompt2 = 'Generate Haiku for "The moon shines bright"'; - await genAIAgent.generateHaiku(prompt2); - await genAIAgent.checkGeneratedHaiku(); // Wait for second haiku to be generated - await genAIAgent.checkHaikuDisplay(page); // Now compare the second haiku - }, -); +test("[Mastra] Haiku generation and UI consistency for two different prompts", async ({ page }) => { + await page.goto(pageURL); + + const genAIAgent = new ToolBaseGenUIPage(page); + + await expect(genAIAgent.haikuAgentIntro).toBeVisible(); + + const prompt1 = 'Generate Haiku for "I will always win"'; + await genAIAgent.generateHaiku(prompt1); + await genAIAgent.checkGeneratedHaiku(); + const haiku1Content = await genAIAgent.extractChatHaikuContent(page); + await genAIAgent.waitForMainDisplayHaiku(page, haiku1Content); + + const prompt2 = 'Generate Haiku for "The moon shines bright"'; + await genAIAgent.generateHaiku(prompt2); + await genAIAgent.checkGeneratedHaiku(); + const haiku2Content = await genAIAgent.extractChatHaikuContent(page); + + // Verify haikus are different + expect(haiku1Content).not.toBe(haiku2Content); + + await genAIAgent.waitForMainDisplayHaiku(page, haiku2Content); +}); diff --git a/typescript-sdk/apps/dojo/e2e/tests/pydanticAITests/toolBasedGenUIPage.spec.ts b/typescript-sdk/apps/dojo/e2e/tests/pydanticAITests/toolBasedGenUIPage.spec.ts index 3a21d88bc..2c5696465 100644 --- a/typescript-sdk/apps/dojo/e2e/tests/pydanticAITests/toolBasedGenUIPage.spec.ts +++ b/typescript-sdk/apps/dojo/e2e/tests/pydanticAITests/toolBasedGenUIPage.spec.ts @@ -1,12 +1,9 @@ import { test, expect } from "@playwright/test"; import { ToolBaseGenUIPage } from "../../featurePages/ToolBaseGenUIPage"; -const pageURL = - "/pydantic-ai/feature/tool_based_generative_ui"; +const pageURL = "/pydantic-ai/feature/tool_based_generative_ui"; -test('[PydanticAI] Haiku generation and display verification', async ({ - page, -}) => { +test("[PydanticAI] Haiku generation and display verification", async ({ page }) => { await page.goto(pageURL); const genAIAgent = new ToolBaseGenUIPage(page); @@ -17,7 +14,7 @@ test('[PydanticAI] Haiku generation and display verification', async ({ await genAIAgent.checkHaikuDisplay(page); }); -test('[PydanticAI] Haiku generation and UI consistency for two different prompts', async ({ +test("[PydanticAI] Haiku generation and UI consistency for two different prompts", async ({ page, }) => { await page.goto(pageURL); @@ -29,10 +26,16 @@ test('[PydanticAI] Haiku generation and UI consistency for two different prompts const prompt1 = 'Generate Haiku for "I will always win"'; await genAIAgent.generateHaiku(prompt1); await genAIAgent.checkGeneratedHaiku(); - await genAIAgent.checkHaikuDisplay(page); + const haiku1Content = await genAIAgent.extractChatHaikuContent(page); + await genAIAgent.waitForMainDisplayHaiku(page, haiku1Content); const prompt2 = 'Generate Haiku for "The moon shines bright"'; await genAIAgent.generateHaiku(prompt2); - await genAIAgent.checkGeneratedHaiku(); // Wait for second haiku to be generated - await genAIAgent.checkHaikuDisplay(page); // Now compare the second haiku -}); \ No newline at end of file + await genAIAgent.checkGeneratedHaiku(); + const haiku2Content = await genAIAgent.extractChatHaikuContent(page); + + // Verify haikus are different + expect(haiku1Content).not.toBe(haiku2Content); + + await genAIAgent.waitForMainDisplayHaiku(page, haiku2Content); +}); diff --git a/typescript-sdk/apps/dojo/e2e/tests/serverStarterAllFeaturesTests/toolBasedGenUIPage.spec.ts b/typescript-sdk/apps/dojo/e2e/tests/serverStarterAllFeaturesTests/toolBasedGenUIPage.spec.ts index 34598e4ce..b08bd9ef8 100644 --- a/typescript-sdk/apps/dojo/e2e/tests/serverStarterAllFeaturesTests/toolBasedGenUIPage.spec.ts +++ b/typescript-sdk/apps/dojo/e2e/tests/serverStarterAllFeaturesTests/toolBasedGenUIPage.spec.ts @@ -1,10 +1,9 @@ import { test, expect } from "@playwright/test"; import { ToolBaseGenUIPage } from "../../featurePages/ToolBaseGenUIPage"; -const pageURL = - "/server-starter-all-features/feature/tool_based_generative_ui"; +const pageURL = "/server-starter-all-features/feature/tool_based_generative_ui"; -test('[Server Starter all features] Haiku generation and display verification', async ({ +test("[Server Starter all features] Haiku generation and display verification", async ({ page, }) => { await page.goto(pageURL); @@ -17,7 +16,7 @@ test('[Server Starter all features] Haiku generation and display verification', await genAIAgent.checkHaikuDisplay(page); }); -test('[Server Starter all features] Haiku generation and UI consistency for two different prompts', async ({ +test("[Server Starter all features] Haiku generation and UI consistency for two different prompts", async ({ page, }) => { await page.goto(pageURL); @@ -29,10 +28,16 @@ test('[Server Starter all features] Haiku generation and UI consistency for two const prompt1 = 'Generate Haiku for "I will always win"'; await genAIAgent.generateHaiku(prompt1); await genAIAgent.checkGeneratedHaiku(); - await genAIAgent.checkHaikuDisplay(page); + const haiku1Content = await genAIAgent.extractChatHaikuContent(page); + await genAIAgent.waitForMainDisplayHaiku(page, haiku1Content); const prompt2 = 'Generate Haiku for "The moon shines bright"'; await genAIAgent.generateHaiku(prompt2); await genAIAgent.checkGeneratedHaiku(); - await genAIAgent.checkHaikuDisplay(page); -}); \ No newline at end of file + const haiku2Content = await genAIAgent.extractChatHaikuContent(page); + + // Verify haikus are different + expect(haiku1Content).not.toBe(haiku2Content); + + await genAIAgent.waitForMainDisplayHaiku(page, haiku2Content); +});