From a3f8cec2513c3317337e6ae50417de9c5ccd3445 Mon Sep 17 00:00:00 2001 From: cristhianzl Date: Thu, 29 Aug 2024 17:05:00 -0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20(Dynamic=20Agent.spec.ts):=20Add=20?= =?UTF-8?q?end-to-end=20test=20for=20Dynamic=20Agent=20functionality=20?= =?UTF-8?q?=E2=9C=A8=20(Simple=20Agent.spec.ts):=20Add=20end-to-end=20test?= =?UTF-8?q?=20for=20Simple=20Agent=20functionality=20=E2=9C=A8=20(Travel?= =?UTF-8?q?=20Planning=20Agent.spec.ts):=20Add=20end-to-end=20test=20for?= =?UTF-8?q?=20Travel=20Planning=20Agent=20functionality?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ex Agent.spec.ts => Dynamic Agent.spec.ts} | 2 +- ...sks Agent.spec.ts => Simple Agent.spec.ts} | 68 +++++++++---------- ....spec.ts => Travel Planning Agent.spec.ts} | 38 ++++------- 3 files changed, 47 insertions(+), 61 deletions(-) rename src/frontend/tests/end-to-end/{Complex Agent.spec.ts => Dynamic Agent.spec.ts} (98%) rename src/frontend/tests/end-to-end/{Hierarchical Tasks Agent.spec.ts => Simple Agent.spec.ts} (63%) rename src/frontend/tests/end-to-end/{Sequential Tasks Agent.spec.ts => Travel Planning Agent.spec.ts} (71%) diff --git a/src/frontend/tests/end-to-end/Complex Agent.spec.ts b/src/frontend/tests/end-to-end/Dynamic Agent.spec.ts similarity index 98% rename from src/frontend/tests/end-to-end/Complex Agent.spec.ts rename to src/frontend/tests/end-to-end/Dynamic Agent.spec.ts index 64658f3aa855..0a798185d1cd 100644 --- a/src/frontend/tests/end-to-end/Complex Agent.spec.ts +++ b/src/frontend/tests/end-to-end/Dynamic Agent.spec.ts @@ -104,5 +104,5 @@ test("Dynamic Agent", async ({ page }) => { const concatAllText = textContents.join(" "); expect(concatAllText.toLocaleLowerCase()).toContain("apple"); const allTextLength = concatAllText.length; - expect(allTextLength).toBeGreaterThan(500); + expect(allTextLength).toBeGreaterThan(100); }); diff --git a/src/frontend/tests/end-to-end/Hierarchical Tasks Agent.spec.ts b/src/frontend/tests/end-to-end/Simple Agent.spec.ts similarity index 63% rename from src/frontend/tests/end-to-end/Hierarchical Tasks Agent.spec.ts rename to src/frontend/tests/end-to-end/Simple Agent.spec.ts index 3752b24c4fe4..d8325d36b92d 100644 --- a/src/frontend/tests/end-to-end/Hierarchical Tasks Agent.spec.ts +++ b/src/frontend/tests/end-to-end/Simple Agent.spec.ts @@ -2,17 +2,12 @@ import { expect, test } from "@playwright/test"; import * as dotenv from "dotenv"; import path from "path"; -test("Hierarchical Tasks Agent", async ({ page }) => { +test("Simple Agent", async ({ page }) => { test.skip( !process?.env?.OPENAI_API_KEY, "OPENAI_API_KEY required to run this test", ); - test.skip( - !process?.env?.BRAVE_SEARCH_API_KEY, - "BRAVE_SEARCH_API_KEY required to run this test", - ); - if (!process.env.CI) { dotenv.config({ path: path.resolve(__dirname, "../../.env") }); } @@ -42,7 +37,7 @@ test("Hierarchical Tasks Agent", async ({ page }) => { modalCount = await page.getByTestId("modal-title")?.count(); } - await page.getByRole("heading", { name: "Hierarchical Tasks Agent" }).click(); + await page.getByRole("heading", { name: "Simple Agent" }).click(); await page.waitForSelector('[title="fit view"]', { timeout: 100000, @@ -63,33 +58,15 @@ test("Hierarchical Tasks Agent", async ({ page }) => { await page .getByTestId("popover-anchor-input-api_key") - .first() - .fill(process.env.OPENAI_API_KEY ?? ""); - - await page - .getByTestId("popover-anchor-input-api_key") - .nth(1) .fill(process.env.OPENAI_API_KEY ?? ""); - await page.getByTestId("dropdown_str_model_name").first().click(); - await page.getByTestId("gpt-4o-1-option").first().click(); - - await page.waitForTimeout(1000); - - await page.getByTestId("dropdown_str_model_name").last().click(); - await page.getByTestId("gpt-4o-1-option").last().click(); - - await page.waitForTimeout(1000); - - await page - .getByTestId("popover-anchor-input-api_key") - .last() - .fill(process.env.BRAVE_SEARCH_API_KEY ?? ""); + await page.getByTestId("dropdown_str_model_name").click(); + await page.getByTestId("gpt-4o-1-option").click(); await page.waitForTimeout(1000); await page.getByTestId("button_run_chat output").click(); - await page.waitForSelector("text=built successfully", { timeout: 60000 * 3 }); + await page.waitForSelector("text=built successfully", { timeout: 30000 }); await page.getByText("built successfully").last().click({ timeout: 15000, @@ -97,14 +74,33 @@ test("Hierarchical Tasks Agent", async ({ page }) => { await page.getByText("Playground", { exact: true }).click(); - await page.waitForTimeout(3000); + await page.waitForSelector( + "text=write short python scsript to say hello world", + { + timeout: 30000, + }, + ); + + await page.waitForTimeout(1000); + + expect(await page.getByText("User")).toBeVisible(); + + expect(await page.locator(".language-python")).toBeVisible(); + + let pythonWords = await page.getByText("Hello, World!").count(); + + expect(pythonWords).toBe(2); + + await page.getByTestId("icon-Copy").last().click(); + + await page.waitForTimeout(500); + + await page.getByPlaceholder("Send a message...").click(); + await page.keyboard.press("Control+V"); + + await page.waitForTimeout(500); - const textContents = await page - .getByTestId("div-chat-message") - .allTextContents(); + pythonWords = await page.getByText("Hello, World!").count(); - const concatAllText = textContents.join(" "); - expect(concatAllText.toLocaleLowerCase()).toContain("langflow"); - const allTextLength = concatAllText.length; - expect(allTextLength).toBeGreaterThan(500); + expect(pythonWords).toBe(3); }); diff --git a/src/frontend/tests/end-to-end/Sequential Tasks Agent.spec.ts b/src/frontend/tests/end-to-end/Travel Planning Agent.spec.ts similarity index 71% rename from src/frontend/tests/end-to-end/Sequential Tasks Agent.spec.ts rename to src/frontend/tests/end-to-end/Travel Planning Agent.spec.ts index d841ccab67fc..6edd61ab0d81 100644 --- a/src/frontend/tests/end-to-end/Sequential Tasks Agent.spec.ts +++ b/src/frontend/tests/end-to-end/Travel Planning Agent.spec.ts @@ -2,15 +2,15 @@ import { expect, test } from "@playwright/test"; import * as dotenv from "dotenv"; import path from "path"; -test("Sequential Tasks Agent", async ({ page }) => { +test("Travel Planning Agent", async ({ page }) => { test.skip( !process?.env?.OPENAI_API_KEY, "OPENAI_API_KEY required to run this test", ); test.skip( - !process?.env?.BRAVE_SEARCH_API_KEY, - "BRAVE_SEARCH_API_KEY required to run this test", + !process?.env?.SEARCH_API_KEY, + "SEARCH_API_KEY required to run this test", ); if (!process.env.CI) { @@ -42,7 +42,7 @@ test("Sequential Tasks Agent", async ({ page }) => { modalCount = await page.getByTestId("modal-title")?.count(); } - await page.getByRole("heading", { name: "Sequential Tasks Agent" }).click(); + await page.getByRole("heading", { name: "Travel Planning Agents" }).click(); await page.waitForSelector('[title="fit view"]', { timeout: 100000, @@ -76,8 +76,6 @@ test("Sequential Tasks Agent", async ({ page }) => { .last() .fill(process.env.BRAVE_SEARCH_API_KEY ?? ""); - await page.waitForTimeout(1000); - await page.getByTestId("button_run_chat output").click(); await page.waitForSelector("text=built successfully", { timeout: 60000 * 3 }); @@ -87,26 +85,18 @@ test("Sequential Tasks Agent", async ({ page }) => { await page.getByText("Playground", { exact: true }).click(); - await page.waitForTimeout(1000); + await page.waitForSelector("text=default session", { + timeout: 30000, + }); - expect( - page - .getByPlaceholder("No chat input variables found. Click to run your flow") - .last(), - ).toBeVisible(); + await page.waitForTimeout(1000); - await page.getByText("Topic", { exact: true }).nth(1).isVisible(); - await page.getByText("Topic", { exact: true }).nth(1).click(); - expect(await page.getByPlaceholder("Enter text...").inputValue()).toBe( - "Agile", - ); + const output = await page.getByTestId("div-chat-message").allTextContents(); + const outputText = output.join("\n"); - const textContents = await page - .getByTestId("div-chat-message") - .allTextContents(); + expect(outputText.toLowerCase()).toContain("weather"); + expect(outputText.toLowerCase()).toContain("budget"); - const concatAllText = textContents.join(" "); - expect(concatAllText.toLocaleLowerCase()).toContain("agile"); - const allTextLength = concatAllText.length; - expect(allTextLength).toBeGreaterThan(500); + expect(outputText.toLowerCase()).toContain("uberlândia"); + expect(outputText.toLowerCase()).toContain("pão de queijo"); });