From 7114061f6786a70ecc75bc1afee0b00b5aa7274f Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Sat, 7 Dec 2024 01:14:08 -0300 Subject: [PATCH] refactor: Improve page loading and element visibility in regression tests (#5136) fix: Improve page loading and element visibility in regression tests --- .../regression/generalBugs-shard-3.spec.ts | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/frontend/tests/extended/regression/generalBugs-shard-3.spec.ts b/src/frontend/tests/extended/regression/generalBugs-shard-3.spec.ts index 65b11718b..233e357fa 100644 --- a/src/frontend/tests/extended/regression/generalBugs-shard-3.spec.ts +++ b/src/frontend/tests/extended/regression/generalBugs-shard-3.spec.ts @@ -39,7 +39,9 @@ test( while (modalCount === 0) { await page.getByText("New Flow", { exact: true }).click(); - await page.waitForTimeout(3000); + await page.waitForSelector('[data-testid="modal-title"]', { + timeout: 3000, + }); modalCount = await page.getByTestId("modal-title")?.count(); } @@ -48,9 +50,15 @@ test( }); await page.getByTestId("blank-flow").click(); + await page.waitForSelector('[data-testid="sidebar-search-input"]', { + timeout: 30000, + }); await page.getByTestId("sidebar-search-input").click(); await page.getByTestId("sidebar-search-input").fill("chat output"); - await page.waitForTimeout(1000); + + await page.waitForSelector('[data-testid="outputsChat Output"]', { + timeout: 30000, + }); await page .getByTestId("outputsChat Output") @@ -65,7 +73,9 @@ test( await page.getByTestId("sidebar-search-input").click(); await page.getByTestId("sidebar-search-input").fill("chat input"); - await page.waitForTimeout(1000); + await page.waitForSelector('[data-testid="inputsChat Input"]', { + timeout: 30000, + }); await page .getByTestId("inputsChat Input") @@ -75,7 +85,6 @@ test( await page.getByTestId("sidebar-search-input").click(); await page.getByTestId("sidebar-search-input").fill("openai"); - await page.waitForTimeout(1000); await page.getByTestId("fit_view").click(); await page.getByTestId("zoom_out").click(); @@ -104,14 +113,12 @@ test( while (outdatedComponents > 0) { await page.getByTestId("icon-AlertTriangle").first().click(); - await page.waitForTimeout(1000); outdatedComponents = await page.getByTestId("icon-AlertTriangle").count(); } let filledApiKey = await page.getByTestId("remove-icon-badge").count(); while (filledApiKey > 0) { await page.getByTestId("remove-icon-badge").first().click(); - await page.waitForTimeout(1000); filledApiKey = await page.getByTestId("remove-icon-badge").count(); } @@ -218,7 +225,6 @@ test( timeout: 30000, }); - await page.waitForTimeout(1000); await page.getByTestId("copy-code-button").last().click(); const handle = await page.evaluateHandle(() => @@ -256,7 +262,9 @@ test( while (modalCount === 0) { await page.getByText("New Flow", { exact: true }).click(); - await page.waitForTimeout(3000); + await page.waitForSelector('[data-testid="modal-title"]', { + timeout: 3000, + }); modalCount = await page.getByTestId("modal-title")?.count(); } @@ -273,8 +281,9 @@ test( await page.getByTestId("sidebar-search-input").click(); await page.getByTestId("sidebar-search-input").fill("chat output"); - await page.waitForTimeout(1000); - + await page.waitForSelector('[data-testid="outputsChat Output"]', { + timeout: 30000, + }); await page .locator('//*[@id="outputsChat Output"]') .dragTo(page.locator('//*[@id="react-flow-id"]')); @@ -284,8 +293,6 @@ test( timeout: 100000, }); - await page.waitForTimeout(1000); - await page.getByTestId("playground-btn-flow-io").click({ force: true }); expect(await page.getByText("Langflow Chat").isVisible());