From 72f2528216eb39bfe322cbee75e5dbcfab5dd45a Mon Sep 17 00:00:00 2001 From: Cristhian Zanforlin Lousa Date: Fri, 14 Mar 2025 11:44:53 -0300 Subject: [PATCH] test: add pokedex agent and social media agent integration tests (#7087) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ✨ (Pokedex Agent.spec.ts): Add integration test for Pokedex Agent to interact with the Pokédex feature and verify expected outputs ✨ (Social Media Agent.spec.ts): Add integration test for Social Media Agent to interact with social media platforms and verify expected outputs --- .../core/integrations/Pokedex Agent.spec.ts | 52 ++++++++++++++ .../integrations/Social Media Agent.spec.ts | 69 +++++++++++++++++++ 2 files changed, 121 insertions(+) create mode 100644 src/frontend/tests/core/integrations/Pokedex Agent.spec.ts create mode 100644 src/frontend/tests/core/integrations/Social Media Agent.spec.ts diff --git a/src/frontend/tests/core/integrations/Pokedex Agent.spec.ts b/src/frontend/tests/core/integrations/Pokedex Agent.spec.ts new file mode 100644 index 000000000..dd8f5d561 --- /dev/null +++ b/src/frontend/tests/core/integrations/Pokedex Agent.spec.ts @@ -0,0 +1,52 @@ +import { expect, test } from "@playwright/test"; +import * as dotenv from "dotenv"; +import path from "path"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; +import { initialGPTsetup } from "../../utils/initialGPTsetup"; +import { withEventDeliveryModes } from "../../utils/withEventDeliveryModes"; + +withEventDeliveryModes( + "Pokedex Agent", + { tag: ["@release", "@starter-projects"] }, + async ({ page }) => { + test.skip( + !process?.env?.OPENAI_API_KEY, + "OPENAI_API_KEY required to run this test", + ); + + if (!process.env.CI) { + dotenv.config({ path: path.resolve(__dirname, "../../.env") }); + } + + await awaitBootstrapTest(page); + + await page.getByTestId("side_nav_options_all-templates").click(); + await page.getByRole("heading", { name: "Pokédex Agent" }).click(); + + await initialGPTsetup(page); + + await page.getByTestId("playground-btn-flow-io").click(); + + await page + .getByTestId("input-chat-playground") + .last() + .fill("Can I catch a Charizard in Pokemon Yellow?"); + + await page.getByTestId("button-send").last().click(); + + const stopButton = page.getByRole("button", { name: "Stop" }); + await stopButton.waitFor({ state: "visible", timeout: 30000 }); + + if (await stopButton.isVisible()) { + await expect(stopButton).toBeHidden({ timeout: 120000 }); + } + + const output = await page + .getByTestId("div-chat-message") + .last() + .innerText(); + expect(output).toContain("Charmander"); + expect(output).toContain("Route 24"); + expect(output.length).toBeGreaterThan(100); + }, +); diff --git a/src/frontend/tests/core/integrations/Social Media Agent.spec.ts b/src/frontend/tests/core/integrations/Social Media Agent.spec.ts new file mode 100644 index 000000000..7055cccf6 --- /dev/null +++ b/src/frontend/tests/core/integrations/Social Media Agent.spec.ts @@ -0,0 +1,69 @@ +import { expect, test } from "@playwright/test"; +import * as dotenv from "dotenv"; +import path from "path"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; +import { initialGPTsetup } from "../../utils/initialGPTsetup"; +import { withEventDeliveryModes } from "../../utils/withEventDeliveryModes"; + +withEventDeliveryModes( + "Social Media Agent", + { tag: ["@release", "@starter-projects"] }, + async ({ page }) => { + test.skip( + !process?.env?.APIFY_API_TOKEN, + "APIFY_API_TOKEN required to run this test", + ); + + if (!process.env.CI) { + dotenv.config({ path: path.resolve(__dirname, "../../.env") }); + } + + await awaitBootstrapTest(page); + + await page.getByTestId("side_nav_options_all-templates").click(); + await page.getByRole("heading", { name: "Social Media Agent" }).click(); + + await initialGPTsetup(page); + + const apifyApiTokenInputCount = await page + .getByTestId("popover-anchor-input-apify_token") + .count(); + + for (let i = 0; i < apifyApiTokenInputCount; i++) { + await page + .getByTestId("popover-anchor-input-apify_token") + .nth(i) + .fill(process.env.APIFY_API_TOKEN ?? ""); + } + + await page + .getByTestId("popover-anchor-input-apify_token") + .nth(apifyApiTokenInputCount - 1) + .fill(process.env.APIFY_API_TOKEN ?? ""); + + await page.getByTestId("playground-btn-flow-io").click(); + + await page + .getByTestId("input-chat-playground") + .last() + .fill( + "Find the TikTok profile of the company OpenAI using Google search, then show me the profile bio and their latest video.", + ); + + await page.getByTestId("button-send").last().click(); + + const stopButton = page.getByRole("button", { name: "Stop" }); + await stopButton.waitFor({ state: "visible", timeout: 30000 }); + + if (await stopButton.isVisible()) { + await expect(stopButton).toBeHidden({ timeout: 120000 }); + } + + const output = await page + .getByTestId("div-chat-message") + .last() + .innerText(); + expect(output).toContain("TikTok"); + expect(output.length).toBeGreaterThan(300); + }, +);