Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add FE tests for new starter project templates #6772

Merged
merged 6 commits into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 110 additions & 0 deletions src/frontend/tests/core/integrations/Price Deal Finder.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
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(
"Price Deal Finder",
{ tag: ["@release", "@starter-projects"] },
async ({ page }) => {
test.skip(
!process?.env?.AGENTQL_API_KEY,
"AGENTQL_API_KEY required to run this test",
);

test.skip(
!process?.env?.OPENAI_API_KEY,
"OPENAI_API_KEY required to run this test",
);

test.skip(
!process?.env?.TAVILY_API_KEY,
"TAVILY_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: "Price Deal Finder" }).click();

await page.waitForSelector('[data-testid="fit_view"]', {
timeout: 100000,
});

await initialGPTsetup(page, {
skipAdjustScreenView: true,
skipAddNewApiKeys: true,
skipSelectGptModel: true,
});

await page
.getByTestId("popover-anchor-input-api_key")
.nth(0)
.fill(process?.env?.TAVILY_API_KEY ?? "");

await page
.getByTestId("popover-anchor-input-api_key")
.nth(1)
.fill(process?.env?.AGENTQL_API_KEY ?? "");

await page
.getByTestId("popover-anchor-input-api_key")
.nth(2)
.fill(process?.env?.OPENAI_API_KEY ?? "");

await page.getByTestId("playground-btn-flow-io").click();

await page.waitForSelector('[data-testid="button-send"]', {
timeout: 3000,
});

const product = randomProduct();

await page.getByTestId("input-chat-playground").fill(product);

await page.getByTestId("button-send").click();

try {
await page.waitForSelector('[data-testid="button-stop"]', {
timeout: 180000,
state: "hidden",
});
} catch (error) {
console.log("Timeout error");
test.skip(true, "Timeout error");
}

await page.waitForSelector(".markdown", { timeout: 3000 });

const textContents = await page.locator(".markdown").allTextContents();

const concatAllText = textContents.join(" ").toLowerCase();

expect(concatAllText.length).toBeGreaterThan(100);

const zeldaChapter = product.split(" ")[1];
expect(concatAllText).toContain(zeldaChapter);
},
);

const randomProduct = () => {
const products = [
"Zelda Tears of the Kingdom",
"Zelda Ocarina of Time",
"Zelda Majora's Mask",
"Zelda The Wind Waker",
"Zelda Twilight Princess",
"Zelda Skyward Sword",
"Zelda Breath of the Wild",
"Zelda Link's Awakening",
"Zelda Link to the Past",
];

return products[Math.floor(Math.random() * products.length)].toLowerCase();
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
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(
"Research Translation Loop.spec",
{ tag: ["@release", "@starter-projects"] },
async ({ page }) => {
test.skip(
!process?.env?.ANTHROPIC_API_KEY,
"ANTHROPIC_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: "Research Translation Loop" })
.click();

await page.waitForSelector('[data-testid="fit_view"]', {
timeout: 100000,
});

await initialGPTsetup(page, {
skipAdjustScreenView: true,
skipAddNewApiKeys: true,
skipSelectGptModel: true,
});

await page
.getByTestId("popover-anchor-input-api_key")
.last()
.fill(process.env.ANTHROPIC_API_KEY ?? "");

await page.waitForSelector('[data-testid="dropdown_str_model_name"]', {
timeout: 5000,
});

await page.getByTestId("dropdown_str_model_name").click();

await page.keyboard.press("Enter");

await page.getByTestId("playground-btn-flow-io").click();

await page.waitForSelector('[data-testid="button-send"]', {
timeout: 3000,
});

await page.getByTestId("input-chat-playground").fill("This is a test");

await page.getByTestId("button-send").click();

await page.waitForSelector('[data-testid="div-chat-message"]', {
timeout: 30000,
});

const textContents = await page
.getByTestId("div-chat-message")
.allTextContents();

const concatAllText = textContents.join(" ").toLowerCase();

expect(concatAllText.length).toBeGreaterThan(300);
},
);
Loading