From 905ea027798e42f54df78b06b09f09abe360da44 Mon Sep 17 00:00:00 2001 From: Cristhian Zanforlin Lousa Date: Fri, 21 Mar 2025 08:51:24 -0300 Subject: [PATCH] fix: Test Stability Enhancements (nightly fix) (#7207) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ✨ (PageComponent/index.tsx): Update maxZoom value to 3 for better user experience 🔧 (globalVariables.spec.ts): Refactor code to use hover and click methods for better readability and maintainability ♻️ (publish-flow.spec.ts): Refactor adjustScreenView function to accept parameters for better flexibility and update zoom out value to 3 * ✨ (globalVariables.spec.ts): update the selector for clicking the last element with the test ID "add-component-button-openai" to ensure the correct element is clicked ✨ (publish-flow.spec.ts): update the selector for clicking the last element with the test ID "add-component-button-chat-input" to ensure the correct element is clicked --- .../components/PageComponent/index.tsx | 2 +- .../core/features/filterEdge-shard-0.spec.ts | 4 +++ .../core/features/globalVariables.spec.ts | 9 +++--- .../tests/core/features/publish-flow.spec.ts | 29 ++++--------------- 4 files changed, 16 insertions(+), 28 deletions(-) diff --git a/src/frontend/src/pages/FlowPage/components/PageComponent/index.tsx b/src/frontend/src/pages/FlowPage/components/PageComponent/index.tsx index 62e348e77..8d3448721 100644 --- a/src/frontend/src/pages/FlowPage/components/PageComponent/index.tsx +++ b/src/frontend/src/pages/FlowPage/components/PageComponent/index.tsx @@ -578,7 +578,7 @@ export default function Page({ }} className="theme-attribution" minZoom={0.2} - maxZoom={8} + maxZoom={3} zoomOnScroll={!view} zoomOnPinch={!view} panOnDrag={!view} diff --git a/src/frontend/tests/core/features/filterEdge-shard-0.spec.ts b/src/frontend/tests/core/features/filterEdge-shard-0.spec.ts index 15c40d80f..27acb1338 100644 --- a/src/frontend/tests/core/features/filterEdge-shard-0.spec.ts +++ b/src/frontend/tests/core/features/filterEdge-shard-0.spec.ts @@ -64,6 +64,8 @@ test( .getByTestId("handle-retrievalqa-shownode-language model-left") .all(); + await page.waitForTimeout(1000); + for (const element of rqaChainInputElements1) { if (await element.isVisible()) { visibleElementHandle = element; @@ -71,6 +73,8 @@ test( } } + await page.waitForTimeout(1000); + await visibleElementHandle.hover().then(async () => { await expect( page.getByText("Drag to connect compatible outputs").first(), diff --git a/src/frontend/tests/core/features/globalVariables.spec.ts b/src/frontend/tests/core/features/globalVariables.spec.ts index d0a47caf0..9099c2ef5 100644 --- a/src/frontend/tests/core/features/globalVariables.spec.ts +++ b/src/frontend/tests/core/features/globalVariables.spec.ts @@ -21,11 +21,12 @@ test( await page .getByTestId("modelsOpenAI") - .dragTo(page.locator('//*[@id="react-flow-id"]')); - await page.mouse.up(); - await page.mouse.down(); + .hover() + .then(async () => { + await page.getByTestId("add-component-button-openai").last().click(); + }); - await adjustScreenView(page); + await page.getByTestId("fit_view").click(); const genericName = Math.random().toString(); const credentialName = Math.random().toString(); diff --git a/src/frontend/tests/core/features/publish-flow.spec.ts b/src/frontend/tests/core/features/publish-flow.spec.ts index 917ecac83..b3713f689 100644 --- a/src/frontend/tests/core/features/publish-flow.spec.ts +++ b/src/frontend/tests/core/features/publish-flow.spec.ts @@ -12,27 +12,6 @@ test( timeout: 5000, }); - let flowId = ""; - let retries = 0; - const maxRetries = 3; - - while (flowId.length === 0 && retries < maxRetries) { - const url = page.url(); - flowId = url.split("/").pop() || ""; - - if (flowId.length === 0) { - console.log( - `Empty flowId detected (attempt ${retries + 1}/${maxRetries}), waiting and retrying...`, - ); - await page.waitForTimeout(1000); - retries++; - } - } - - expect(flowId).toBeDefined(); - expect(flowId).not.toBeNull(); - expect(flowId.length).toBeGreaterThan(0); - await page.getByTestId("blank-flow").click(); await page.waitForSelector('[data-testid="sidebar-search-input"]', { timeout: 5000, @@ -44,16 +23,20 @@ test( await page.waitForSelector('[data-testid="inputsChat Input"]', { timeout: 3000, }); + await page .getByTestId("inputsChat Input") .hover({ timeout: 3000 }) .then(async () => { - await page.getByTestId("add-component-button-chat-input").click(); + await page + .getByTestId("add-component-button-chat-input") + .last() + .click(); }); await page.waitForTimeout(2000); - await adjustScreenView(page); + await adjustScreenView(page, { numberOfZoomOut: 3 }); await page.getByTestId("publish-button").click(); await page.waitForTimeout(3000);