From c9bedb21c94a39f08959cd2df0ebd42b17a7248d Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Mon, 9 Dec 2024 09:18:57 -0300 Subject: [PATCH] refactor: Improve wait time for modals and elements in regression tests (#5141) * feat: Improve wait time for modals and elements in regression tests - Increase the timeout for waiting for modals and elements in regression tests to 3000ms. - Replace the usage of `waitForTimeout` with `waitForSelector` for better reliability. * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- .../regression/generalBugs-shard-11.spec.ts | 38 +++++++++++-------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/src/frontend/tests/extended/regression/generalBugs-shard-11.spec.ts b/src/frontend/tests/extended/regression/generalBugs-shard-11.spec.ts index 448b92be7..b8809d2c6 100644 --- a/src/frontend/tests/extended/regression/generalBugs-shard-11.spec.ts +++ b/src/frontend/tests/extended/regression/generalBugs-shard-11.spec.ts @@ -23,7 +23,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(); } @@ -34,7 +36,9 @@ test( await page.getByTestId("sidebar-search-input").click(); await page.getByTestId("sidebar-search-input").fill("composio"); - await page.waitForTimeout(1000); + await page.waitForSelector('[data-testid="composioComposio Tools"]', { + timeout: 3000, + }); const modelElement = await page.getByTestId("composioComposio Tools"); const targetElement = await page.locator('//*[@id="react-flow-id"]'); @@ -47,9 +51,10 @@ test( await page.getByTestId("zoom_out").click(); await page.getByTestId("zoom_out").click(); - await page.waitForTimeout(1000); - - expect(await page.getByText("api_key").isVisible()).toBe(false); + await expect(page.getByText("api_key")).toBeVisible({ + timeout: 3000, + visible: false, + }); }, ); @@ -76,7 +81,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(); } @@ -87,7 +94,9 @@ test( await page.getByTestId("sidebar-search-input").click(); await page.getByTestId("sidebar-search-input").fill("search api"); - await page.waitForTimeout(1000); + await page.waitForSelector('[data-testid="toolsSearch API"]', { + timeout: 3000, + }); let modelElement = await page.getByTestId("toolsSearch API"); let targetElement = await page.locator('//*[@id="react-flow-id"]'); @@ -100,16 +109,17 @@ test( await page.getByTestId("zoom_out").click(); await page.getByTestId("zoom_out").click(); - await page.waitForTimeout(1000); - await page.getByTestId("sidebar-search-input").click(); await page.getByTestId("sidebar-search-input").fill("tool calling agent"); - await page.waitForTimeout(1000); - - modelElement = await page.getByTestId( - "langchain_utilitiesTool Calling Agent", + await page.waitForSelector( + '[data-testid="langchain_utilitiesTool Calling Agent"]', + { + timeout: 3000, + }, ); + + modelElement = page.getByTestId("langchain_utilitiesTool Calling Agent"); targetElement = await page.locator('//*[@id="react-flow-id"]'); await modelElement.dragTo(targetElement); @@ -132,8 +142,6 @@ test( await toolCallingAgentInput.hover(); await page.mouse.up(); - await page.waitForTimeout(1000); - expect(await page.locator(".react-flow__edge-interaction").count()).toBe(1); }, );