From 7f4bd9779d61915a23201b829ee0ce5156d3da35 Mon Sep 17 00:00:00 2001 From: cristhianzl Date: Mon, 20 May 2024 16:35:09 -0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20(deleteComponentFlows.spec.ts):=20a?= =?UTF-8?q?dd=20steps=20to=20save=20API=20Key=20before=20deleting=20a=20fl?= =?UTF-8?q?ow=20to=20ensure=20proper=20authentication=20=E2=9C=A8=20(delet?= =?UTF-8?q?eComponentFlows.spec.ts):=20update=20confirmation=20message=20s?= =?UTF-8?q?elector=20to=20match=20the=20updated=20text=20=E2=9C=A8=20(nest?= =?UTF-8?q?edComponent.spec.ts):=20update=20selector=20to=20click=20on=20"?= =?UTF-8?q?New=20Project"=20button=20=E2=99=BB=EF=B8=8F=20(nestedComponent?= =?UTF-8?q?.spec.ts):=20remove=20redundant=20code=20for=20clicking=20on=20?= =?UTF-8?q?"showpinecone=5Fenv"=20checkbox=20=E2=99=BB=EF=B8=8F=20(nestedC?= =?UTF-8?q?omponent.spec.ts):=20remove=20redundant=20code=20for=20clicking?= =?UTF-8?q?=20on=20"showpinecone=5Fenv"=20checkbox=20=E2=99=BB=EF=B8=8F=20?= =?UTF-8?q?(nestedComponent.spec.ts):=20remove=20redundant=20code=20for=20?= =?UTF-8?q?clicking=20on=20"showpinecone=5Fenv"=20checkbox=20=E2=99=BB?= =?UTF-8?q?=EF=B8=8F=20(nestedComponent.spec.ts):=20remove=20redundant=20c?= =?UTF-8?q?ode=20for=20clicking=20on=20"showpinecone=5Fenv"=20checkbox=20?= =?UTF-8?q?=E2=99=BB=EF=B8=8F=20(saveComponents.spec.ts):=20update=20selec?= =?UTF-8?q?tor=20to=20click=20on=20"New=20Project"=20button=20=E2=99=BB?= =?UTF-8?q?=EF=B8=8F=20(saveComponents.spec.ts):=20remove=20redundant=20co?= =?UTF-8?q?de=20for=20clicking=20on=20"title-PythonFunctionTool"=20element?= =?UTF-8?q?=20=E2=99=BB=EF=B8=8F=20(saveComponents.spec.ts):=20remove=20re?= =?UTF-8?q?dundant=20code=20for=20clicking=20on=20"title-ChatOpenAI"=20ele?= =?UTF-8?q?ment=20=E2=99=BB=EF=B8=8F=20(store.spec.ts):=20update=20API=20K?= =?UTF-8?q?ey=20placeholder=20value=20to=20use=20environment=20variable=20?= =?UTF-8?q?instead=20of=20hardcoding=20it=20=E2=99=BB=EF=B8=8F=20(store.sp?= =?UTF-8?q?ec.ts):=20update=20API=20Key=20placeholder=20value=20to=20use?= =?UTF-8?q?=20environment=20variable=20instead=20of=20hardcoding=20it=20?= =?UTF-8?q?=E2=99=BB=EF=B8=8F=20(store.spec.ts):=20update=20API=20Key=20pl?= =?UTF-8?q?aceholder=20value=20to=20use=20environment=20variable=20instead?= =?UTF-8?q?=20of=20hardcoding=20it=20=E2=99=BB=EF=B8=8F=20(store.spec.ts):?= =?UTF-8?q?=20update=20API=20Key=20placeholder=20value=20to=20use=20enviro?= =?UTF-8?q?nment=20variable=20instead=20of=20hardcoding=20it=20=E2=99=BB?= =?UTF-8?q?=EF=B8=8F=20(store.spec.ts):=20update=20API=20Key=20placeholder?= =?UTF-8?q?=20value=20to=20use=20environment=20variable=20instead=20of=20h?= =?UTF-8?q?ardcoding=20it=20=E2=99=BB=EF=B8=8F=20(store.spec.ts):=20update?= =?UTF-8?q?=20API=20Key=20placeholder=20value=20to=20use=20environment=20v?= =?UTF-8?q?ariable=20instead=20of=20hardcoding=20it=20=E2=99=BB=EF=B8=8F?= =?UTF-8?q?=20(store.spec.ts):=20update=20API=20Key=20placeholder=20value?= =?UTF-8?q?=20to=20use=20environment=20variable=20instead=20of=20hardcodin?= =?UTF-8?q?g=20it=20=E2=99=BB=EF=B8=8F=20(store.spec.ts):=20update=20API?= =?UTF-8?q?=20Key=20placeholder=20value=20to=20use=20environment=20variabl?= =?UTF-8?q?e=20instead=20of=20hardcoding=20it=20=E2=99=BB=EF=B8=8F=20(stor?= =?UTF-8?q?e.spec.ts):=20update=20API=20Key=20placeholder=20value=20to=20u?= =?UTF-8?q?se=20environment=20variable=20instead=20of=20hardcoding=20it=20?= =?UTF-8?q?=E2=99=BB=EF=B8=8F=20(store.spec.ts):=20update=20API=20Key=20pl?= =?UTF-8?q?aceholder=20value=20to=20use=20environment=20variable=20instead?= =?UTF-8?q?=20of=20hardcoding=20it=20=E2=99=BB=EF=B8=8F=20(store.spec.ts):?= =?UTF-8?q?=20update=20API=20Key=20placeholder=20value=20to=20use=20enviro?= =?UTF-8?q?nment=20variable=20instead=20of=20hardcoding=20it=20=E2=99=BB?= =?UTF-8?q?=EF=B8=8F=20(store.spec.ts):=20update=20API=20Key=20placeholder?= =?UTF-8?q?=20value=20to=20use=20environment=20variable=20instead=20of=20h?= =?UTF-8?q?ardcoding=20it=20=E2=99=BB=EF=B8=8F=20(store.spec.ts):=20update?= =?UTF-8?q?=20API=20Key=20placeholder=20value=20to=20use=20environment=20v?= =?UTF-8?q?ariable=20instead=20of=20hardcoding=20it=20=E2=99=BB=EF=B8=8F?= =?UTF-8?q?=20(store.spec.ts):=20update=20API=20Key=20placeholder=20value?= =?UTF-8?q?=20to=20use=20environment=20variable=20instead=20of=20hardcodin?= =?UTF-8?q?g=20it=20=E2=99=BB=EF=B8=8F=20(store.spec.ts):=20update=20API?= =?UTF-8?q?=20Key=20placeholder=20value=20to=20use=20environment=20variabl?= =?UTF-8?q?e=20instead=20of=20hardcoding=20it=20=E2=99=BB=EF=B8=8F=20(stor?= =?UTF-8?q?e.spec.ts):=20update=20API=20Key=20placeholder=20value=20to=20u?= =?UTF-8?q?se=20environment=20variable=20instead=20of=20hardcoding=20it=20?= =?UTF-8?q?=E2=99=BB=EF=B8=8F=20(store.spec.ts):=20update=20API=20Key=20pl?= =?UTF-8?q?aceholder=20value=20to=20use=20environment=20variable=20instead?= =?UTF-8?q?=20of=20hardcoding=20it=20=E2=99=BB=EF=B8=8F=20(store.spec.ts):?= =?UTF-8?q?=20update=20API=20Key=20placeholder=20value=20to=20use=20enviro?= =?UTF-8?q?nment=20variable=20instead=20of=20hardcoding=20it=20=E2=99=BB?= =?UTF-8?q?=EF=B8=8F=20(store.spec.ts):=20update=20API=20Key=20placeholder?= =?UTF-8?q?=20value=20to=20use=20environment=20variable=20instead=20of=20h?= =?UTF-8?q?ardcoding=20it=20=E2=99=BB=EF=B8=8F=20(store.spec.ts):=20update?= =?UTF-8?q?=20API=20Key=20placeholder=20value=20to=20use=20environment=20v?= =?UTF-8?q?ariable=20instead=20of=20hardcoding=20it=20=E2=99=BB=EF=B8=8F?= =?UTF-8?q?=20(store.spec.ts):=20update=20API=20Key=20placeholder=20value?= =?UTF-8?q?=20to=20use=20environment=20variable=20instead=20of=20hardcodin?= =?UTF-8?q?g=20it=20=E2=99=BB=EF=B8=8F=20(store.spec.ts):=20update=20API?= =?UTF-8?q?=20Key=20placeholder=20value=20to=20use=20environment=20variabl?= =?UTF-8?q?e=20instead=20of=20hardcoding=20it=20=E2=99=BB=EF=B8=8F=20(stor?= =?UTF-8?q?e.spec.ts):=20update=20API=20Key=20placeholder=20value=20to=20u?= =?UTF-8?q?se=20environment=20variable=20instead=20of=20hardcoding=20it=20?= =?UTF-8?q?=E2=99=BB=EF=B8=8F=20(store.spec.ts):=20update=20API=20Key=20pl?= =?UTF-8?q?aceholder=20value=20to=20use=20environment=20variable=20instead?= =?UTF-8?q?=20of=20hardcoding=20it=20=E2=99=BB=EF=B8=8F=20(store.spec.ts):?= =?UTF-8?q?=20update=20API=20Key=20placeholder=20value=20to=20use=20enviro?= =?UTF-8?q?nment=20variable=20instead=20of=20hardcoding=20it=20=E2=99=BB?= =?UTF-8?q?=EF=B8=8F=20(store.spec.ts):=20update=20API=20Key=20placeholder?= =?UTF-8?q?=20value=20to=20use=20environment=20variable=20instead=20of=20h?= =?UTF-8?q?ardcoding=20it=20=E2=99=BB=EF=B8=8F=20(store.spec.ts):=20update?= =?UTF-8?q?=20API=20Key=20placeholder=20value=20to=20use=20environment=20v?= =?UTF-8?q?ariable=20instead=20of=20hardcoding=20it=20=E2=99=BB=EF=B8=8F?= =?UTF-8?q?=20(store.spec.ts):=20update=20API=20Key=20placeholder=20value?= =?UTF-8?q?=20to=20use=20environment=20variable=20instead=20of=20hardcodin?= =?UTF-8?q?g=20it=20=E2=99=BB=EF=B8=8F=20(store.spec.ts):=20update=20API?= =?UTF-8?q?=20Key=20placeholder=20value=20to=20use=20environment=20variabl?= =?UTF-8?q?e=20instead=20of=20hardcoding=20it=20=E2=99=BB=EF=B8=8F=20(stor?= =?UTF-8?q?e.spec.ts):=20update=20API=20Key=20placeholder=20value=20to=20u?= =?UTF-8?q?se=20environment=20variable=20instead=20of=20hardcoding=20it=20?= =?UTF-8?q?=E2=99=BB=EF=B8=8F=20(store.spec.ts):=20update=20API=20Key=20pl?= =?UTF-8?q?aceholder=20value=20to=20use=20environment=20variable=20instead?= =?UTF-8?q?=20of=20hardcoding=20it=20=E2=99=BB=EF=B8=8F=20(store.spec.ts):?= =?UTF-8?q?=20update=20API=20Key=20placeholder=20value=20to=20use=20enviro?= =?UTF-8?q?nment=20variable=20instead=20of=20hardcoding=20it=20=E2=99=BB?= =?UTF-8?q?=EF=B8=8F=20(store.spec.ts):=20update=20API=20Key=20placeholder?= =?UTF-8?q?=20value=20to=20use=20environment=20variable=20instead=20of=20h?= =?UTF-8?q?ardcoding=20it=20=E2=99=BB=EF=B8=8F=20(store.spec.ts):=20update?= =?UTF-8?q?=20API=20Key=20placeholder=20value=20to=20use=20environment=20v?= =?UTF-8?q?ariable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ✅ (tweaks_test.spec.ts): update selectors to use getByText instead of locator for better readability and maintainability --- .../end-to-end/deleteComponentFlows.spec.ts | 16 ++++++- .../tests/end-to-end/nestedComponent.spec.ts | 44 +------------------ .../tests/end-to-end/saveComponents.spec.ts | 5 +-- src/frontend/tests/end-to-end/store.spec.ts | 10 +++-- .../tests/end-to-end/tweaks_test.spec.ts | 8 ++-- 5 files changed, 26 insertions(+), 57 deletions(-) diff --git a/src/frontend/tests/end-to-end/deleteComponentFlows.spec.ts b/src/frontend/tests/end-to-end/deleteComponentFlows.spec.ts index ecb590aa9..7ca9c482c 100644 --- a/src/frontend/tests/end-to-end/deleteComponentFlows.spec.ts +++ b/src/frontend/tests/end-to-end/deleteComponentFlows.spec.ts @@ -4,6 +4,14 @@ test("shoud delete a flow", async ({ page }) => { await page.goto("/"); await page.waitForTimeout(2000); await page.getByText("Store").nth(0).click(); + + await page.getByText("API Key", { exact: true }).click(); + await page + .getByPlaceholder("Insert your API Key", { exact: true }) + .fill(process.env.STORE_API_KEY ?? ""); + await page.getByText("Save").last().click(); + await page.waitForTimeout(8000); + await page.getByTestId("install-Website Content QA").click(); await page.waitForTimeout(5000); await page.getByText("My Collection").nth(0).click(); @@ -16,7 +24,9 @@ test("shoud delete a flow", async ({ page }) => { await page.getByTestId("icon-Trash2").first().click(); await page.waitForTimeout(2000); }); - await page.getByText("Confirm deletion of component?").isVisible(); + await page + .getByText("Are you sure you want to delete the selected component?") + .isVisible(); await page.getByText("Delete").nth(1).click(); await page.waitForTimeout(1000); await page.getByText("Successfully").first().isVisible(); @@ -39,7 +49,9 @@ test("shoud delete a component", async ({ page }) => { await page.getByTestId("icon-Trash2").first().click(); await page.waitForTimeout(2000); }); - await page.getByText("Confirm deletion of component?").isVisible(); + await page + .getByText("Are you sure you want to delete the selected component?") + .isVisible(); await page.getByText("Delete").nth(1).click(); await page.waitForTimeout(1000); await page.getByText("Successfully").first().isVisible(); diff --git a/src/frontend/tests/end-to-end/nestedComponent.spec.ts b/src/frontend/tests/end-to-end/nestedComponent.spec.ts index a6b358f71..891229aaf 100644 --- a/src/frontend/tests/end-to-end/nestedComponent.spec.ts +++ b/src/frontend/tests/end-to-end/nestedComponent.spec.ts @@ -15,7 +15,7 @@ test("NestedComponent", async ({ page }) => { } while (modalCount === 0) { - await page.locator('//*[@id="new-project-btn"]').click(); + await page.getByText("New Project", { exact: true }).click(); await page.waitForTimeout(5000); modalCount = await page.getByTestId("modal-title")?.count(); } @@ -70,13 +70,6 @@ test("NestedComponent", async ({ page }) => { await page.locator('//*[@id="showpinecone_api_key"]').isChecked() ).toBeFalsy(); - // showpinecone_env - await page.locator('//*[@id="showpinecone_env"]').click(); - - expect( - await page.locator('//*[@id="showpinecone_env"]').isChecked() - ).toBeFalsy(); - // showindex_name await page.locator('//*[@id="showindex_name"]').click(); @@ -98,13 +91,6 @@ test("NestedComponent", async ({ page }) => { await page.locator('//*[@id="showpinecone_api_key"]').isChecked() ).toBeTruthy(); - // showpinecone_env - await page.locator('//*[@id="showpinecone_env"]').click(); - - expect( - await page.locator('//*[@id="showpinecone_env"]').isChecked() - ).toBeTruthy(); - // showindex_name await page.locator('//*[@id="showindex_name"]').click(); @@ -126,13 +112,6 @@ test("NestedComponent", async ({ page }) => { await page.locator('//*[@id="showpinecone_api_key"]').isChecked() ).toBeFalsy(); - // showpinecone_env - await page.locator('//*[@id="showpinecone_env"]').click(); - - expect( - await page.locator('//*[@id="showpinecone_env"]').isChecked() - ).toBeFalsy(); - // showindex_name await page.locator('//*[@id="showindex_name"]').click(); @@ -154,13 +133,6 @@ test("NestedComponent", async ({ page }) => { await page.locator('//*[@id="showpinecone_api_key"]').isChecked() ).toBeTruthy(); - // showpinecone_env - await page.locator('//*[@id="showpinecone_env"]').click(); - - expect( - await page.locator('//*[@id="showpinecone_env"]').isChecked() - ).toBeTruthy(); - // showindex_name await page.locator('//*[@id="showindex_name"]').click(); @@ -182,13 +154,6 @@ test("NestedComponent", async ({ page }) => { await page.locator('//*[@id="showpinecone_api_key"]').isChecked() ).toBeFalsy(); - // showpinecone_env - await page.locator('//*[@id="showpinecone_env"]').click(); - - expect( - await page.locator('//*[@id="showpinecone_env"]').isChecked() - ).toBeFalsy(); - // showindex_name await page.locator('//*[@id="showindex_name"]').click(); @@ -210,13 +175,6 @@ test("NestedComponent", async ({ page }) => { await page.locator('//*[@id="showpinecone_api_key"]').isChecked() ).toBeTruthy(); - // showpinecone_env - await page.locator('//*[@id="showpinecone_env"]').click(); - - expect( - await page.locator('//*[@id="showpinecone_env"]').isChecked() - ).toBeTruthy(); - //showpool_threads await page.locator('//*[@id="showpool_threads"]').click(); diff --git a/src/frontend/tests/end-to-end/saveComponents.spec.ts b/src/frontend/tests/end-to-end/saveComponents.spec.ts index b089abc9c..acd8a61e9 100644 --- a/src/frontend/tests/end-to-end/saveComponents.spec.ts +++ b/src/frontend/tests/end-to-end/saveComponents.spec.ts @@ -16,7 +16,7 @@ test.describe("save component tests", () => { } while (modalCount === 0) { - await page.locator('//*[@id="new-project-btn"]').click(); + await page.getByText("New Project", { exact: true }).click(); await page.waitForTimeout(5000); modalCount = await page.getByTestId("modal-title")?.count(); } @@ -61,9 +61,6 @@ test.describe("save component tests", () => { .locator('//*[@id="react-flow-id"]/div[1]/div[2]/button[3]') .click(); - await page.getByTestId("title-PythonFunctionTool").click({ - modifiers: ["Control"], - }); await page.getByTestId("title-ChatOpenAI").click({ modifiers: ["Control"], }); diff --git a/src/frontend/tests/end-to-end/store.spec.ts b/src/frontend/tests/end-to-end/store.spec.ts index 6e372c5b0..2eff8879a 100644 --- a/src/frontend/tests/end-to-end/store.spec.ts +++ b/src/frontend/tests/end-to-end/store.spec.ts @@ -144,7 +144,7 @@ test("should add API-KEY", async ({ page }) => { await page.getByTestId("api-key-button-store").click(); await page .getByPlaceholder("Insert your API Key") - .fill("x1fOKU0v2e5zL5d-BZW6CxZBZvoyuFgF"); + .fill(process.env.STORE_API_KEY ?? ""); await page.getByTestId("api-key-save-button-store").click(); await page.waitForTimeout(2000); @@ -165,7 +165,7 @@ test("should like and add components and flows", async ({ page }) => { await page .getByPlaceholder("Insert your API Key") - .fill("x1fOKU0v2e5zL5d-BZW6CxZBZvoyuFgF"); + .fill(process.env.STORE_API_KEY ?? ""); await page.getByTestId("api-key-save-button-store").click(); await page.waitForTimeout(2000); @@ -174,6 +174,8 @@ test("should like and add components and flows", async ({ page }) => { await page.waitForTimeout(2000); await page.getByText("API Key Error").isHidden(); + await page.waitForTimeout(5000); + const likedValue = await page .getByTestId("likes-Website Content QA") .innerText(); @@ -214,7 +216,7 @@ test("should like and add components and flows", async ({ page }) => { await page.getByText("My Collection").click(); await page.getByText("Website Content QA").first().isVisible(); - await page.getByTestId("sidebar-nav-Components").click(); + await page.getByText("Components").first().click(); await page.getByText("Basic RAG").first().isVisible(); }); @@ -233,7 +235,7 @@ test("should share component with share button", async ({ page }) => { } while (modalCount === 0) { - await page.locator('//*[@id="new-project-btn"]').click(); + await page.getByText("New Project", { exact: true }).click(); await page.waitForTimeout(5000); modalCount = await page.getByTestId("modal-title")?.count(); } diff --git a/src/frontend/tests/end-to-end/tweaks_test.spec.ts b/src/frontend/tests/end-to-end/tweaks_test.spec.ts index 55386fcae..7d29f9e4c 100644 --- a/src/frontend/tests/end-to-end/tweaks_test.spec.ts +++ b/src/frontend/tests/end-to-end/tweaks_test.spec.ts @@ -13,7 +13,7 @@ test("curl_api_generation", async ({ page, context }) => { } while (modalCount === 0) { - await page.locator('//*[@id="new-project-btn"]').click(); + await page.getByText("New Project", { exact: true }).click(); await page.waitForTimeout(5000); modalCount = await page.getByTestId("modal-title")?.count(); } @@ -24,7 +24,7 @@ test("curl_api_generation", async ({ page, context }) => { await page.getByRole("tab", { name: "cURL" }).click(); await page.getByRole("button", { name: "Copy Code" }).click(); const handle = await page.evaluateHandle(() => - navigator.clipboard.readText(), + navigator.clipboard.readText() ); const clipboardContent = await handle.jsonValue(); const oldValue = clipboardContent; @@ -50,7 +50,7 @@ test("curl_api_generation", async ({ page, context }) => { await page.getByRole("tab", { name: "cURL" }).click(); await page.getByRole("button", { name: "Copy Code" }).click(); const handle2 = await page.evaluateHandle(() => - navigator.clipboard.readText(), + navigator.clipboard.readText() ); const clipboardContent2 = await handle2.jsonValue(); const newValue = clipboardContent2; @@ -75,7 +75,7 @@ test("check if tweaks are updating when someothing on the flow changes", async ( } while (modalCount === 0) { - await page.locator('//*[@id="new-project-btn"]').click(); + await page.getByText("New Project", { exact: true }).click(); await page.waitForTimeout(5000); modalCount = await page.getByTestId("modal-title")?.count(); }