From 56bcb85e03d30b9e7194d8a14e03082b4ac5ff0a Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Fri, 6 Dec 2024 23:25:40 -0300 Subject: [PATCH] fix: Improve test and add improve timeouts (#5142) * fix: Improve test and add missing timeouts The test in the generalBugs-shard-13.spec.ts file was improved to include missing timeouts for better stability and reliability. --- .../regression/generalBugs-shard-13.spec.ts | 34 ++++++++----------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/src/frontend/tests/extended/regression/generalBugs-shard-13.spec.ts b/src/frontend/tests/extended/regression/generalBugs-shard-13.spec.ts index 6962ef80a..4ed10537d 100644 --- a/src/frontend/tests/extended/regression/generalBugs-shard-13.spec.ts +++ b/src/frontend/tests/extended/regression/generalBugs-shard-13.spec.ts @@ -1,4 +1,4 @@ -import { test } from "@playwright/test"; +import { expect, test } from "@playwright/test"; import * as dotenv from "dotenv"; import path from "path"; @@ -16,7 +16,6 @@ test( } await page.goto("/"); - await page.waitForTimeout(1000); let modalCount = 0; try { @@ -30,39 +29,40 @@ test( while (modalCount === 0) { await page.getByText("New Flow", { exact: true }).click(); - await page.waitForTimeout(5000); + await page.waitForSelector('[data-testid="modal-title"]', { + timeout: 3000, + }); modalCount = await page.getByTestId("modal-title")?.count(); } await page.getByText("Close", { exact: true }).click(); - await page.waitForTimeout(1000); - + await page.waitForSelector('[data-testid="user-profile-settings"]', { + timeout: 3000, + }); await page.getByTestId("user-profile-settings").click(); - await page.waitForTimeout(500); await page.getByText("Settings", { exact: true }).first().click(); - await page.waitForTimeout(1000); - await page .getByPlaceholder("Insert your API Key") .fill(process.env.STORE_API_KEY ?? ""); await page.getByTestId("api-key-save-button-store").click(); - await page.waitForTimeout(1000); - - await page.getByText("Success! Your API Key has been saved.").isVisible(); - - await page.waitForTimeout(1000); + await expect(page.getByText("API key saved successfully")).toBeVisible({ + timeout: 3000, + }); await page.waitForSelector('[data-testid="icon-ChevronLeft"]', { timeout: 100000, }); await page.getByTestId("icon-ChevronLeft").first().click(); - await page.waitForTimeout(1000); + + await expect(page.getByText("New Flow", { exact: true })).toBeVisible({ + timeout: 3000, + }); await page.getByText("New Flow", { exact: true }).click(); @@ -74,8 +74,6 @@ test( await page.getByTestId("shared-button-flow").click(); - await page.waitForTimeout(500); - await page.waitForSelector("text=Share Flow", { timeout: 10000, }); @@ -96,16 +94,12 @@ test( timeout: 10000, }); - await page.waitForTimeout(500); - await page.waitForSelector("text=share", { timeout: 10000 }); await page.waitForSelector("text=playground", { timeout: 10000 }); await page.waitForSelector("text=api", { timeout: 10000 }); await page.getByTestId("shared-button-flow").click(); - await page.waitForTimeout(500); - await page.waitForSelector("text=Publish workflow to the Langflow Store.", { timeout: 10000, });