Skip to content

Commit

Permalink
✨ (Dynamic Agent.spec.ts): Add end-to-end test for Dynamic Agent func…
Browse files Browse the repository at this point in the history
…tionality

✨ (Simple Agent.spec.ts): Add end-to-end test for Simple Agent functionality
✨ (Travel Planning Agent.spec.ts): Add end-to-end test for Travel Planning Agent functionality
  • Loading branch information
Cristhianzl committed Aug 29, 2024
1 parent 72c5594 commit a3f8cec
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Original file line number Diff line number Diff line change
Expand Up @@ -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") });
}
Expand Down Expand Up @@ -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,
Expand All @@ -63,48 +58,49 @@ 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,
});

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);
});
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 });

Expand All @@ -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");
});

0 comments on commit a3f8cec

Please sign in to comment.