From ab68e13493385df54d9fecec7c6d8c5935f4576d Mon Sep 17 00:00:00 2001 From: Cristhian Zanforlin Lousa Date: Mon, 9 Dec 2024 17:30:56 -0300 Subject: [PATCH] test: Add utility functions to streamline test setup and improve maintainability (#5168) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * change tests to use utils libs * 🔧 (frontend): add data-testid attribute to buttons in baseModal and secretKeyModal components 🔧 (frontend): add data-testid attribute to buttons in various test files for improved testing 🔧 (frontend): refactor awaitBootstrapTest function to remove skipNewFlow option and improve modal handling * ✅ (userSettings.spec.ts): add a 1-second timeout before checking for the "Please save" text to ensure it is rendered on the page before interacting with it * ✅ (userSettings.spec.ts): add comment to clarify waiting for API key creation to complete before proceeding to the next form element * ✨ (freeze-path.spec.ts): refactor adjustScreenView function to accept a parameter for the number of zoom outs to perform, improving flexibility and reusability in test scenarios. 🔧 (freeze-path.spec.ts): replace adjustScreenView function with initialGPTsetup function for setting up initial GPT configuration in the test scenario. --- .../components/FlowMenu/index.tsx | 2 +- src/frontend/src/modals/baseModal/index.tsx | 10 +- .../src/modals/secretKeyModal/index.tsx | 1 + .../features/actionsMainPage-shard-1.spec.ts | 79 +------------ .../core/features/auto-login-off.spec.ts | 33 +----- .../chatInputOutputUser-shard-0.spec.ts | 55 +-------- .../core/features/componentHoverAdd.spec.ts | 24 +--- .../core/features/filterEdge-shard-0.spec.ts | 41 ++----- .../tests/core/features/filterSidebar.spec.ts | 34 +----- .../tests/core/features/folders.spec.ts | 53 +-------- .../tests/core/features/freeze-path.spec.ts | 62 +---------- .../tests/core/features/freeze.spec.ts | 31 +----- .../core/features/globalVariables.spec.ts | 37 +----- .../tests/core/features/group.spec.ts | 18 +-- .../features/keyboardComponentSearch.spec.ts | 24 +--- src/frontend/tests/core/features/logs.spec.ts | 28 +---- .../tests/core/features/playground.spec.ts | 40 ++----- .../core/features/saveComponents.spec.ts | 19 +--- .../tests/core/features/stop-building.spec.ts | 86 +++----------- .../tests/core/features/store-shard-2.spec.ts | 18 +-- .../tests/core/features/tweaksTest.spec.ts | 47 +------- .../core/integrations/Basic Prompting.spec.ts | 63 +---------- .../core/integrations/Blog Writer.spec.ts | 62 +---------- .../core/integrations/Document QA.spec.ts | 63 +---------- .../core/integrations/Dynamic Agent.spec.ts | 64 ++--------- .../integrations/Hierarchical Agent.spec.ts | 74 +----------- .../core/integrations/Memory Chatbot.spec.ts | 63 +---------- .../Sequential Task Agent.spec.ts | 66 +---------- .../core/integrations/Simple Agent.spec.ts | 67 +---------- .../core/integrations/Vector Store.spec.ts | 28 +---- .../core/integrations/decisionFlow.spec.ts | 26 +---- .../core/integrations/similarity.spec.ts | 21 +--- .../integrations/starter-projects.spec.ts | 29 +---- .../core/integrations/textInputOutput.spec.ts | 33 +----- .../regression/generalBugs-prompt.spec.ts | 29 +---- .../regression/generalBugs-shard-4.spec.ts | 27 +---- .../regression/generalBugs-shard-5.spec.ts | 25 +---- .../regression/generalBugs-shard-9.spec.ts | 22 +--- .../tests/core/unit/chatInputOutput.spec.ts | 29 +---- .../core/unit/codeAreaModalComponent.spec.ts | 28 +---- .../tests/core/unit/dropdownComponent.spec.ts | 33 +----- .../core/unit/fileUploadComponent.spec.ts | 43 +------ .../tests/core/unit/floatComponent.spec.ts | 33 +----- .../tests/core/unit/inputComponent.spec.ts | 36 +----- .../core/unit/inputListComponent.spec.ts | 27 +---- .../tests/core/unit/intComponent.spec.ts | 27 +---- .../core/unit/keyPairListComponent.spec.ts | 33 +----- .../tests/core/unit/linkComponent.spec.ts | 32 +----- .../tests/core/unit/nestedComponent.spec.ts | 33 +----- .../core/unit/promptModalComponent.spec.ts | 33 +----- .../tests/core/unit/sliderComponent.spec.ts | 32 +----- .../core/unit/tableInputComponent.spec.ts | 31 +----- .../core/unit/textAreaModalComponent.spec.ts | 29 +---- .../tests/core/unit/toggleComponent.spec.ts | 46 +------- .../features/actionsMainPage-shard-0.spec.ts | 91 +-------------- .../extended/features/auto-save-off.spec.ts | 30 +---- .../features/curlApiGeneration.spec.ts | 19 +--- .../extended/features/dragAndDrop.spec.ts | 41 +------ .../features/filterEdge-shard-1.spec.ts | 34 +----- .../tests/extended/features/flowPage.spec.ts | 28 +---- .../extended/features/flowSettings.spec.ts | 27 +---- .../features/integration-side-bar.spec.ts | 35 +----- .../features/langflowShortcuts.spec.ts | 37 +----- .../features/limit-file-size-upload.spec.ts | 56 +--------- .../tests/extended/features/lock-flow.spec.ts | 28 +---- .../tests/extended/features/minimize.spec.ts | 34 +----- .../features/outdated-actions.spec.ts | 20 +--- .../features/outdated-message.spec.ts | 18 +-- .../features/pythonApiGeneration.spec.ts | 26 +---- .../features/starter-projects.spec.ts | 20 +--- .../extended/features/sticky-notes.spec.ts | 32 +----- .../features/stop-button-playground.spec.ts | 38 +------ .../extended/features/store-shard-1.spec.ts | 19 +--- .../tests/extended/features/twoEdges.spec.ts | 28 +---- .../extended/features/userSettings.spec.ts | 16 ++- .../chatInputOutputUser-shard-1.spec.ts | 53 +-------- .../chatInputOutputUser-shard-2.spec.ts | 57 +--------- .../extended/integrations/duckduckgo.spec.ts | 28 +---- .../integrations/youtube-transcripts.spec.ts | 28 +---- ...al-bugs-component-as-tool-shortcut.spec.ts | 20 +--- .../general-bugs-shard-3836.spec.ts | 56 +--------- .../general-bugs-shard-3909.spec.ts | 21 +--- .../regression/generalBugs-shard-1.spec.ts | 63 +---------- .../regression/generalBugs-shard-10.spec.ts | 21 +--- .../regression/generalBugs-shard-11.spec.ts | 51 +-------- .../regression/generalBugs-shard-12.spec.ts | 26 +---- .../regression/generalBugs-shard-13.spec.ts | 21 +--- .../regression/generalBugs-shard-2.spec.ts | 38 +------ .../regression/generalBugs-shard-3.spec.ts | 105 ++---------------- .../regression/generalBugs-shard-6.spec.ts | 22 +--- .../regression/generalBugs-shard-7.spec.ts | 26 +---- .../regression/generalBugs-shard-8.spec.ts | 33 +----- .../tests/utils/adjust-screen-view.ts | 16 ++- .../tests/utils/await-bootstrap-test.ts | 11 +- 94 files changed, 344 insertions(+), 3058 deletions(-) diff --git a/src/frontend/src/components/core/appHeaderComponent/components/FlowMenu/index.tsx b/src/frontend/src/components/core/appHeaderComponent/components/FlowMenu/index.tsx index cc9430959..cb1d01920 100644 --- a/src/frontend/src/components/core/appHeaderComponent/components/FlowMenu/index.tsx +++ b/src/frontend/src/components/core/appHeaderComponent/components/FlowMenu/index.tsx @@ -336,7 +336,7 @@ export const MenuBar = ({}: {}): JSX.Element => { @@ -134,7 +138,9 @@ const Footer: React.FC<{ )} {close && ( - + )} diff --git a/src/frontend/src/modals/secretKeyModal/index.tsx b/src/frontend/src/modals/secretKeyModal/index.tsx index 12b4a1097..6603cf8fc 100644 --- a/src/frontend/src/modals/secretKeyModal/index.tsx +++ b/src/frontend/src/modals/secretKeyModal/index.tsx @@ -112,6 +112,7 @@ export default function SecretKeyModal({ onClick={() => { handleCopyClick(); }} + data-testid="btn-copy-api-key" unstyled > {textCopied ? ( diff --git a/src/frontend/tests/core/features/actionsMainPage-shard-1.spec.ts b/src/frontend/tests/core/features/actionsMainPage-shard-1.spec.ts index ca6b1a4dc..42203f050 100644 --- a/src/frontend/tests/core/features/actionsMainPage-shard-1.spec.ts +++ b/src/frontend/tests/core/features/actionsMainPage-shard-1.spec.ts @@ -1,35 +1,12 @@ import { test } from "@playwright/test"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "select and delete a flow", { tag: ["@release", "@api"] }, async ({ page }) => { - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); + await awaitBootstrapTest(page); - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } await page.getByTestId("side_nav_options_all-templates").click(); await page.getByRole("heading", { name: "Basic Prompting" }).click(); @@ -61,32 +38,8 @@ test( ); test("search flows", { tag: ["@release"] }, async ({ page }) => { - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); + await awaitBootstrapTest(page); - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } await page.getByTestId("side_nav_options_all-templates").click(); await page.getByRole("heading", { name: "Basic Prompting" }).click(); @@ -122,32 +75,8 @@ test("search flows", { tag: ["@release"] }, async ({ page }) => { }); test("search components", { tag: ["@release"] }, async ({ page }) => { - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); + await awaitBootstrapTest(page); - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } await page.getByTestId("side_nav_options_all-templates").click(); await page.getByRole("heading", { name: "Basic Prompting" }).click(); diff --git a/src/frontend/tests/core/features/auto-login-off.spec.ts b/src/frontend/tests/core/features/auto-login-off.spec.ts index 01a568532..b89b41599 100644 --- a/src/frontend/tests/core/features/auto-login-off.spec.ts +++ b/src/frontend/tests/core/features/auto-login-off.spec.ts @@ -1,4 +1,5 @@ import { expect, test } from "@playwright/test"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "when auto_login is false, admin can CRUD user's and should see just your own flows", @@ -115,23 +116,7 @@ test( timeout: 30000, }); - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 30000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page, { skipGoto: true }); await page.getByTestId("side_nav_options_all-templates").click(); await page.getByRole("heading", { name: "Basic Prompting" }).click(); @@ -204,19 +189,7 @@ test( ).isVisible(), ); - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 30000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } - - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - await page.getByText("New Flow", { exact: true }).click(); + await awaitBootstrapTest(page, { skipGoto: true }); await page.getByTestId("side_nav_options_all-templates").click(); await page.getByRole("heading", { name: "Basic Prompting" }).click(); diff --git a/src/frontend/tests/core/features/chatInputOutputUser-shard-0.spec.ts b/src/frontend/tests/core/features/chatInputOutputUser-shard-0.spec.ts index fa18117a1..8ec21307e 100644 --- a/src/frontend/tests/core/features/chatInputOutputUser-shard-0.spec.ts +++ b/src/frontend/tests/core/features/chatInputOutputUser-shard-0.spec.ts @@ -2,6 +2,8 @@ import { test } from "@playwright/test"; import * as dotenv from "dotenv"; import { readFileSync } from "fs"; import path from "path"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; +import { initialGPTsetup } from "../../utils/initialGPTsetup"; test( "user must be able to send an image on chat", @@ -16,25 +18,7 @@ test( dotenv.config({ path: path.resolve(__dirname, "../../.env") }); } - await page.goto("/"); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); await page.getByTestId("side_nav_options_all-templates").click(); await page.getByRole("heading", { name: "Basic Prompting" }).click(); @@ -42,38 +26,7 @@ test( timeout: 100000, }); - await page.getByTestId("fit_view").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - - let outdatedComponents = await page - .getByTestId("icon-AlertTriangle") - .count(); - - while (outdatedComponents > 0) { - await page.getByTestId("icon-AlertTriangle").first().click(); - await page.waitForSelector('[data-testid="icon-AlertTriangle"]', { - timeout: 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(); - filledApiKey = await page.getByTestId("remove-icon-badge").count(); - } - - const apiKeyInput = page.getByTestId("popover-anchor-input-api_key"); - const isApiKeyInputVisible = await apiKeyInput.isVisible(); - - if (isApiKeyInputVisible) { - await apiKeyInput.fill(process.env.OPENAI_API_KEY ?? ""); - } - - await page.getByTestId("dropdown_str_model_name").click(); - await page.getByTestId("gpt-4o-1-option").click(); + await initialGPTsetup(page); await page.waitForSelector("text=Chat Input", { timeout: 30000 }); diff --git a/src/frontend/tests/core/features/componentHoverAdd.spec.ts b/src/frontend/tests/core/features/componentHoverAdd.spec.ts index 74f6d65e4..4d3684cfc 100644 --- a/src/frontend/tests/core/features/componentHoverAdd.spec.ts +++ b/src/frontend/tests/core/features/componentHoverAdd.spec.ts @@ -1,4 +1,5 @@ import { expect, test } from "@playwright/test"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "user can add components by hovering and clicking the plus icon", @@ -6,28 +7,7 @@ test( async ({ page }) => { // Navigate to homepage and handle initial modal - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); // Start with blank flow await page.getByTestId("blank-flow").click(); 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 2282e8bc9..dc13b2fd7 100644 --- a/src/frontend/tests/core/features/filterEdge-shard-0.spec.ts +++ b/src/frontend/tests/core/features/filterEdge-shard-0.spec.ts @@ -1,27 +1,12 @@ import { expect, test } from "@playwright/test"; +import { adjustScreenView } from "../../utils/adjust-screen-view"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "user must see on handle hover a tooltip with possibility connections", { tag: ["@release", "@components", "@api"] }, async ({ page }) => { - await page.goto("/"); - await page.waitForTimeout(1000); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForTimeout(3000); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); await page.getByTestId("blank-flow").click(); await page.getByTestId("sidebar-search-input").click(); @@ -41,10 +26,7 @@ test( .dragTo(page.locator('//*[@id="react-flow-id"]')); await page.mouse.up(); await page.mouse.down(); - await page.getByTestId("fit_view").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); + await adjustScreenView(page); const outputElements = await page .getByTestId("handle-retrievalqa-shownode-text-right") @@ -76,10 +58,7 @@ test( ).toBeVisible(); }); - await page.getByTestId("fit_view").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); + await adjustScreenView(page); const rqaChainInputElements1 = await page .getByTestId("handle-retrievalqa-shownode-language model-left") @@ -109,10 +88,7 @@ test( page.getByTestId("input-tooltip-languagemodel").first(), ).toBeVisible(); }); - await page.getByTestId("fit_view").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); + await adjustScreenView(page); const rqaChainInputElements0 = await page .getByTestId("handle-retrievalqa-shownode-retriever-left") @@ -143,10 +119,7 @@ test( ).toBeVisible(); }); - await page.getByTestId("fit_view").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); + await adjustScreenView(page); const rqaChainInputElements2 = await page .getByTestId("handle-retrievalqa-shownode-memory-left") diff --git a/src/frontend/tests/core/features/filterSidebar.spec.ts b/src/frontend/tests/core/features/filterSidebar.spec.ts index 868491096..2fd1437a5 100644 --- a/src/frontend/tests/core/features/filterSidebar.spec.ts +++ b/src/frontend/tests/core/features/filterSidebar.spec.ts @@ -1,36 +1,14 @@ import { expect, test } from "@playwright/test"; +import { adjustScreenView } from "../../utils/adjust-screen-view"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "user must see on handle click the possibility connections", { tag: ["@release", "@components", "@api"] }, async ({ page }) => { - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); + await awaitBootstrapTest(page); - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } await page.waitForSelector('[data-testid="blank-flow"]', { timeout: 3000, }); @@ -51,10 +29,8 @@ test( .dragTo(page.locator('//*[@id="react-flow-id"]')); await page.mouse.up(); await page.mouse.down(); - await page.getByTestId("fit_view").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); + await adjustScreenView(page); + await page.waitForSelector( '[data-testid="handle-apirequest-shownode-urls-left"]', { diff --git a/src/frontend/tests/core/features/folders.spec.ts b/src/frontend/tests/core/features/folders.spec.ts index 251f60d6d..26d8f8f9b 100644 --- a/src/frontend/tests/core/features/folders.spec.ts +++ b/src/frontend/tests/core/features/folders.spec.ts @@ -1,37 +1,14 @@ import { expect, test } from "@playwright/test"; import { readFileSync } from "fs"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "CRUD folders", { tag: ["@release", "@api"] }, async ({ page }) => { - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); + await awaitBootstrapTest(page); - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } await page.getByTestId("side_nav_options_all-templates").click(); await page.getByRole("heading", { name: "Basic Prompting" }).click(); @@ -147,32 +124,8 @@ test("add a flow into a folder by drag and drop", async ({ page }) => { }); test("change flow folder", async ({ page }) => { - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); + await awaitBootstrapTest(page); - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } await page.getByTestId("side_nav_options_all-templates").click(); await page.getByRole("heading", { name: "Basic Prompting" }).click(); diff --git a/src/frontend/tests/core/features/freeze-path.spec.ts b/src/frontend/tests/core/features/freeze-path.spec.ts index 35144b7b5..85ddd54ed 100644 --- a/src/frontend/tests/core/features/freeze-path.spec.ts +++ b/src/frontend/tests/core/features/freeze-path.spec.ts @@ -1,6 +1,8 @@ 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"; test( "user must be able to freeze a path", @@ -16,68 +18,12 @@ test( dotenv.config({ path: path.resolve(__dirname, "../../.env") }); } - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); - - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); await page.getByTestId("side_nav_options_all-templates").click(); await page.getByRole("heading", { name: "Basic Prompting" }).click(); - await page.waitForSelector('[data-testid="fit_view"]', { - timeout: 100000, - }); - - await page.getByTestId("fit_view").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - - let outdatedComponents = await page - .getByTestId("icon-AlertTriangle") - .count(); - - while (outdatedComponents > 0) { - await page.getByTestId("icon-AlertTriangle").first().click(); - await page.waitForTimeout(1000); - outdatedComponents = await page.getByTestId("icon-AlertTriangle").count(); - } - - //remove all saved api keys - let filledApiKey = await page.getByTestId("remove-icon-badge").count(); - while (filledApiKey > 0) { - await page.getByTestId("remove-icon-badge").first().click(); - filledApiKey = await page.getByTestId("remove-icon-badge").count(); - } - - const apiKeyInput = page.getByTestId("popover-anchor-input-api_key"); - const isApiKeyInputVisible = await apiKeyInput.isVisible(); - - if (isApiKeyInputVisible) { - await apiKeyInput.fill(process.env.OPENAI_API_KEY ?? ""); - } + await initialGPTsetup(page); await page .getByTestId("textarea_str_input_value") diff --git a/src/frontend/tests/core/features/freeze.spec.ts b/src/frontend/tests/core/features/freeze.spec.ts index 9b0542f09..7c7f04f1c 100644 --- a/src/frontend/tests/core/features/freeze.spec.ts +++ b/src/frontend/tests/core/features/freeze.spec.ts @@ -1,36 +1,12 @@ import { expect, test } from "@playwright/test"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "user must be able to freeze a component", { tag: ["@release", "@workspace", "@components"] }, async ({ page }) => { - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); - - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); await page.getByTestId("blank-flow").click(); @@ -250,8 +226,7 @@ test( .getByPlaceholder("Empty") .textContent(); - await page.getByText("Close").last().click(); - await page.getByText("Close").last().click(); + await page.getByTestId("btn-close-modal").click(); await page.getByTestId("textarea_str_input_value").first().fill(","); diff --git a/src/frontend/tests/core/features/globalVariables.spec.ts b/src/frontend/tests/core/features/globalVariables.spec.ts index fa360c757..16439e0dd 100644 --- a/src/frontend/tests/core/features/globalVariables.spec.ts +++ b/src/frontend/tests/core/features/globalVariables.spec.ts @@ -1,35 +1,13 @@ import { expect, test } from "@playwright/test"; +import { adjustScreenView } from "../../utils/adjust-screen-view"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "user must be able to save or delete a global variable", { tag: ["@release", "@workspace", "@api"] }, async ({ page }) => { - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); + await awaitBootstrapTest(page); - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } await page.waitForSelector('[data-testid="blank-flow"]', { timeout: 30000, }); @@ -47,14 +25,7 @@ test( await page.mouse.up(); await page.mouse.down(); - await page.waitForSelector('[data-testid="fit_view"]', { - timeout: 100000, - }); - - await page.getByTestId("fit_view").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); + await adjustScreenView(page); const genericName = Math.random().toString(); const credentialName = Math.random().toString(); diff --git a/src/frontend/tests/core/features/group.spec.ts b/src/frontend/tests/core/features/group.spec.ts index 2f4e6fa26..a2d168bea 100644 --- a/src/frontend/tests/core/features/group.spec.ts +++ b/src/frontend/tests/core/features/group.spec.ts @@ -1,4 +1,5 @@ import { test } from "@playwright/test"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test.describe("group node test", () => { /// @@ -6,22 +7,7 @@ test.describe("group node test", () => { "group and ungroup updating values", { tag: ["@release", "@workspace"] }, async ({ page }) => { - await page.goto("/"); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); await page.getByTestId("side_nav_options_all-templates").click(); await page diff --git a/src/frontend/tests/core/features/keyboardComponentSearch.spec.ts b/src/frontend/tests/core/features/keyboardComponentSearch.spec.ts index 2b0f9f68f..13b324cc6 100644 --- a/src/frontend/tests/core/features/keyboardComponentSearch.spec.ts +++ b/src/frontend/tests/core/features/keyboardComponentSearch.spec.ts @@ -1,32 +1,12 @@ import { expect, test } from "@playwright/test"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "user can search and add components using keyboard shortcuts", { tag: ["@release", "@workspace"] }, async ({ page }) => { // Navigate to homepage and handle initial modal - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); // Start with blank flow await page.getByTestId("blank-flow").click(); diff --git a/src/frontend/tests/core/features/logs.spec.ts b/src/frontend/tests/core/features/logs.spec.ts index befbd7871..a0a188365 100644 --- a/src/frontend/tests/core/features/logs.spec.ts +++ b/src/frontend/tests/core/features/logs.spec.ts @@ -1,6 +1,7 @@ import { expect, test } from "@playwright/test"; import * as dotenv from "dotenv"; import path from "path"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "should able to see and interact with logs", @@ -16,32 +17,7 @@ test( dotenv.config({ path: path.resolve(__dirname, "../../.env") }); } - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); - - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); await page.getByTestId("side_nav_options_all-templates").click(); await page.getByRole("heading", { name: "Basic Prompting" }).click(); diff --git a/src/frontend/tests/core/features/playground.spec.ts b/src/frontend/tests/core/features/playground.spec.ts index ad37d0861..db7eb6c27 100644 --- a/src/frontend/tests/core/features/playground.spec.ts +++ b/src/frontend/tests/core/features/playground.spec.ts @@ -1,6 +1,8 @@ import { expect, test } from "@playwright/test"; import * as dotenv from "dotenv"; import path from "path"; +import { adjustScreenView } from "../../utils/adjust-screen-view"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "fresh start playground", @@ -10,31 +12,7 @@ test( dotenv.config({ path: path.resolve(__dirname, "../../.env") }); } - await page.goto("/"); - await page.locator("span").filter({ hasText: "My Collection" }).isVisible(); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); - - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForTimeout(3000); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); await page.waitForSelector('[data-testid="blank-flow"]', { timeout: 30000, @@ -52,10 +30,8 @@ test( await page.mouse.up(); await page.mouse.down(); - await page.getByTestId("fit_view").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); + await adjustScreenView(page); + await page.getByTestId("zoom_out").click(); await page.getByTestId("zoom_out").click(); await page.getByTestId("zoom_out").click(); @@ -85,10 +61,8 @@ test( await page.mouse.up(); await page.mouse.down(); - await page.getByTestId("fit_view").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); + await adjustScreenView(page); + await page.getByTestId("zoom_out").click(); await page.getByTestId("zoom_out").click(); await page.getByTestId("zoom_out").click(); diff --git a/src/frontend/tests/core/features/saveComponents.spec.ts b/src/frontend/tests/core/features/saveComponents.spec.ts index 3f32f7c6f..d62834279 100644 --- a/src/frontend/tests/core/features/saveComponents.spec.ts +++ b/src/frontend/tests/core/features/saveComponents.spec.ts @@ -1,5 +1,6 @@ import { expect, test } from "@playwright/test"; import { readFileSync } from "fs"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test.describe("save component tests", () => { /// @@ -8,24 +9,8 @@ test.describe("save component tests", () => { { tag: ["@release", "@workspace", "@api"] }, async ({ page }) => { - await page.goto("/"); - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } + await awaitBootstrapTest(page); - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } await page.waitForSelector('[data-testid="blank-flow"]', { timeout: 30000, }); diff --git a/src/frontend/tests/core/features/stop-building.spec.ts b/src/frontend/tests/core/features/stop-building.spec.ts index 2340db761..a5f125472 100644 --- a/src/frontend/tests/core/features/stop-building.spec.ts +++ b/src/frontend/tests/core/features/stop-building.spec.ts @@ -1,41 +1,18 @@ import { test } from "@playwright/test"; -import uaParser from "ua-parser-js"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; // TODO: fix this test test( "user must be able to stop a building", { tag: ["@release", "@workspace", "@api"] }, async ({ page }) => { - test.skip(true, "Test is flaky"); - await page.goto("/"); - // await page.waitForTimeout(2000); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForTimeout(3000); - modalCount = await page.getByTestId("modal-title")?.count(); - } - - const getUA = await page.evaluate(() => navigator.userAgent); - const userAgentInfo = uaParser(getUA); - + await awaitBootstrapTest(page); await page.getByTestId("blank-flow").click(); //first component await page.getByTestId("sidebar-search-input").click(); await page.getByTestId("sidebar-search-input").fill("text input"); - // await page.waitForTimeout(1000); await page .getByTestId("inputsText Input") @@ -56,7 +33,6 @@ test( await page.getByTestId("sidebar-search-input").click(); await page.getByTestId("sidebar-search-input").fill("url"); - // await page.waitForTimeout(1000); await page .getByTestId("dataURL") @@ -77,7 +53,6 @@ test( await page.getByTestId("sidebar-search-input").click(); await page.getByTestId("sidebar-search-input").fill("split text"); - // await page.waitForTimeout(1000); await page .getByTestId("processingSplit Text") @@ -98,7 +73,6 @@ test( await page.getByTestId("sidebar-search-input").click(); await page.getByTestId("sidebar-search-input").fill("parse data"); - // await page.waitForTimeout(1000); await page .getByTestId("processingParse Data") @@ -119,7 +93,6 @@ test( await page.getByTestId("sidebar-search-input").click(); await page.getByTestId("sidebar-search-input").fill("chat output"); - // await page.waitForTimeout(1000); await page .getByTestId("outputsChat Output") @@ -142,7 +115,6 @@ test( while (outdatedComponents > 0) { await page.getByTestId("icon-AlertTriangle").first().click(); - // await page.waitForTimeout(1000); outdatedComponents = await page.getByTestId("icon-AlertTriangle").count(); } @@ -251,9 +223,15 @@ class CustomComponent(Component): await page.getByTestId("title-Custom Component").first().click(); - await page.waitForTimeout(500); + await page.waitForSelector('[data-testid="code-button-modal"]', { + timeout: 3000, + }); + await page.getByTestId("code-button-modal").click(); - await page.waitForTimeout(500); + + await page.waitForSelector('[id="checkAndSaveBtn"]', { + timeout: 3000, + }); await page.locator("textarea").last().press(`ControlOrMeta+a`); await page.keyboard.press("Backspace"); @@ -263,53 +241,17 @@ class CustomComponent(Component): await page.getByTestId("button_run_custom component").click(); - await page.waitForSelector("text=Building", { + await page.waitForSelector("text=running", { timeout: 100000, }); - await page.waitForSelector('div[class*="animate-border-beam"]', { - state: "visible", - timeout: 5000, - }); - - await page.waitForTimeout(1000); - - await page.waitForSelector('div[class*="animate-border-beam"]', { - state: "hidden", - timeout: 5000, - }); - - await page.waitForSelector("text=Saved", { + await page.waitForSelector('[data-testid="stop_building_button"]', { timeout: 100000, }); - await page.getByTestId("button_run_custom component").click(); + await page.getByTestId("stop_building_button").last().click(); - await page.waitForSelector("text=Building", { - timeout: 100000, - }); - - await page.waitForSelector('div[class*="animate-border-beam"]', { - state: "visible", - timeout: 5000, - }); - - await page.waitForSelector("text=Building", { - timeout: 100000, - }); - - await page.waitForSelector("text=Saved", { - timeout: 100000, - }); - - await page.getByTestId("button_run_custom component").click(); - - await page.waitForSelector('div[class*="animate-border-beam"]', { - state: "visible", - timeout: 5000, - }); - - await page.waitForSelector("text=Saved", { + await page.waitForSelector("text=build stopped", { timeout: 100000, }); }, diff --git a/src/frontend/tests/core/features/store-shard-2.spec.ts b/src/frontend/tests/core/features/store-shard-2.spec.ts index f7398dd59..e3dc90719 100644 --- a/src/frontend/tests/core/features/store-shard-2.spec.ts +++ b/src/frontend/tests/core/features/store-shard-2.spec.ts @@ -1,6 +1,7 @@ import { test } from "@playwright/test"; import * as dotenv from "dotenv"; import path from "path"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "should filter by tag", @@ -99,21 +100,10 @@ test("should share component with share button", async ({ page }) => { await page.getByTestId("icon-ChevronLeft").first().click(); - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } + await awaitBootstrapTest(page, { + skipGoto: true, + }); - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForTimeout(3000); - modalCount = await page.getByTestId("modal-title")?.count(); - } await page.waitForTimeout(1000); const randomName = Math.random().toString(36).substring(2); diff --git a/src/frontend/tests/core/features/tweaksTest.spec.ts b/src/frontend/tests/core/features/tweaksTest.spec.ts index 3278101b2..9c6ab9188 100644 --- a/src/frontend/tests/core/features/tweaksTest.spec.ts +++ b/src/frontend/tests/core/features/tweaksTest.spec.ts @@ -1,28 +1,12 @@ import { expect, test } from "@playwright/test"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "curl_api_generation", { tag: ["@release", "@workspace", "@api"] }, async ({ page, context }) => { - await page.goto("/"); - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); await page.getByTestId("side_nav_options_all-templates").click(); await page.getByRole("heading", { name: "Basic Prompting" }).click(); @@ -69,32 +53,7 @@ test( test("check if tweaks are updating when someothing on the flow changes", async ({ page, }) => { - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); - - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); await page.waitForSelector('[data-testid="blank-flow"]', { timeout: 30000, diff --git a/src/frontend/tests/core/integrations/Basic Prompting.spec.ts b/src/frontend/tests/core/integrations/Basic Prompting.spec.ts index 758743677..d50fdee46 100644 --- a/src/frontend/tests/core/integrations/Basic Prompting.spec.ts +++ b/src/frontend/tests/core/integrations/Basic Prompting.spec.ts @@ -1,6 +1,8 @@ import { 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"; test( "Basic Prompting (Hello, World)", @@ -15,69 +17,12 @@ test( dotenv.config({ path: path.resolve(__dirname, "../../.env") }); } - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); - - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); await page.getByTestId("side_nav_options_all-templates").click(); await page.getByRole("heading", { name: "Basic Prompting" }).click(); - await page.waitForSelector('[data-testid="fit_view"]', { - timeout: 100000, - }); - - await page.getByTestId("fit_view").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - - let outdatedComponents = await page - .getByTestId("icon-AlertTriangle") - .count(); - - while (outdatedComponents > 0) { - await page.getByTestId("icon-AlertTriangle").first().click(); - 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(); - filledApiKey = await page.getByTestId("remove-icon-badge").count(); - } - - const apiKeyInput = page.getByTestId("popover-anchor-input-api_key"); - const isApiKeyInputVisible = await apiKeyInput.isVisible(); - - if (isApiKeyInputVisible) { - await apiKeyInput.fill(process.env.OPENAI_API_KEY ?? ""); - } - - await page.getByTestId("dropdown_str_model_name").click(); - await page.getByTestId("gpt-4o-1-option").click(); + await initialGPTsetup(page); await page.getByTestId("button_run_chat output").click(); await page.waitForSelector("text=built successfully", { timeout: 30000 }); diff --git a/src/frontend/tests/core/integrations/Blog Writer.spec.ts b/src/frontend/tests/core/integrations/Blog Writer.spec.ts index 5298fdea2..d9b14040d 100644 --- a/src/frontend/tests/core/integrations/Blog Writer.spec.ts +++ b/src/frontend/tests/core/integrations/Blog Writer.spec.ts @@ -1,6 +1,8 @@ import { 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"; test( "Blog Writer", @@ -15,68 +17,12 @@ test( dotenv.config({ path: path.resolve(__dirname, "../../.env") }); } - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); - - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); await page.getByTestId("side_nav_options_all-templates").click(); await page.getByRole("heading", { name: "Blog Writer" }).click(); - await page.waitForSelector('[data-testid="fit_view"]', { - timeout: 5000, - }); - await page.getByTestId("fit_view").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - - let outdatedComponents = await page - .getByTestId("icon-AlertTriangle") - .count(); - - while (outdatedComponents > 0) { - await page.getByTestId("icon-AlertTriangle").first().click(); - 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(); - filledApiKey = await page.getByTestId("remove-icon-badge").count(); - } - - const apiKeyInput = page.getByTestId("popover-anchor-input-api_key"); - const isApiKeyInputVisible = await apiKeyInput.isVisible(); - - if (isApiKeyInputVisible) { - await apiKeyInput.fill(process.env.OPENAI_API_KEY ?? ""); - } - - await page.getByTestId("dropdown_str_model_name").click(); - await page.getByTestId("gpt-4o-1-option").click(); + await initialGPTsetup(page); await page .getByTestId("inputlist_str_urls_0") diff --git a/src/frontend/tests/core/integrations/Document QA.spec.ts b/src/frontend/tests/core/integrations/Document QA.spec.ts index 3b3082393..2fa3bbf8a 100644 --- a/src/frontend/tests/core/integrations/Document QA.spec.ts +++ b/src/frontend/tests/core/integrations/Document QA.spec.ts @@ -1,6 +1,8 @@ import { 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"; test( "Document Q&A", @@ -15,68 +17,11 @@ test( dotenv.config({ path: path.resolve(__dirname, "../../.env") }); } - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); - - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); await page.getByTestId("side_nav_options_all-templates").click(); await page.getByRole("heading", { name: "Document Q&A" }).click(); - await page.waitForSelector('[data-testid="fit_view"]', { - timeout: 3000, - }); - - await page.getByTestId("fit_view").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - - let outdatedComponents = await page - .getByTestId("icon-AlertTriangle") - .count(); - - while (outdatedComponents > 0) { - await page.getByTestId("icon-AlertTriangle").first().click(); - 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(); - filledApiKey = await page.getByTestId("remove-icon-badge").count(); - } - - const apiKeyInput = page.getByTestId("popover-anchor-input-api_key"); - const isApiKeyInputVisible = await apiKeyInput.isVisible(); - - if (isApiKeyInputVisible) { - await apiKeyInput.fill(process.env.OPENAI_API_KEY ?? ""); - } - - await page.getByTestId("dropdown_str_model_name").click(); - await page.getByTestId("gpt-4o-1-option").click(); + await initialGPTsetup(page); const fileChooserPromise = page.waitForEvent("filechooser"); await page.getByTestId("button_upload_file").click(); diff --git a/src/frontend/tests/core/integrations/Dynamic Agent.spec.ts b/src/frontend/tests/core/integrations/Dynamic Agent.spec.ts index 93a2bc527..6d54a0082 100644 --- a/src/frontend/tests/core/integrations/Dynamic Agent.spec.ts +++ b/src/frontend/tests/core/integrations/Dynamic Agent.spec.ts @@ -1,6 +1,8 @@ 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"; test.skip( "Dynamic Agent", @@ -17,69 +19,17 @@ test.skip( if (!process.env.CI) { dotenv.config({ path: path.resolve(__dirname, "../../.env") }); } - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForTimeout(3000); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); + await page.getByTestId("side_nav_options_all-templates").click(); await page.getByRole("heading", { name: "Dynamic Agent" }).last().click(); - await page.waitForSelector('[data-testid="fit_view"]', { - timeout: 100000, - }); - await page.getByTestId("fit_view").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - let outdatedComponents = await page - .getByTestId("icon-AlertTriangle") - .count(); - 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(); - } + await initialGPTsetup(page); + await page .getByTestId("popover-anchor-input-api_key") .last() .fill(process.env.SEARCH_API_KEY ?? ""); - await page.waitForTimeout(1000); - let openAiLlms = await page.getByText("OpenAI", { exact: true }).count(); - await page.waitForSelector('[data-testid="fit_view"]', { - timeout: 100000, - }); - for (let i = 0; i < openAiLlms; i++) { - await page - .getByTestId("popover-anchor-input-api_key") - .nth(i) - .fill(process.env.OPENAI_API_KEY ?? ""); - await page.getByTestId("zoom_in").click(); - await page.getByTestId("dropdown_str_model_name").nth(i).click(); - await page.getByTestId("gpt-4o-1-option").last().click(); - await page.waitForTimeout(1000); - } + await page .getByTestId("textarea_str_input_value") .first() diff --git a/src/frontend/tests/core/integrations/Hierarchical Agent.spec.ts b/src/frontend/tests/core/integrations/Hierarchical Agent.spec.ts index d14dc0bac..ba5ff76ee 100644 --- a/src/frontend/tests/core/integrations/Hierarchical Agent.spec.ts +++ b/src/frontend/tests/core/integrations/Hierarchical Agent.spec.ts @@ -1,7 +1,8 @@ import { expect, test } from "@playwright/test"; import * as dotenv from "dotenv"; import path from "path"; -import uaParser from "ua-parser-js"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; +import { initialGPTsetup } from "../../utils/initialGPTsetup"; test.skip( "Hierarchical Tasks Agent", @@ -21,81 +22,14 @@ test.skip( dotenv.config({ path: path.resolve(__dirname, "../../.env") }); } - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); - - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForTimeout(3000); - modalCount = await page.getByTestId("modal-title")?.count(); - } - - const getUA = await page.evaluate(() => navigator.userAgent); - const userAgentInfo = uaParser(getUA); + await awaitBootstrapTest(page); await page.getByTestId("side_nav_options_all-templates").click(); await page .getByRole("heading", { name: "Hierarchical Tasks Agent" }) .first() .click(); - - await page.waitForSelector('[data-testid="fit_view"]', { - timeout: 100000, - }); - - await page.getByTestId("fit_view").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - - let outdatedComponents = await page - .getByTestId("icon-AlertTriangle") - .count(); - - 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(); - } - - await page - .getByTestId("popover-anchor-input-api_key") - .nth(1) - .fill(process.env.OPENAI_API_KEY ?? ""); - - await page - .getByTestId("popover-anchor-input-api_key") - .nth(0) - .fill(process.env.OPENAI_API_KEY ?? ""); - - await page.getByTestId("dropdown_str_model_name").nth(1).click(); - await page.getByTestId("gpt-4o-1-option").last().click(); - - await page.getByTestId("dropdown_str_model_name").nth(0).click(); - await page.getByTestId("gpt-4o-1-option").first().click(); + await initialGPTsetup(page); await page .getByTestId("popover-anchor-input-api_key") diff --git a/src/frontend/tests/core/integrations/Memory Chatbot.spec.ts b/src/frontend/tests/core/integrations/Memory Chatbot.spec.ts index 0dab727ff..db0603ed3 100644 --- a/src/frontend/tests/core/integrations/Memory Chatbot.spec.ts +++ b/src/frontend/tests/core/integrations/Memory Chatbot.spec.ts @@ -1,6 +1,8 @@ import { 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"; test( "Memory Chatbot", @@ -15,68 +17,11 @@ test( dotenv.config({ path: path.resolve(__dirname, "../../.env") }); } - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); - - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); await page.getByTestId("side_nav_options_all-templates").click(); await page.getByRole("heading", { name: "Memory Chatbot" }).click(); - await page.waitForSelector('[data-testid="fit_view"]', { - timeout: 5000, - }); - - await page.getByTestId("fit_view").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - - let outdatedComponents = await page - .getByTestId("icon-AlertTriangle") - .count(); - - while (outdatedComponents > 0) { - await page.getByTestId("icon-AlertTriangle").first().click(); - 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(); - filledApiKey = await page.getByTestId("remove-icon-badge").count(); - } - - const apiKeyInput = page.getByTestId("popover-anchor-input-api_key"); - const isApiKeyInputVisible = await apiKeyInput.isVisible(); - - if (isApiKeyInputVisible) { - await apiKeyInput.fill(process.env.OPENAI_API_KEY ?? ""); - } - - await page.getByTestId("dropdown_str_model_name").click(); - await page.getByTestId("gpt-4o-1-option").click(); + await initialGPTsetup(page); await page.getByTestId("button_run_chat output").click(); await page.waitForSelector("text=built successfully", { timeout: 30000 }); diff --git a/src/frontend/tests/core/integrations/Sequential Task Agent.spec.ts b/src/frontend/tests/core/integrations/Sequential Task Agent.spec.ts index ea7edba43..a1d6fd0d3 100644 --- a/src/frontend/tests/core/integrations/Sequential Task Agent.spec.ts +++ b/src/frontend/tests/core/integrations/Sequential Task Agent.spec.ts @@ -1,7 +1,8 @@ import { expect, test } from "@playwright/test"; import * as dotenv from "dotenv"; import path from "path"; -import uaParser from "ua-parser-js"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; +import { initialGPTsetup } from "../../utils/initialGPTsetup"; test.skip( "Sequential Task Agent", @@ -16,33 +17,7 @@ test.skip( dotenv.config({ path: path.resolve(__dirname, "../../.env") }); } - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); - - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForTimeout(3000); - modalCount = await page.getByTestId("modal-title")?.count(); - } - - const getUA = await page.evaluate(() => navigator.userAgent); - const userAgentInfo = uaParser(getUA); + await awaitBootstrapTest(page); await page.getByTestId("side_nav_options_all-templates").click(); await page @@ -50,40 +25,7 @@ test.skip( .first() .click(); - await page.waitForSelector('[data-testid="fit_view"]', { - timeout: 100000, - }); - - await page.getByTestId("fit_view").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - - let outdatedComponents = await page - .getByTestId("icon-AlertTriangle") - .count(); - - 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(); - } - - await page - .getByTestId("popover-anchor-input-api_key") - .fill(process.env.OPENAI_API_KEY ?? ""); - - await page.getByTestId("dropdown_str_model_name").click(); - await page.getByTestId("gpt-4o-1-option").click(); - - await page.waitForTimeout(1000); + await initialGPTsetup(page); await page.getByTestId("button_run_chat output").click(); diff --git a/src/frontend/tests/core/integrations/Simple Agent.spec.ts b/src/frontend/tests/core/integrations/Simple Agent.spec.ts index bbaebd1a8..e20e0444b 100644 --- a/src/frontend/tests/core/integrations/Simple Agent.spec.ts +++ b/src/frontend/tests/core/integrations/Simple Agent.spec.ts @@ -1,7 +1,8 @@ import { expect, test } from "@playwright/test"; import * as dotenv from "dotenv"; import path from "path"; -import uaParser from "ua-parser-js"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; +import { initialGPTsetup } from "../../utils/initialGPTsetup"; test( "Simple Agent", @@ -17,71 +18,11 @@ test( dotenv.config({ path: path.resolve(__dirname, "../../.env") }); } - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); - - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } - - const getUA = await page.evaluate(() => navigator.userAgent); - const userAgentInfo = uaParser(getUA); + await awaitBootstrapTest(page); await page.getByTestId("side_nav_options_all-templates").click(); await page.getByRole("heading", { name: "Simple Agent" }).first().click(); - - await page.waitForSelector('[data-testid="fit_view"]', { - timeout: 100000, - }); - - await page.getByTestId("fit_view").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - - let outdatedComponents = await page - .getByTestId("icon-AlertTriangle") - .count(); - - while (outdatedComponents > 0) { - await page.getByTestId("icon-AlertTriangle").first().click(); - 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(); - filledApiKey = await page.getByTestId("remove-icon-badge").count(); - } - - await page - .getByTestId("popover-anchor-input-api_key") - .fill(process.env.OPENAI_API_KEY ?? ""); - - await page.getByTestId("fit_view").click(); - - await page.getByTestId("dropdown_str_model_name").click(); - await page.getByTestId("gpt-4o-1-option").click(); + await initialGPTsetup(page); await page.getByTestId("button_run_chat output").last().click(); diff --git a/src/frontend/tests/core/integrations/Vector Store.spec.ts b/src/frontend/tests/core/integrations/Vector Store.spec.ts index 8750f1a13..c1e0ff7dd 100644 --- a/src/frontend/tests/core/integrations/Vector Store.spec.ts +++ b/src/frontend/tests/core/integrations/Vector Store.spec.ts @@ -1,6 +1,6 @@ import { Page, test } from "@playwright/test"; import path from "path"; -import uaParser from "ua-parser-js"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; import { extractAndCleanCode } from "../../utils/extract-and-clean-code"; test( @@ -19,29 +19,8 @@ test( !process?.env?.ASTRA_DB_APPLICATION_TOKEN, "ASTRA_DB_APPLICATION_TOKEN required to run this test", ); - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); + await page.getByTestId("side_nav_options_all-templates").click(); await page .getByRole("heading", { name: "Vector Store RAG" }) @@ -67,7 +46,6 @@ test( filledApiKey = await page.getByTestId("remove-icon-badge").count(); } if (process?.env?.ASTRA_DB_API_ENDPOINT?.includes("astra-dev")) { - const getUA = await page.evaluate(() => navigator.userAgent); await page.getByTestId("title-Astra DB").first().click(); await page.getByTestId("code-button-modal").click(); await page.waitForSelector("text=Edit Code", { diff --git a/src/frontend/tests/core/integrations/decisionFlow.spec.ts b/src/frontend/tests/core/integrations/decisionFlow.spec.ts index 8a3807d00..52c1be1be 100644 --- a/src/frontend/tests/core/integrations/decisionFlow.spec.ts +++ b/src/frontend/tests/core/integrations/decisionFlow.spec.ts @@ -1,6 +1,7 @@ import { Page, test } from "@playwright/test"; import * as dotenv from "dotenv"; import path from "path"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; async function zoomOut(page: Page, times: number = 4) { for (let i = 0; i < times; i++) { @@ -20,29 +21,8 @@ test( if (!process.env.CI) { dotenv.config({ path: path.resolve(__dirname, "../../.env") }); } - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); + await page.waitForSelector('[data-testid="blank-flow"]', { timeout: 30000, }); diff --git a/src/frontend/tests/core/integrations/similarity.spec.ts b/src/frontend/tests/core/integrations/similarity.spec.ts index c51731d9b..d0693472e 100644 --- a/src/frontend/tests/core/integrations/similarity.spec.ts +++ b/src/frontend/tests/core/integrations/similarity.spec.ts @@ -1,4 +1,5 @@ import { expect, test } from "@playwright/test"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "user must be able to check similarity between embedding texts", @@ -9,25 +10,7 @@ test( "OPENAI_API_KEY required to run this test", ); - await page.goto("/"); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); await page.getByTestId("blank-flow").click(); diff --git a/src/frontend/tests/core/integrations/starter-projects.spec.ts b/src/frontend/tests/core/integrations/starter-projects.spec.ts index c15501d76..f256523d2 100644 --- a/src/frontend/tests/core/integrations/starter-projects.spec.ts +++ b/src/frontend/tests/core/integrations/starter-projects.spec.ts @@ -1,4 +1,5 @@ import { expect, test } from "@playwright/test"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "vector store from starter projects should have its connections and nodes on the flow", @@ -46,33 +47,7 @@ test( } }); - await page.goto("/"); - - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); - - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); await page.getByTestId("side_nav_options_all-templates").click(); await page diff --git a/src/frontend/tests/core/integrations/textInputOutput.spec.ts b/src/frontend/tests/core/integrations/textInputOutput.spec.ts index a2f7616c8..dbee37b12 100644 --- a/src/frontend/tests/core/integrations/textInputOutput.spec.ts +++ b/src/frontend/tests/core/integrations/textInputOutput.spec.ts @@ -1,6 +1,8 @@ import { expect, test } from "@playwright/test"; import * as dotenv from "dotenv"; import path from "path"; +import { adjustScreenView } from "../../utils/adjust-screen-view"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test.skip( "TextInputOutputComponent", @@ -14,27 +16,8 @@ test.skip( if (!process.env.CI) { dotenv.config({ path: path.resolve(__dirname, "../../.env") }); } - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForTimeout(3000); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); + await page.waitForSelector('[data-testid="blank-flow"]', { timeout: 30000, }); @@ -55,13 +38,7 @@ test.skip( .dragTo(page.locator('//*[@id="react-flow-id"]')); await page.mouse.up(); await page.mouse.down(); - await page.waitForSelector('[data-testid="fit_view"]', { - timeout: 100000, - }); - await page.getByTestId("fit_view").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); + await adjustScreenView(page); let visibleElementHandle; const elementsTextInputOutput = await page .getByTestId("handle-textinput-shownode-text-right") diff --git a/src/frontend/tests/core/regression/generalBugs-prompt.spec.ts b/src/frontend/tests/core/regression/generalBugs-prompt.spec.ts index 48e07723b..ae53e0674 100644 --- a/src/frontend/tests/core/regression/generalBugs-prompt.spec.ts +++ b/src/frontend/tests/core/regression/generalBugs-prompt.spec.ts @@ -1,6 +1,7 @@ import { expect, test } from "@playwright/test"; import * as dotenv from "dotenv"; import path from "path"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "user must be able to edit an empty prompt", @@ -14,33 +15,7 @@ test( if (!process.env.CI) { dotenv.config({ path: path.resolve(__dirname, "../../.env") }); } - - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); - - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); await page.getByTestId("side_nav_options_all-templates").click(); await page.getByRole("heading", { name: "Basic Prompting" }).click(); diff --git a/src/frontend/tests/core/regression/generalBugs-shard-4.spec.ts b/src/frontend/tests/core/regression/generalBugs-shard-4.spec.ts index 47e69c978..552cb497c 100644 --- a/src/frontend/tests/core/regression/generalBugs-shard-4.spec.ts +++ b/src/frontend/tests/core/regression/generalBugs-shard-4.spec.ts @@ -1,4 +1,5 @@ import { expect, test } from "@playwright/test"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "should be able to move flow from folder, rename it and be displayed on correct folder", @@ -11,31 +12,7 @@ test( const randomName = Math.random().toString(36).substring(2); const secondRandomName = Math.random().toString(36).substring(2); - await page.goto("/"); - await page.locator("span").filter({ hasText: "My Collection" }).isVisible(); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); - - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForTimeout(3000); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); await page.getByTestId("side_nav_options_all-templates").click(); await page diff --git a/src/frontend/tests/core/regression/generalBugs-shard-5.spec.ts b/src/frontend/tests/core/regression/generalBugs-shard-5.spec.ts index 5d4a540b7..544bad24d 100644 --- a/src/frontend/tests/core/regression/generalBugs-shard-5.spec.ts +++ b/src/frontend/tests/core/regression/generalBugs-shard-5.spec.ts @@ -1,36 +1,15 @@ import { expect, test } from "@playwright/test"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "should be able to see output preview from grouped components and connect components with a single click", { tag: ["@release", "@workspace", "@components"] }, async ({ page }) => { - await page.goto("/"); - - let modalCount = 0; const randomName = Math.random().toString(36).substring(2); const secondRandomName = Math.random().toString(36).substring(2); const thirdRandomName = Math.random().toString(36).substring(2); - try { - const modalTitleElement = page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } - - await page.waitForSelector('[data-testid="blank-flow"]', { - timeout: 30000, - }); + await awaitBootstrapTest(page); await page.getByTestId("blank-flow").click(); diff --git a/src/frontend/tests/core/regression/generalBugs-shard-9.spec.ts b/src/frontend/tests/core/regression/generalBugs-shard-9.spec.ts index c96f241f8..aa363dd14 100644 --- a/src/frontend/tests/core/regression/generalBugs-shard-9.spec.ts +++ b/src/frontend/tests/core/regression/generalBugs-shard-9.spec.ts @@ -1,6 +1,7 @@ import { expect, test } from "@playwright/test"; import * as dotenv from "dotenv"; import path from "path"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "memory should work as expect", @@ -14,26 +15,7 @@ test( if (!process.env.CI) { dotenv.config({ path: path.resolve(__dirname, "../../.env") }); } - - await page.goto("/"); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); await page.getByTestId("side_nav_options_all-templates").click(); await page.getByRole("heading", { name: "Basic Prompting" }).click(); diff --git a/src/frontend/tests/core/unit/chatInputOutput.spec.ts b/src/frontend/tests/core/unit/chatInputOutput.spec.ts index e40a00283..bc63ee776 100644 --- a/src/frontend/tests/core/unit/chatInputOutput.spec.ts +++ b/src/frontend/tests/core/unit/chatInputOutput.spec.ts @@ -1,33 +1,8 @@ import { expect, test } from "@playwright/test"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test("chat_io_teste", { tag: ["@release", "@workspace"] }, async ({ page }) => { - await page.goto("/"); - await page.locator("span").filter({ hasText: "My Collection" }).isVisible(); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); - - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); await page.waitForSelector('[data-testid="blank-flow"]', { timeout: 30000, diff --git a/src/frontend/tests/core/unit/codeAreaModalComponent.spec.ts b/src/frontend/tests/core/unit/codeAreaModalComponent.spec.ts index 398aecd3b..e0a0d5ebe 100644 --- a/src/frontend/tests/core/unit/codeAreaModalComponent.spec.ts +++ b/src/frontend/tests/core/unit/codeAreaModalComponent.spec.ts @@ -1,35 +1,11 @@ import { test } from "@playwright/test"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "CodeAreaModalComponent", { tag: ["@release", "@workspace"] }, async ({ page }) => { - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); - - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); await page.waitForSelector('[data-testid="blank-flow"]', { timeout: 30000, diff --git a/src/frontend/tests/core/unit/dropdownComponent.spec.ts b/src/frontend/tests/core/unit/dropdownComponent.spec.ts index fa4692152..e9010c4ff 100644 --- a/src/frontend/tests/core/unit/dropdownComponent.spec.ts +++ b/src/frontend/tests/core/unit/dropdownComponent.spec.ts @@ -1,35 +1,13 @@ import { expect, test } from "@playwright/test"; +import { adjustScreenView } from "../../utils/adjust-screen-view"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "dropDownComponent", { tag: ["@release", "@workspace"] }, async ({ page }) => { - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); + await awaitBootstrapTest(page); - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } await page.waitForSelector('[data-testid="blank-flow"]', { timeout: 30000, }); @@ -49,10 +27,7 @@ test( .dragTo(page.locator('//*[@id="react-flow-id"]')); await page.mouse.up(); await page.mouse.down(); - await page.getByTestId("fit_view").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); + await adjustScreenView(page); await page.getByTestId("title-Amazon Bedrock").click(); await page.getByTestId("dropdown_str_model_id").click(); diff --git a/src/frontend/tests/core/unit/fileUploadComponent.spec.ts b/src/frontend/tests/core/unit/fileUploadComponent.spec.ts index ab980f5f1..5991dc327 100644 --- a/src/frontend/tests/core/unit/fileUploadComponent.spec.ts +++ b/src/frontend/tests/core/unit/fileUploadComponent.spec.ts @@ -1,5 +1,7 @@ import { expect, test } from "@playwright/test"; import path from "path"; +import { adjustScreenView } from "../../utils/adjust-screen-view"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "should be able to upload a file", @@ -7,32 +9,8 @@ test( tag: ["@release", "@workspace"], }, async ({ page }) => { - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); + await awaitBootstrapTest(page); - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } await page.waitForSelector('[data-testid="blank-flow"]', { timeout: 30000, }); @@ -51,10 +29,7 @@ test( .dragTo(page.locator('//*[@id="react-flow-id"]')); await page.mouse.up(); await page.mouse.down(); - await page.getByTestId("fit_view").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); + await adjustScreenView(page); const fileChooserPromise = page.waitForEvent("filechooser"); await page.getByTestId("button_upload_file").click(); const fileChooser = await fileChooserPromise; @@ -72,10 +47,7 @@ test( .dragTo(page.locator('//*[@id="react-flow-id"]')); await page.mouse.up(); await page.mouse.down(); - await page.getByTestId("fit_view").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); + await adjustScreenView(page); await page.getByTestId("sidebar-search-input").click(); await page.getByTestId("sidebar-search-input").fill("parse data"); @@ -86,10 +58,7 @@ test( await page.mouse.up(); await page.mouse.down(); - await page.getByTestId("fit_view").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); + await adjustScreenView(page); let visibleElementHandle; diff --git a/src/frontend/tests/core/unit/floatComponent.spec.ts b/src/frontend/tests/core/unit/floatComponent.spec.ts index 92ddbcb0c..7f2d80381 100644 --- a/src/frontend/tests/core/unit/floatComponent.spec.ts +++ b/src/frontend/tests/core/unit/floatComponent.spec.ts @@ -1,35 +1,13 @@ import { expect, test } from "@playwright/test"; +import { adjustScreenView } from "../../utils/adjust-screen-view"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "FloatComponent", { tag: ["@release", "@workspace"] }, async ({ page }) => { - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); + await awaitBootstrapTest(page); - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } await page.waitForSelector('[data-testid="blank-flow"]', { timeout: 30000, }); @@ -46,10 +24,7 @@ test( .dragTo(page.locator('//*[@id="react-flow-id"]')); await page.mouse.up(); await page.mouse.down(); - await page.getByTestId("fit_view").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); + await adjustScreenView(page); await page.locator('//*[@id="float_float_temperature"]').click(); await page.locator('//*[@id="float_float_temperature"]').fill(""); diff --git a/src/frontend/tests/core/unit/inputComponent.spec.ts b/src/frontend/tests/core/unit/inputComponent.spec.ts index 2e0824a31..54c92da3a 100644 --- a/src/frontend/tests/core/unit/inputComponent.spec.ts +++ b/src/frontend/tests/core/unit/inputComponent.spec.ts @@ -1,35 +1,13 @@ import { expect, test } from "@playwright/test"; +import { adjustScreenView } from "../../utils/adjust-screen-view"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "InputComponent", { tag: ["@release", "@workspace"] }, async ({ page }) => { - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); + await awaitBootstrapTest(page); - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } await page.waitForSelector('[data-testid="blank-flow"]', { timeout: 30000, }); @@ -45,14 +23,8 @@ test( .dragTo(page.locator('//*[@id="react-flow-id"]')); await page.mouse.up(); await page.mouse.down(); - await page.waitForSelector('[data-testid="fit_view"]', { - timeout: 100000, - }); + await adjustScreenView(page); - await page.getByTestId("fit_view").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); await page.getByTestId("popover-anchor-input-collection_name").click(); await page .getByTestId("popover-anchor-input-collection_name") diff --git a/src/frontend/tests/core/unit/inputListComponent.spec.ts b/src/frontend/tests/core/unit/inputListComponent.spec.ts index 6d989fa9c..676a26287 100644 --- a/src/frontend/tests/core/unit/inputListComponent.spec.ts +++ b/src/frontend/tests/core/unit/inputListComponent.spec.ts @@ -1,28 +1,12 @@ import { expect, test } from "@playwright/test"; +import { adjustScreenView } from "../../utils/adjust-screen-view"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "InputListComponent", { tag: ["@release", "@workspace"] }, async ({ page }) => { - await page.goto("/"); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); await page.getByTestId("blank-flow").click(); await page.getByTestId("sidebar-search-input").click(); @@ -36,10 +20,7 @@ test( .dragTo(page.locator('//*[@id="react-flow-id"]')); await page.mouse.up(); await page.mouse.down(); - await page.getByTestId("fit_view").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); + await adjustScreenView(page); await page.getByTestId("inputlist_str_urls_0").fill("test test test test"); diff --git a/src/frontend/tests/core/unit/intComponent.spec.ts b/src/frontend/tests/core/unit/intComponent.spec.ts index c8b31874f..f18f8f8e7 100644 --- a/src/frontend/tests/core/unit/intComponent.spec.ts +++ b/src/frontend/tests/core/unit/intComponent.spec.ts @@ -1,32 +1,9 @@ import { expect, test } from "@playwright/test"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test("IntComponent", { tag: ["@release", "@workspace"] }, async ({ page }) => { - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); + await awaitBootstrapTest(page); - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } await page.waitForSelector('[data-testid="blank-flow"]', { timeout: 30000, }); diff --git a/src/frontend/tests/core/unit/keyPairListComponent.spec.ts b/src/frontend/tests/core/unit/keyPairListComponent.spec.ts index f0600080b..38fb6e03c 100644 --- a/src/frontend/tests/core/unit/keyPairListComponent.spec.ts +++ b/src/frontend/tests/core/unit/keyPairListComponent.spec.ts @@ -1,35 +1,13 @@ import { expect, test } from "@playwright/test"; +import { adjustScreenView } from "../../utils/adjust-screen-view"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "KeypairListComponent", { tag: ["@release", "@workspace"] }, async ({ page }) => { - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); + await awaitBootstrapTest(page); - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } await page.waitForSelector('[data-testid="blank-flow"]', { timeout: 30000, }); @@ -46,10 +24,7 @@ test( .dragTo(page.locator('//*[@id="react-flow-id"]')); await page.mouse.up(); await page.mouse.down(); - await page.getByTestId("fit_view").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); + await adjustScreenView(page); await page.getByTestId("more-options-modal").click(); await page.getByTestId("advanced-button-modal").click(); diff --git a/src/frontend/tests/core/unit/linkComponent.spec.ts b/src/frontend/tests/core/unit/linkComponent.spec.ts index 67f97fee0..8baa0183b 100644 --- a/src/frontend/tests/core/unit/linkComponent.spec.ts +++ b/src/frontend/tests/core/unit/linkComponent.spec.ts @@ -1,40 +1,12 @@ import { expect, Page, test } from "@playwright/test"; -import uaParser from "ua-parser-js"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; // TODO: This test might not be needed anymore test( "user should interact with link component", { tag: ["@release", "@workspace"] }, async ({ context, page }) => { - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); - - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } - - const getUA = await page.evaluate(() => navigator.userAgent); - const userAgentInfo = uaParser(getUA); + await awaitBootstrapTest(page); await page.waitForSelector('[data-testid="blank-flow"]', { timeout: 30000, diff --git a/src/frontend/tests/core/unit/nestedComponent.spec.ts b/src/frontend/tests/core/unit/nestedComponent.spec.ts index 27a8bbd13..753440898 100644 --- a/src/frontend/tests/core/unit/nestedComponent.spec.ts +++ b/src/frontend/tests/core/unit/nestedComponent.spec.ts @@ -1,35 +1,13 @@ import { expect, test } from "@playwright/test"; +import { adjustScreenView } from "../../utils/adjust-screen-view"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "NestedComponent", { tag: ["@release", "@workspace"] }, async ({ page }) => { - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); + await awaitBootstrapTest(page); - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } await page.waitForSelector('[data-testid="blank-flow"]', { timeout: 30000, }); @@ -47,10 +25,7 @@ test( .dragTo(page.locator('//*[@id="react-flow-id"]')); await page.click('//*[@id="react-flow-id"]'); - await page.getByTestId("fit_view").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); + await adjustScreenView(page); await page.getByTestId("dict_nesteddict_headers").first().click(); await page diff --git a/src/frontend/tests/core/unit/promptModalComponent.spec.ts b/src/frontend/tests/core/unit/promptModalComponent.spec.ts index c774d2b94..42f6348ee 100644 --- a/src/frontend/tests/core/unit/promptModalComponent.spec.ts +++ b/src/frontend/tests/core/unit/promptModalComponent.spec.ts @@ -1,35 +1,13 @@ import { expect, test } from "@playwright/test"; +import { adjustScreenView } from "../../utils/adjust-screen-view"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "PromptTemplateComponent", { tag: ["@release", "@workspace"] }, async ({ page }) => { - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); + await awaitBootstrapTest(page); - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } await page.waitForSelector('[data-testid="blank-flow"]', { timeout: 30000, }); @@ -46,10 +24,7 @@ test( .dragTo(page.locator('//*[@id="react-flow-id"]')); await page.mouse.up(); await page.mouse.down(); - await page.getByTestId("fit_view").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); + await adjustScreenView(page); await page.getByTestId("promptarea_prompt_template").click(); await page diff --git a/src/frontend/tests/core/unit/sliderComponent.spec.ts b/src/frontend/tests/core/unit/sliderComponent.spec.ts index d1263401f..6f8ebba69 100644 --- a/src/frontend/tests/core/unit/sliderComponent.spec.ts +++ b/src/frontend/tests/core/unit/sliderComponent.spec.ts @@ -1,5 +1,5 @@ import { expect, Page, test } from "@playwright/test"; -import uaParser from "ua-parser-js"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; // TODO: This component doesn't have slider needs updating test( @@ -8,35 +8,7 @@ test( tag: ["@release", "@workspace"], }, async ({ page }) => { - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); - - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } - - const getUA = await page.evaluate(() => navigator.userAgent); - const userAgentInfo = uaParser(getUA); + await awaitBootstrapTest(page); await page.waitForSelector('[data-testid="blank-flow"]', { timeout: 30000, diff --git a/src/frontend/tests/core/unit/tableInputComponent.spec.ts b/src/frontend/tests/core/unit/tableInputComponent.spec.ts index ea78e3b0e..f460928b3 100644 --- a/src/frontend/tests/core/unit/tableInputComponent.spec.ts +++ b/src/frontend/tests/core/unit/tableInputComponent.spec.ts @@ -1,5 +1,5 @@ import { expect, test } from "@playwright/test"; -import uaParser from "ua-parser-js"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "user must be able to interact with table input component", @@ -7,39 +7,12 @@ test( tag: ["@release", "@workspace"], }, async ({ page }) => { - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); - - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - const randomText = Math.random().toString(36).substring(7); const secondRandomText = Math.random().toString(36).substring(7); const thirdRandomText = Math.random().toString(36).substring(7); - const getUA = await page.evaluate(() => navigator.userAgent); - const userAgentInfo = uaParser(getUA); + await awaitBootstrapTest(page); - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } await page.waitForSelector('[data-testid="blank-flow"]', { timeout: 30000, }); diff --git a/src/frontend/tests/core/unit/textAreaModalComponent.spec.ts b/src/frontend/tests/core/unit/textAreaModalComponent.spec.ts index 92bf1133d..94e05661a 100644 --- a/src/frontend/tests/core/unit/textAreaModalComponent.spec.ts +++ b/src/frontend/tests/core/unit/textAreaModalComponent.spec.ts @@ -1,28 +1,13 @@ import { expect, test } from "@playwright/test"; +import { adjustScreenView } from "../../utils/adjust-screen-view"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "TextAreaModalComponent", { tag: ["@release", "@workspace"] }, async ({ page }) => { - await page.goto("/"); + await awaitBootstrapTest(page); - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } await page.waitForSelector('[data-testid="blank-flow"]', { timeout: 30000, }); @@ -40,14 +25,8 @@ test( .dragTo(page.locator('//*[@id="react-flow-id"]')); await page.mouse.up(); await page.mouse.down(); - await page.waitForSelector('[data-testid="fit_view"]', { - timeout: 100000, - }); + await adjustScreenView(page); - await page.getByTestId("fit_view").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); await page.getByTestId("promptarea_prompt_template").click(); await page.getByTestId("modal-promptarea_prompt_template").fill("{text}"); diff --git a/src/frontend/tests/core/unit/toggleComponent.spec.ts b/src/frontend/tests/core/unit/toggleComponent.spec.ts index e11d3642b..20bea4ca4 100644 --- a/src/frontend/tests/core/unit/toggleComponent.spec.ts +++ b/src/frontend/tests/core/unit/toggleComponent.spec.ts @@ -1,35 +1,13 @@ import { expect, test } from "@playwright/test"; +import { adjustScreenView } from "../../utils/adjust-screen-view"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "ToggleComponent", { tag: ["@release", "@workspace"] }, async ({ page }) => { - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); + await awaitBootstrapTest(page); - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } await page.waitForSelector('[data-testid="blank-flow"]', { timeout: 30000, }); @@ -47,14 +25,7 @@ test( await page.mouse.up(); await page.mouse.down(); - await page.waitForSelector('[data-testid="fit_view"]', { - timeout: 100000, - }); - - await page.getByTestId("fit_view").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); + await adjustScreenView(page); await page.getByTestId("div-generic-node").click(); @@ -101,14 +72,7 @@ test( await page.getByTestId("div-generic-node").click(); - await page.waitForSelector('[data-testid="fit_view"]', { - timeout: 100000, - }); - - await page.getByTestId("fit_view").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); + await adjustScreenView(page); await page.getByTestId("more-options-modal").click(); await page.getByTestId("advanced-button-modal").click(); diff --git a/src/frontend/tests/extended/features/actionsMainPage-shard-0.spec.ts b/src/frontend/tests/extended/features/actionsMainPage-shard-0.spec.ts index 5ab28a788..6b06020f2 100644 --- a/src/frontend/tests/extended/features/actionsMainPage-shard-0.spec.ts +++ b/src/frontend/tests/extended/features/actionsMainPage-shard-0.spec.ts @@ -1,48 +1,16 @@ import { expect, test } from "@playwright/test"; +import { adjustScreenView } from "../../utils/adjust-screen-view"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "user should be able to download a flow or a component", { tag: ["@release", "@workspace"] }, async ({ page }) => { - await page.goto("/"); - - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); - - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); await page.getByTestId("side_nav_options_all-templates").click(); await page.getByRole("heading", { name: "Basic Prompting" }).click(); - - await page.waitForSelector('[data-testid="fit_view"]', { - timeout: 100000, - }); - - await page.getByTestId("fit_view").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); + await adjustScreenView(page); await page.getByText("Chat Input", { exact: true }).click(); await page.getByTestId("more-options-modal").click(); @@ -94,21 +62,6 @@ test( await page.waitForSelector('[data-testid="mainpage_title"]', { timeout: 30000, }); - - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - await page.getByTestId("upload-folder-button").last().click(); }, ); @@ -117,43 +70,11 @@ test( "user should be able to duplicate a flow or a component", { tag: ["@release", "@workspace"] }, async ({ page }) => { - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); - - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); await page.getByTestId("side_nav_options_all-templates").click(); await page.getByRole("heading", { name: "Basic Prompting" }).click(); - await page.waitForSelector('[data-testid="fit_view"]', { - timeout: 100000, - }); - - await page.getByTestId("fit_view").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); + await adjustScreenView(page); await page.getByText("Chat Input", { exact: true }).click(); await page.getByTestId("more-options-modal").click(); diff --git a/src/frontend/tests/extended/features/auto-save-off.spec.ts b/src/frontend/tests/extended/features/auto-save-off.spec.ts index b5ebf0830..abdd53560 100644 --- a/src/frontend/tests/extended/features/auto-save-off.spec.ts +++ b/src/frontend/tests/extended/features/auto-save-off.spec.ts @@ -1,4 +1,5 @@ import { expect, test } from "@playwright/test"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "user should be able to manually save a flow when the auto_save is off", @@ -19,34 +20,7 @@ test( }); }); - await page.goto("/"); - await page.locator("span").filter({ hasText: "My Collection" }).isVisible(); - - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 5000, - }); - - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 5000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); await page.waitForSelector('[data-testid="blank-flow"]', { timeout: 5000, diff --git a/src/frontend/tests/extended/features/curlApiGeneration.spec.ts b/src/frontend/tests/extended/features/curlApiGeneration.spec.ts index c3fbe479f..f811f2033 100644 --- a/src/frontend/tests/extended/features/curlApiGeneration.spec.ts +++ b/src/frontend/tests/extended/features/curlApiGeneration.spec.ts @@ -1,27 +1,12 @@ import { expect, test } from "@playwright/test"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "curl_api_generation", { tag: ["@release", "@api", "@workspace"] }, async ({ page, context }) => { - await page.goto("/"); - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } + await awaitBootstrapTest(page); - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } await page.getByTestId("side_nav_options_all-templates").click(); await page.getByRole("heading", { name: "Basic Prompting" }).click(); await page.getByText("API", { exact: true }).click(); diff --git a/src/frontend/tests/extended/features/dragAndDrop.spec.ts b/src/frontend/tests/extended/features/dragAndDrop.spec.ts index 9c8b5ed46..ec1dd047a 100644 --- a/src/frontend/tests/extended/features/dragAndDrop.spec.ts +++ b/src/frontend/tests/extended/features/dragAndDrop.spec.ts @@ -1,29 +1,12 @@ import { expect, test } from "@playwright/test"; import { readFileSync } from "fs"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; import { simulateDragAndDrop } from "../../utils/simulate-drag-and-drop"; test( "user should be able to drag and drop an old collection without crashing the application", { tag: ["@release"] }, async ({ page }) => { - await page.goto("/"); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); await page.locator("span").filter({ hasText: "Close" }).first().click(); @@ -55,25 +38,7 @@ test( "user should be able to drag and drop a flow on main page", { tag: ["@release"] }, async ({ page }) => { - await page.goto("/"); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); await page.locator("span").filter({ hasText: "Close" }).first().click(); await page.locator("span").filter({ hasText: "My Projects" }).isVisible(); diff --git a/src/frontend/tests/extended/features/filterEdge-shard-1.spec.ts b/src/frontend/tests/extended/features/filterEdge-shard-1.spec.ts index 28b7122cd..8439910da 100644 --- a/src/frontend/tests/extended/features/filterEdge-shard-1.spec.ts +++ b/src/frontend/tests/extended/features/filterEdge-shard-1.spec.ts @@ -1,35 +1,12 @@ import { expect, test } from "@playwright/test"; +import { adjustScreenView } from "../../utils/adjust-screen-view"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "user must see on handle click the possibility connections - RetrievalQA", { tag: ["@release", "@api", "@components"] }, async ({ page }) => { - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); - - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); await page.getByTestId("blank-flow").click(); @@ -60,11 +37,8 @@ test( .dragTo(page.locator('//*[@id="react-flow-id"]')); await page.mouse.up(); await page.mouse.down(); - await page.getByTestId("fit_view").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); + await adjustScreenView(page); let visibleElementHandle; const outputElements = await page diff --git a/src/frontend/tests/extended/features/flowPage.spec.ts b/src/frontend/tests/extended/features/flowPage.spec.ts index 7c198fdb7..e4594307d 100644 --- a/src/frontend/tests/extended/features/flowPage.spec.ts +++ b/src/frontend/tests/extended/features/flowPage.spec.ts @@ -1,33 +1,9 @@ import { test } from "@playwright/test"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test.describe("Flow Page tests", () => { test("save", { tag: ["@release"] }, async ({ page }) => { - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); - - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); await page.getByTestId("blank-flow").click(); diff --git a/src/frontend/tests/extended/features/flowSettings.spec.ts b/src/frontend/tests/extended/features/flowSettings.spec.ts index 2d6f2e316..b5f662d17 100644 --- a/src/frontend/tests/extended/features/flowSettings.spec.ts +++ b/src/frontend/tests/extended/features/flowSettings.spec.ts @@ -1,35 +1,12 @@ import { expect, test } from "@playwright/test"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "flowSettings", { tag: ["@release", "@api", "@workspace"] }, async ({ page }) => { - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); + await awaitBootstrapTest(page); - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } await page.waitForSelector('[data-testid="blank-flow"]', { timeout: 30000, }); diff --git a/src/frontend/tests/extended/features/integration-side-bar.spec.ts b/src/frontend/tests/extended/features/integration-side-bar.spec.ts index cd8832286..154ccb920 100644 --- a/src/frontend/tests/extended/features/integration-side-bar.spec.ts +++ b/src/frontend/tests/extended/features/integration-side-bar.spec.ts @@ -1,41 +1,12 @@ import { expect, test } from "@playwright/test"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "user should be able to see integrations in the sidebar if mvp_components is true", { tag: ["@release", "@api", "@workspace"] }, async ({ page }) => { - // await page.route("**/api/v1/config", (route) => { - // route.fulfill({ - // status: 200, - // contentType: "application/json", - // body: JSON.stringify({ - // feature_flags: { - // mvp_components: true, - // }, - // }), - // headers: { - // "content-type": "application/json", - // ...route.request().headers(), - // }, - // }); - // }); - await page.goto("/"); - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); + await page.getByTestId("blank-flow").click(); await page.waitForSelector('[data-testid="shad-sidebar"]', { timeout: 30000, diff --git a/src/frontend/tests/extended/features/langflowShortcuts.spec.ts b/src/frontend/tests/extended/features/langflowShortcuts.spec.ts index ef4ef4a53..bdca35550 100644 --- a/src/frontend/tests/extended/features/langflowShortcuts.spec.ts +++ b/src/frontend/tests/extended/features/langflowShortcuts.spec.ts @@ -1,32 +1,12 @@ -import { expect, test } from "@playwright/test"; -import uaParser from "ua-parser-js"; +import { expect, Page, test } from "@playwright/test"; +import { adjustScreenView } from "../../utils/adjust-screen-view"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "LangflowShortcuts", { tag: ["@release", "@workspace"] }, async ({ page }) => { - await page.goto("/"); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } - - const getUA = await page.evaluate(() => navigator.userAgent); - const userAgentInfo = uaParser(getUA); + await awaitBootstrapTest(page); await page.waitForSelector('[data-testid="blank-flow"]', { timeout: 30000, @@ -48,14 +28,7 @@ test( await page.locator('//*[@id="react-flow-id"]/div/div[2]/button[3]').click(); - await page.waitForSelector('[data-testid="fit_view"]', { - timeout: 100000, - }); - - await page.getByTestId("fit_view").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); + await adjustScreenView(page); await page.getByTestId("generic-node-title-arrangement").click(); await page.keyboard.press(`ControlOrMeta+Shift+A`); await page.getByText("Close").last().click(); diff --git a/src/frontend/tests/extended/features/limit-file-size-upload.spec.ts b/src/frontend/tests/extended/features/limit-file-size-upload.spec.ts index b57f6929a..d2986e66c 100644 --- a/src/frontend/tests/extended/features/limit-file-size-upload.spec.ts +++ b/src/frontend/tests/extended/features/limit-file-size-upload.spec.ts @@ -2,6 +2,8 @@ import { expect, test } from "@playwright/test"; import * as dotenv from "dotenv"; import { readFileSync } from "fs"; import path from "path"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; +import { initialGPTsetup } from "../../utils/initialGPTsetup"; test( "user should not be able to upload a file larger than the limit", @@ -30,61 +32,11 @@ test( dotenv.config({ path: path.resolve(__dirname, "../../.env") }); } - await page.goto("/"); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); await page.getByTestId("side_nav_options_all-templates").click(); await page.getByRole("heading", { name: "Basic Prompting" }).click(); - await page.waitForSelector('[data-testid="fit_view"]', { - timeout: 100000, - }); - - await page.getByTestId("fit_view").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - - let outdatedComponents = await page - .getByTestId("icon-AlertTriangle") - .count(); - - while (outdatedComponents > 0) { - await page.getByTestId("icon-AlertTriangle").first().click(); - 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(); - filledApiKey = await page.getByTestId("remove-icon-badge").count(); - } - - const apiKeyInput = page.getByTestId("popover-anchor-input-api_key"); - const isApiKeyInputVisible = await apiKeyInput.isVisible(); - - if (isApiKeyInputVisible) { - await apiKeyInput.fill(process.env.OPENAI_API_KEY ?? ""); - } - - await page.getByTestId("dropdown_str_model_name").click(); - await page.getByTestId("gpt-4o-1-option").click(); + await initialGPTsetup(page); await page.waitForSelector("text=Chat Input", { timeout: 30000 }); diff --git a/src/frontend/tests/extended/features/lock-flow.spec.ts b/src/frontend/tests/extended/features/lock-flow.spec.ts index 406f1dad2..3ed84fb81 100644 --- a/src/frontend/tests/extended/features/lock-flow.spec.ts +++ b/src/frontend/tests/extended/features/lock-flow.spec.ts @@ -1,6 +1,7 @@ import { expect, test } from "@playwright/test"; import * as dotenv from "dotenv"; import path from "path"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "user must be able to lock a flow and it must be saved", @@ -15,32 +16,7 @@ test( dotenv.config({ path: path.resolve(__dirname, "../../.env") }); } - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); - - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); await page.getByTestId("side_nav_options_all-templates").click(); await page.getByRole("heading", { name: "Basic Prompting" }).click(); diff --git a/src/frontend/tests/extended/features/minimize.spec.ts b/src/frontend/tests/extended/features/minimize.spec.ts index 260be5157..ccca8ed81 100644 --- a/src/frontend/tests/extended/features/minimize.spec.ts +++ b/src/frontend/tests/extended/features/minimize.spec.ts @@ -1,35 +1,12 @@ import { expect, test } from "@playwright/test"; +import { adjustScreenView } from "../../utils/adjust-screen-view"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "user must be able to minimize and expand a component", { tag: ["@release", "@workspace"] }, async ({ page }) => { - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); - - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); await page.getByTestId("blank-flow").click(); @@ -54,10 +31,7 @@ test( await page.mouse.up(); - await page.getByTestId("fit_view").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); + await adjustScreenView(page); await page.getByTestId("more-options-modal").click(); diff --git a/src/frontend/tests/extended/features/outdated-actions.spec.ts b/src/frontend/tests/extended/features/outdated-actions.spec.ts index 5b682a728..acc8e1c14 100644 --- a/src/frontend/tests/extended/features/outdated-actions.spec.ts +++ b/src/frontend/tests/extended/features/outdated-actions.spec.ts @@ -1,26 +1,10 @@ import { expect, test } from "@playwright/test"; import { readFileSync } from "fs"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test("user must be able to update outdated components", async ({ page }) => { - await page.goto("/"); + await awaitBootstrapTest(page); - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } await page.locator("span").filter({ hasText: "Close" }).first().click(); await page.locator("span").filter({ hasText: "My Collection" }).isVisible(); diff --git a/src/frontend/tests/extended/features/outdated-message.spec.ts b/src/frontend/tests/extended/features/outdated-message.spec.ts index e88eaf113..677f36849 100644 --- a/src/frontend/tests/extended/features/outdated-message.spec.ts +++ b/src/frontend/tests/extended/features/outdated-message.spec.ts @@ -1,24 +1,10 @@ import { test } from "@playwright/test"; import { readFileSync } from "fs"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test("user must be able outdated message on error", async ({ page }) => { - await page.goto("/"); + await awaitBootstrapTest(page); - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForTimeout(3000); - modalCount = await page.getByTestId("modal-title")?.count(); - } await page.locator("span").filter({ hasText: "Close" }).first().click(); await page.locator("span").filter({ hasText: "My Collection" }).isVisible(); diff --git a/src/frontend/tests/extended/features/pythonApiGeneration.spec.ts b/src/frontend/tests/extended/features/pythonApiGeneration.spec.ts index 70c2a4d16..b3efc5bda 100644 --- a/src/frontend/tests/extended/features/pythonApiGeneration.spec.ts +++ b/src/frontend/tests/extended/features/pythonApiGeneration.spec.ts @@ -1,34 +1,12 @@ import { expect, test } from "@playwright/test"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "python_api_generation", { tag: ["@release", "@api", "@workspace"] }, async ({ page, context }) => { - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); + await awaitBootstrapTest(page); - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } await page.getByTestId("side_nav_options_all-templates").click(); await page.getByRole("heading", { name: "Basic Prompting" }).click(); await page.getByText("API", { exact: true }).click(); diff --git a/src/frontend/tests/extended/features/starter-projects.spec.ts b/src/frontend/tests/extended/features/starter-projects.spec.ts index 42ef07705..04500f0f5 100644 --- a/src/frontend/tests/extended/features/starter-projects.spec.ts +++ b/src/frontend/tests/extended/features/starter-projects.spec.ts @@ -1,27 +1,11 @@ import { expect, Page, test } from "@playwright/test"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "user must be able to interact with starter projects", { tag: ["@release", "@starter-projects"] }, async ({ page, context }) => { - await page.goto("/"); - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); expect(page.getByText("Start from scratch", { exact: true })).toBeVisible(); expect(page.getByRole("button", { name: "Blank Flow" })).toBeVisible(); diff --git a/src/frontend/tests/extended/features/sticky-notes.spec.ts b/src/frontend/tests/extended/features/sticky-notes.spec.ts index 5c43505aa..b91d744e2 100644 --- a/src/frontend/tests/extended/features/sticky-notes.spec.ts +++ b/src/frontend/tests/extended/features/sticky-notes.spec.ts @@ -1,33 +1,11 @@ import { expect, test } from "@playwright/test"; -import uaParser from "ua-parser-js"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "user should be able to interact with sticky notes", { tag: ["@release", "@workspace"] }, async ({ page }) => { - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); - - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - const getUA = await page.evaluate(() => navigator.userAgent); - const userAgentInfo = uaParser(getUA); - const randomTitle = Math.random() .toString(36) .substring(7) @@ -55,13 +33,7 @@ Despite its many benefits, AI also raises important ethical and societal questio The future of AI is both exciting and uncertain. As the technology continues to advance, it will undoubtedly bring about profound changes in society. The challenge will be to harness AI's potential for good while addressing the ethical and societal issues that arise. Whether it's through smarter healthcare, more efficient transportation, or enhanced creativity, AI has the potential to reshape the world in ways we are only beginning to imagine. The journey of AI is far from over, and its impact will be felt for generations to come. `; - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); await page.waitForSelector('[data-testid="blank-flow"]', { timeout: 30000, diff --git a/src/frontend/tests/extended/features/stop-button-playground.spec.ts b/src/frontend/tests/extended/features/stop-button-playground.spec.ts index 5eb60e643..7bd33641e 100644 --- a/src/frontend/tests/extended/features/stop-button-playground.spec.ts +++ b/src/frontend/tests/extended/features/stop-button-playground.spec.ts @@ -1,36 +1,12 @@ import { expect, test } from "@playwright/test"; -import uaParser from "ua-parser-js"; +import { adjustScreenView } from "../../utils/adjust-screen-view"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "User must be able to stop building from inside Playground", { tag: ["@release", "@api"] }, async ({ page }) => { - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); - - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); await page.getByTestId("blank-flow").click(); @@ -58,10 +34,7 @@ test( .getByTestId("outputsChat Output") .dragTo(page.locator('//*[@id="react-flow-id"]')); - await page.getByTestId("fit_view").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); + await adjustScreenView(page); await page.getByTestId("div-generic-node").nth(0).click(); @@ -96,9 +69,6 @@ class CustomComponent(Component): sleep(60) return data`; - const getUA = await page.evaluate(() => navigator.userAgent); - const userAgentInfo = uaParser(getUA); - await page.locator(".ace_content").click(); await page.keyboard.press(`ControlOrMeta+A`); await page.locator("textarea").fill(waitTimeoutCode); diff --git a/src/frontend/tests/extended/features/store-shard-1.spec.ts b/src/frontend/tests/extended/features/store-shard-1.spec.ts index 6bbf06e17..00b446096 100644 --- a/src/frontend/tests/extended/features/store-shard-1.spec.ts +++ b/src/frontend/tests/extended/features/store-shard-1.spec.ts @@ -1,6 +1,7 @@ import { expect, test } from "@playwright/test"; import * as dotenv from "dotenv"; import path from "path"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test.skip( "should like and add components and flows", @@ -13,22 +14,8 @@ test.skip( if (!process.env.CI) { dotenv.config({ path: path.resolve(__dirname, "../../.env") }); } - await page.goto("/"); - await page.waitForTimeout(1000); - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForTimeout(5000); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); + await page.getByText("Close", { exact: true }).click(); await page.waitForTimeout(1000); await page.getByTestId("button-store").click(); diff --git a/src/frontend/tests/extended/features/twoEdges.spec.ts b/src/frontend/tests/extended/features/twoEdges.spec.ts index abdc24e8c..59447bf6c 100644 --- a/src/frontend/tests/extended/features/twoEdges.spec.ts +++ b/src/frontend/tests/extended/features/twoEdges.spec.ts @@ -1,35 +1,11 @@ import { test } from "@playwright/test"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "user should be able to see multiple edges and interact with them", { tag: ["@release", "@api", "@workspace"] }, async ({ page }) => { - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); - - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); await page.getByText("Vector Store RAG", { exact: true }).last().click(); await page.getByText("Retriever", { exact: true }).first().isVisible(); diff --git a/src/frontend/tests/extended/features/userSettings.spec.ts b/src/frontend/tests/extended/features/userSettings.spec.ts index 4ad45097b..6360b987b 100644 --- a/src/frontend/tests/extended/features/userSettings.spec.ts +++ b/src/frontend/tests/extended/features/userSettings.spec.ts @@ -159,7 +159,6 @@ test("should see shortcuts", { tag: ["@release"] }, async ({ page }) => { test( "should interact with API Keys", { tag: ["@release", "@api"] }, - async ({ page }) => { await page.goto("/"); await page.getByTestId("user-profile-settings").click(); @@ -175,11 +174,20 @@ test( .getByPlaceholder("Insert a name for your API Key") .fill(randomName); await page.getByText("Create Secret Key", { exact: true }).click(); - await page.getByText("Please save").isVisible(); - await page.getByTestId("icon-Copy").click(); - await expect(page.getByText("Api Key Copied!")).toBeVisible({ + + // Wait for api key creation to complete and render the next form element + await page.waitForTimeout(1000); + + await page.waitForSelector("text=Please save", { timeout: 30000 }); + await page.waitForSelector('[data-testid="btn-copy-api-key"]', { timeout: 3000, + state: "visible", }); + + await page.getByTestId("btn-copy-api-key").click(); + + await page.waitForSelector("text=Api Key Copied!", { timeout: 30000 }); + await page.getByText(randomName).isVisible(); }, ); diff --git a/src/frontend/tests/extended/integrations/chatInputOutputUser-shard-1.spec.ts b/src/frontend/tests/extended/integrations/chatInputOutputUser-shard-1.spec.ts index 956e682e0..614f442be 100644 --- a/src/frontend/tests/extended/integrations/chatInputOutputUser-shard-1.spec.ts +++ b/src/frontend/tests/extended/integrations/chatInputOutputUser-shard-1.spec.ts @@ -1,6 +1,8 @@ import { 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"; test( "user must be able to see output inspection", @@ -15,61 +17,14 @@ test( dotenv.config({ path: path.resolve(__dirname, "../../.env") }); } - await page.goto("/"); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); await page.getByTestId("side_nav_options_all-templates").click(); await page.getByRole("heading", { name: "Basic Prompting" }).click(); await page.waitForSelector('[data-testid="fit_view"]', { timeout: 100000, }); - - await page.getByTestId("fit_view").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - - let outdatedComponents = await page - .getByTestId("icon-AlertTriangle") - .count(); - - while (outdatedComponents > 0) { - await page.getByTestId("icon-AlertTriangle").first().click(); - 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(); - filledApiKey = await page.getByTestId("remove-icon-badge").count(); - } - - const apiKeyInput = page.getByTestId("popover-anchor-input-api_key"); - const isApiKeyInputVisible = await apiKeyInput.isVisible(); - - if (isApiKeyInputVisible) { - await apiKeyInput.fill(process.env.OPENAI_API_KEY ?? ""); - } - - await page.getByTestId("dropdown_str_model_name").click(); - await page.getByTestId("gpt-4o-1-option").click(); + await initialGPTsetup(page); await page.getByTestId("button_run_chat output").last().click(); diff --git a/src/frontend/tests/extended/integrations/chatInputOutputUser-shard-2.spec.ts b/src/frontend/tests/extended/integrations/chatInputOutputUser-shard-2.spec.ts index 358e92e2c..ff9aa4058 100644 --- a/src/frontend/tests/extended/integrations/chatInputOutputUser-shard-2.spec.ts +++ b/src/frontend/tests/extended/integrations/chatInputOutputUser-shard-2.spec.ts @@ -1,6 +1,8 @@ -import { expect, test } from "@playwright/test"; +import { expect, Page, 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"; test( "user must interact with chat with Input/Output", @@ -15,61 +17,12 @@ test( dotenv.config({ path: path.resolve(__dirname, "../../.env") }); } - await page.goto("/"); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); await page.getByTestId("side_nav_options_all-templates").click(); await page.getByRole("heading", { name: "Basic Prompting" }).click(); - await page.waitForSelector('[data-testid="fit_view"]', { - timeout: 100000, - }); - await page.getByTestId("fit_view").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - - let outdatedComponents = await page - .getByTestId("icon-AlertTriangle") - .count(); - - while (outdatedComponents > 0) { - await page.getByTestId("icon-AlertTriangle").first().click(); - 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(); - filledApiKey = await page.getByTestId("remove-icon-badge").count(); - } - - const apiKeyInput = page.getByTestId("popover-anchor-input-api_key"); - const isApiKeyInputVisible = await apiKeyInput.isVisible(); - - if (isApiKeyInputVisible) { - await apiKeyInput.fill(process.env.OPENAI_API_KEY ?? ""); - } - - await page.getByTestId("dropdown_str_model_name").click(); - await page.getByTestId("gpt-4o-1-option").click(); + await initialGPTsetup(page); await page.getByText("Playground", { exact: true }).last().click(); diff --git a/src/frontend/tests/extended/integrations/duckduckgo.spec.ts b/src/frontend/tests/extended/integrations/duckduckgo.spec.ts index b291a8ae1..85b166bec 100644 --- a/src/frontend/tests/extended/integrations/duckduckgo.spec.ts +++ b/src/frontend/tests/extended/integrations/duckduckgo.spec.ts @@ -1,35 +1,11 @@ import { expect, test } from "@playwright/test"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "user should be able to use duckduckgo search component", { tag: ["@release", "@components"] }, async ({ page }) => { - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); - - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); await page.getByTestId("blank-flow").click(); await page.getByTestId("sidebar-search-input").click(); diff --git a/src/frontend/tests/extended/integrations/youtube-transcripts.spec.ts b/src/frontend/tests/extended/integrations/youtube-transcripts.spec.ts index 921289112..36d1eeee5 100644 --- a/src/frontend/tests/extended/integrations/youtube-transcripts.spec.ts +++ b/src/frontend/tests/extended/integrations/youtube-transcripts.spec.ts @@ -1,35 +1,11 @@ import { expect, test } from "@playwright/test"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "user should be able to use youtube transcripts component", { tag: ["@release", "@components"] }, async ({ page }) => { - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); - - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); await page.getByTestId("blank-flow").click(); await page.getByTestId("sidebar-search-input").click(); diff --git a/src/frontend/tests/extended/regression/general-bugs-component-as-tool-shortcut.spec.ts b/src/frontend/tests/extended/regression/general-bugs-component-as-tool-shortcut.spec.ts index 53e6dc90b..bc6312aec 100644 --- a/src/frontend/tests/extended/regression/general-bugs-component-as-tool-shortcut.spec.ts +++ b/src/frontend/tests/extended/regression/general-bugs-component-as-tool-shortcut.spec.ts @@ -1,28 +1,12 @@ import { expect, test } from "@playwright/test"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; import { extractAndCleanCode } from "../../utils/extract-and-clean-code"; test( "user must be able to use component as tool shortcut only if has tool mode is True", { tag: ["@release", "@components"] }, async ({ page }) => { - await page.goto("/"); - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); await page.getByTestId("blank-flow").click(); diff --git a/src/frontend/tests/extended/regression/general-bugs-shard-3836.spec.ts b/src/frontend/tests/extended/regression/general-bugs-shard-3836.spec.ts index a4198b3f8..ee2491734 100644 --- a/src/frontend/tests/extended/regression/general-bugs-shard-3836.spec.ts +++ b/src/frontend/tests/extended/regression/general-bugs-shard-3836.spec.ts @@ -1,6 +1,8 @@ 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"; test( "user must be able to send an image on chat using advanced tool on ChatInputComponent", @@ -15,61 +17,11 @@ test( dotenv.config({ path: path.resolve(__dirname, "../../.env") }); } - await page.goto("/"); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); await page.getByTestId("side_nav_options_all-templates").click(); await page.getByRole("heading", { name: "Basic Prompting" }).click(); - await page.waitForSelector('[data-testid="fit_view"]', { - timeout: 100000, - }); - - await page.getByTestId("fit_view").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - - let outdatedComponents = await page - .getByTestId("icon-AlertTriangle") - .count(); - - while (outdatedComponents > 0) { - await page.getByTestId("icon-AlertTriangle").first().click(); - 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(); - filledApiKey = await page.getByTestId("remove-icon-badge").count(); - } - - const apiKeyInput = page.getByTestId("popover-anchor-input-api_key"); - const isApiKeyInputVisible = await apiKeyInput.isVisible(); - - if (isApiKeyInputVisible) { - await apiKeyInput.fill(process.env.OPENAI_API_KEY ?? ""); - } - - await page.getByTestId("dropdown_str_model_name").click(); - await page.getByTestId("gpt-4o-1-option").click(); + await initialGPTsetup(page); await page.waitForSelector("text=Chat Input", { timeout: 30000 }); diff --git a/src/frontend/tests/extended/regression/general-bugs-shard-3909.spec.ts b/src/frontend/tests/extended/regression/general-bugs-shard-3909.spec.ts index 28cf8d02f..ee509d6a9 100644 --- a/src/frontend/tests/extended/regression/general-bugs-shard-3909.spec.ts +++ b/src/frontend/tests/extended/regression/general-bugs-shard-3909.spec.ts @@ -1,6 +1,7 @@ import { expect, test } from "@playwright/test"; import * as dotenv from "dotenv"; import path from "path"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "user must be able to create a new flow clicking on New Flow button", @@ -15,25 +16,7 @@ test( dotenv.config({ path: path.resolve(__dirname, "../../.env") }); } - await page.goto("/"); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); await page.getByText("Close").last().click(); diff --git a/src/frontend/tests/extended/regression/generalBugs-shard-1.spec.ts b/src/frontend/tests/extended/regression/generalBugs-shard-1.spec.ts index f51fe8889..aff889af4 100644 --- a/src/frontend/tests/extended/regression/generalBugs-shard-1.spec.ts +++ b/src/frontend/tests/extended/regression/generalBugs-shard-1.spec.ts @@ -1,6 +1,8 @@ import { 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"; test( "should delete rows from table message", @@ -13,68 +15,11 @@ test( if (!process.env.CI) { dotenv.config({ path: path.resolve(__dirname, "../../.env") }); } - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); - - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); await page.getByTestId("side_nav_options_all-templates").click(); await page.getByRole("heading", { name: "Basic Prompting" }).click(); - await page.waitForSelector('[data-testid="fit_view"]', { - timeout: 100000, - }); - - await page.getByTestId("fit_view").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - - let outdatedComponents = await page - .getByTestId("icon-AlertTriangle") - .count(); - - while (outdatedComponents > 0) { - await page.getByTestId("icon-AlertTriangle").first().click(); - 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(); - filledApiKey = await page.getByTestId("remove-icon-badge").count(); - } - - const apiKeyInput = page.getByTestId("popover-anchor-input-api_key"); - const isApiKeyInputVisible = await apiKeyInput.isVisible(); - - if (isApiKeyInputVisible) { - await apiKeyInput.fill(process.env.OPENAI_API_KEY ?? ""); - } - - await page.getByTestId("dropdown_str_model_name").click(); - await page.getByTestId("gpt-4o-1-option").click(); + await initialGPTsetup(page); await page.getByTestId("button_run_chat output").click(); await page.waitForSelector("text=built successfully", { timeout: 30000 }); diff --git a/src/frontend/tests/extended/regression/generalBugs-shard-10.spec.ts b/src/frontend/tests/extended/regression/generalBugs-shard-10.spec.ts index 661e1b2a3..b037bd25d 100644 --- a/src/frontend/tests/extended/regression/generalBugs-shard-10.spec.ts +++ b/src/frontend/tests/extended/regression/generalBugs-shard-10.spec.ts @@ -1,6 +1,7 @@ import { expect, test } from "@playwright/test"; import * as dotenv from "dotenv"; import path from "path"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "freeze must work correctly", @@ -15,28 +16,10 @@ test( dotenv.config({ path: path.resolve(__dirname, "../../.env") }); } - await page.goto("/"); - const promptText = "answer as you are a dog"; const newPromptText = "answer as you are a bird"; - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); await page.getByTestId("side_nav_options_all-templates").click(); await page.getByRole("heading", { name: "Basic Prompting" }).click(); 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 b8809d2c6..107b17a55 100644 --- a/src/frontend/tests/extended/regression/generalBugs-shard-11.spec.ts +++ b/src/frontend/tests/extended/regression/generalBugs-shard-11.spec.ts @@ -1,33 +1,11 @@ import { expect, test } from "@playwright/test"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "user should be able to use ComposIO without getting api_key error", { tag: ["@release"] }, async ({ page }) => { - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); - - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page.getByTestId("modal-title"); - modalCount = await modalTitleElement.count(); - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title").count(); - } + await awaitBootstrapTest(page); await page.waitForSelector('[data-testid="blank-flow"]', { timeout: 30000, @@ -62,30 +40,7 @@ test( "user should be able to use connect tools", { tag: ["@release", "@api", "@components"] }, async ({ page }) => { - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); - - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page.getByTestId("modal-title"); - modalCount = await modalTitleElement.count(); - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title").count(); - } + await awaitBootstrapTest(page); await page.waitForSelector('[data-testid="blank-flow"]', { timeout: 30000, diff --git a/src/frontend/tests/extended/regression/generalBugs-shard-12.spec.ts b/src/frontend/tests/extended/regression/generalBugs-shard-12.spec.ts index 394e3071a..bdde84161 100644 --- a/src/frontend/tests/extended/regression/generalBugs-shard-12.spec.ts +++ b/src/frontend/tests/extended/regression/generalBugs-shard-12.spec.ts @@ -1,33 +1,11 @@ import { expect, test } from "@playwright/test"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "user should be able to connect RetrieverTool into another components", { tag: ["@release"] }, async ({ page }) => { - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); - - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page.getByTestId("modal-title"); - modalCount = await modalTitleElement.count(); - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title").count(); - } + await awaitBootstrapTest(page); await page.waitForSelector('[data-testid="blank-flow"]', { timeout: 30000, 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 4ed10537d..269a98445 100644 --- a/src/frontend/tests/extended/regression/generalBugs-shard-13.spec.ts +++ b/src/frontend/tests/extended/regression/generalBugs-shard-13.spec.ts @@ -1,6 +1,7 @@ import { expect, test } from "@playwright/test"; import * as dotenv from "dotenv"; import path from "path"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "should be able to share a component on the store by clicking on the share button on the canvas", @@ -15,25 +16,7 @@ test( dotenv.config({ path: path.resolve(__dirname, "../../.env") }); } - await page.goto("/"); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); await page.getByText("Close", { exact: true }).click(); diff --git a/src/frontend/tests/extended/regression/generalBugs-shard-2.spec.ts b/src/frontend/tests/extended/regression/generalBugs-shard-2.spec.ts index a3499e4ad..fc09f688b 100644 --- a/src/frontend/tests/extended/regression/generalBugs-shard-2.spec.ts +++ b/src/frontend/tests/extended/regression/generalBugs-shard-2.spec.ts @@ -1,6 +1,8 @@ import { expect, test } from "@playwright/test"; import * as dotenv from "dotenv"; import path from "path"; +import { adjustScreenView } from "../../utils/adjust-screen-view"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "should use webhook component on API", @@ -15,32 +17,7 @@ test( if (!process.env.CI) { dotenv.config({ path: path.resolve(__dirname, "../../.env") }); } - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); - - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); await page.getByTestId("blank-flow").click(); @@ -57,14 +34,7 @@ test( await page.mouse.up(); await page.mouse.down(); - await page.waitForSelector('[data-testid="fit_view"]', { - timeout: 100000, - }); - - await page.getByTestId("fit_view").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); + await adjustScreenView(page); // wait for the update to be applied await page.waitForTimeout(1000); 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 233e357fa..868daeaa1 100644 --- a/src/frontend/tests/extended/regression/generalBugs-shard-3.spec.ts +++ b/src/frontend/tests/extended/regression/generalBugs-shard-3.spec.ts @@ -1,6 +1,9 @@ import { expect, test } from "@playwright/test"; import * as dotenv from "dotenv"; import path from "path"; +import { adjustScreenView } from "../../utils/adjust-screen-view"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; +import { initialGPTsetup } from "../../utils/initialGPTsetup"; test( "should copy code from playground modal", @@ -16,34 +19,7 @@ test( if (!process.env.CI) { dotenv.config({ path: path.resolve(__dirname, "../../.env") }); } - - await page.goto("/"); - await page.locator("span").filter({ hasText: "My Collection" }).isVisible(); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); - - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); await page.waitForSelector('[data-testid="blank-flow"]', { timeout: 30000, @@ -66,10 +42,7 @@ test( await page.mouse.up(); await page.mouse.down(); - await page.getByTestId("fit_view").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); + await adjustScreenView(page); await page.getByTestId("sidebar-search-input").click(); await page.getByTestId("sidebar-search-input").fill("chat input"); @@ -86,10 +59,7 @@ test( await page.getByTestId("sidebar-search-input").click(); await page.getByTestId("sidebar-search-input").fill("openai"); - await page.getByTestId("fit_view").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); + await adjustScreenView(page); await page .getByTestId("modelsOpenAI") @@ -97,40 +67,7 @@ test( await page.mouse.up(); await page.mouse.down(); - await page.waitForSelector('[data-testid="fit_view"]', { - timeout: 100000, - }); - - await page.getByTestId("fit_view").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - - let outdatedComponents = await page - .getByTestId("icon-AlertTriangle") - .count(); - - while (outdatedComponents > 0) { - await page.getByTestId("icon-AlertTriangle").first().click(); - 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(); - filledApiKey = await page.getByTestId("remove-icon-badge").count(); - } - - const apiKeyInput = page.getByTestId("popover-anchor-input-api_key"); - const isApiKeyInputVisible = await apiKeyInput.isVisible(); - - if (isApiKeyInputVisible) { - await apiKeyInput.fill(process.env.OPENAI_API_KEY ?? ""); - } - - await page.getByTestId("dropdown_str_model_name").click(); - await page.getByTestId("gpt-4o-1-option").click(); + await initialGPTsetup(page); const elementsChatInput = await page .locator('[data-testid="handle-chatinput-shownode-message-right"]') @@ -240,33 +177,7 @@ test( "playground button should be enabled or disabled", { tag: ["@release", "@api", "@workspace"] }, async ({ page }) => { - await page.goto("/"); - await page.locator("span").filter({ hasText: "My Collection" }).isVisible(); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); - - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); await page.waitForSelector('[data-testid="blank-flow"]', { timeout: 30000, diff --git a/src/frontend/tests/extended/regression/generalBugs-shard-6.spec.ts b/src/frontend/tests/extended/regression/generalBugs-shard-6.spec.ts index cd0edfa0e..13234c42e 100644 --- a/src/frontend/tests/extended/regression/generalBugs-shard-6.spec.ts +++ b/src/frontend/tests/extended/regression/generalBugs-shard-6.spec.ts @@ -1,29 +1,11 @@ import { expect, test } from "@playwright/test"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "should be able to see error when something goes wrong on Code Modal", { tag: ["@release"] }, async ({ page }) => { - await page.goto("/"); - - let modalCount = 0; - - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); await page.waitForSelector('[data-testid="blank-flow"]', { timeout: 30000, diff --git a/src/frontend/tests/extended/regression/generalBugs-shard-7.spec.ts b/src/frontend/tests/extended/regression/generalBugs-shard-7.spec.ts index 2d43b44bc..80612273e 100644 --- a/src/frontend/tests/extended/regression/generalBugs-shard-7.spec.ts +++ b/src/frontend/tests/extended/regression/generalBugs-shard-7.spec.ts @@ -1,31 +1,12 @@ import { expect, test } from "@playwright/test"; -import uaParser from "ua-parser-js"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; // TODO: This test might not be needed anymore test( "should be able to select all with ctrl + A on advanced modal", { tag: ["@release"] }, async ({ page }) => { - await page.goto("/"); - - let modalCount = 0; - - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } + await awaitBootstrapTest(page); await page.waitForSelector('[data-testid="blank-flow"]', { timeout: 30000, @@ -47,9 +28,6 @@ test( await page.getByTestId("zoom_out").click(); await page.getByTestId("zoom_out").click(); - const getUA = await page.evaluate(() => navigator.userAgent); - const userAgentInfo = uaParser(getUA); - await page.getByTestId("div-generic-node").click(); await page.keyboard.press(`ControlOrMeta+Shift+A`); diff --git a/src/frontend/tests/extended/regression/generalBugs-shard-8.spec.ts b/src/frontend/tests/extended/regression/generalBugs-shard-8.spec.ts index 114ae619c..003d53eb8 100644 --- a/src/frontend/tests/extended/regression/generalBugs-shard-8.spec.ts +++ b/src/frontend/tests/extended/regression/generalBugs-shard-8.spec.ts @@ -1,35 +1,13 @@ import { test } from "@playwright/test"; +import { adjustScreenView } from "../../utils/adjust-screen-view"; +import { awaitBootstrapTest } from "../../utils/await-bootstrap-test"; test( "should interact with api request", { tag: ["@release"] }, async ({ page }) => { - await page.goto("/"); - await page.waitForSelector('[data-testid="mainpage_title"]', { - timeout: 30000, - }); + await awaitBootstrapTest(page); - await page.waitForSelector('[id="new-project-btn"]', { - timeout: 30000, - }); - - let modalCount = 0; - try { - const modalTitleElement = await page?.getByTestId("modal-title"); - if (modalTitleElement) { - modalCount = await modalTitleElement.count(); - } - } catch (error) { - modalCount = 0; - } - - while (modalCount === 0) { - await page.getByText("New Flow", { exact: true }).click(); - await page.waitForSelector('[data-testid="modal-title"]', { - timeout: 3000, - }); - modalCount = await page.getByTestId("modal-title")?.count(); - } await page.getByTestId("blank-flow").click(); await page.getByTestId("sidebar-search-input").click(); await page.getByTestId("sidebar-search-input").fill("api request"); @@ -43,9 +21,6 @@ test( .dragTo(page.locator('//*[@id="react-flow-id"]')); await page.mouse.up(); await page.mouse.down(); - await page.getByTestId("fit_view").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); + await adjustScreenView(page); }, ); diff --git a/src/frontend/tests/utils/adjust-screen-view.ts b/src/frontend/tests/utils/adjust-screen-view.ts index 51f0d9720..1aa373b2a 100644 --- a/src/frontend/tests/utils/adjust-screen-view.ts +++ b/src/frontend/tests/utils/adjust-screen-view.ts @@ -1,8 +1,16 @@ import { Page } from "playwright/test"; -export async function adjustScreenView(page: Page) { +export async function adjustScreenView( + page: Page, + { + numberOfZoomOut = 3, + }: { + numberOfZoomOut?: number; + } = {}, +) { await page.getByTestId("fit_view").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); - await page.getByTestId("zoom_out").click(); + + for (let i = 0; i < numberOfZoomOut; i++) { + await page.getByTestId("zoom_out").click(); + } } diff --git a/src/frontend/tests/utils/await-bootstrap-test.ts b/src/frontend/tests/utils/await-bootstrap-test.ts index e26e54d77..d718d1cc6 100644 --- a/src/frontend/tests/utils/await-bootstrap-test.ts +++ b/src/frontend/tests/utils/await-bootstrap-test.ts @@ -1,6 +1,15 @@ import { Page } from "playwright/test"; -export const awaitBootstrapTest = async (page: Page) => { +export const awaitBootstrapTest = async ( + page: Page, + options?: { + skipGoto?: boolean; + }, +) => { + if (!options?.skipGoto) { + await page.goto("/"); + } + await page.waitForSelector('[data-testid="mainpage_title"]', { timeout: 30000, });