From 9c9d916d80c8fb3f8a073c221501c98e9947e51c Mon Sep 17 00:00:00 2001 From: Cristhian Zanforlin Lousa <72977554+Cristhianzl@users.noreply.github.com> Date: Fri, 19 Jul 2024 15:38:14 -0300 Subject: [PATCH] test: fix general test and CI (#2839) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ๐Ÿ”ง (typescript_test.yml): Remove unnecessary steps and conditions in GitHub Actions workflow file ๐Ÿ”ง (authContext.tsx): Update cookie key from LANGFLOW_ACCESS_TOKEN to LANGFLOW_API_TOKEN for consistency ๐Ÿ”ง (Basic Prompting.spec.ts): Update test to click on correct dropdown option ๐Ÿ”ง (filterEdge-shard-0.spec.ts): Update test to check for correct element ๐Ÿ”ง (filterSidebar.spec.ts): Update test to check for correct elements ๐Ÿ”ง (generalBugs-shard-5.spec.ts): Update test to interact with correct element ๐Ÿ”ง (inputComponent.spec.ts): Update test to interact with correct elements ๐Ÿ”ง (store-shard-1.spec.ts): Update test to interact with correct elements and remove unnecessary code --- .github/workflows/typescript_test.yml | 16 --------------- src/frontend/src/contexts/authContext.tsx | 2 +- .../tests/end-to-end/Basic Prompting.spec.ts | 2 +- .../end-to-end/filterEdge-shard-0.spec.ts | 2 +- .../tests/end-to-end/filterSidebar.spec.ts | 10 ++++------ .../end-to-end/generalBugs-shard-5.spec.ts | 7 ++++--- .../tests/end-to-end/inputComponent.spec.ts | 7 +------ .../tests/end-to-end/store-shard-1.spec.ts | 20 +++++++++++++++++++ 8 files changed, 32 insertions(+), 34 deletions(-) diff --git a/.github/workflows/typescript_test.yml b/.github/workflows/typescript_test.yml index 7778b0872..f0c131c7d 100644 --- a/.github/workflows/typescript_test.yml +++ b/.github/workflows/typescript_test.yml @@ -110,15 +110,8 @@ jobs: run: | cd src/frontend npx playwright test --trace on --shard ${{ matrix.shardIndex }}/${{ matrix.shardTotal }} --workers 2 - continue-on-error: true timeout-minutes: 12 - # If the test fails, set a flag to indicate that the shard failed - - name: Set failure flag - id: check-failure - if: failure() - run: echo "failed=true" >> "$GITHUB_OUTPUT" - - name: Upload blob report to GitHub Actions Artifacts if: always() uses: actions/upload-artifact@v4 @@ -130,7 +123,6 @@ jobs: merge-reports: needs: setup-and-test runs-on: ubuntu-latest - if: ${{ needs.setup-and-test.outputs.failed == 'true' }} steps: - name: Checkout code uses: actions/checkout@v4 @@ -157,11 +149,3 @@ jobs: name: html-report--attempt-${{ github.run_attempt }} path: playwright-report retention-days: 14 - delete-reports: - needs: setup-and-test - runs-on: ubuntu-latest - if: ${{ needs.setup-and-test.outputs.failed != 'true' }} - steps: - - uses: geekyeggo/delete-artifact@v5 - with: - name: blob-report-* diff --git a/src/frontend/src/contexts/authContext.tsx b/src/frontend/src/contexts/authContext.tsx index a4709c42b..9fa875339 100644 --- a/src/frontend/src/contexts/authContext.tsx +++ b/src/frontend/src/contexts/authContext.tsx @@ -126,7 +126,7 @@ export function AuthProvider({ children }): React.ReactElement { } function storeApiKey(apikey: string) { - cookies.set(LANGFLOW_ACCESS_TOKEN, apikey, { path: "/" }); + cookies.set(LANGFLOW_API_TOKEN, apikey, { path: "/" }); setApiKey(apikey); } diff --git a/src/frontend/tests/end-to-end/Basic Prompting.spec.ts b/src/frontend/tests/end-to-end/Basic Prompting.spec.ts index f4837d22c..12c962424 100644 --- a/src/frontend/tests/end-to-end/Basic Prompting.spec.ts +++ b/src/frontend/tests/end-to-end/Basic Prompting.spec.ts @@ -47,7 +47,7 @@ test("Basic Prompting (Hello, World)", async ({ page }) => { .fill(process.env.OPENAI_API_KEY ?? ""); await page.getByTestId("dropdown-model_name").click(); - await page.getByTestId("gpt-4o-0-option").click(); + await page.getByTestId("gpt-4o-1-option").click(); await page.waitForTimeout(2000); diff --git a/src/frontend/tests/end-to-end/filterEdge-shard-0.spec.ts b/src/frontend/tests/end-to-end/filterEdge-shard-0.spec.ts index 07322b752..6733e9020 100644 --- a/src/frontend/tests/end-to-end/filterEdge-shard-0.spec.ts +++ b/src/frontend/tests/end-to-end/filterEdge-shard-0.spec.ts @@ -170,7 +170,7 @@ test("RetrievalQA - Tooltip", async ({ page }) => { await visibleElementHandle.hover().then(async () => { await expect( - page.getByTestId("available-input-memories").first(), + page.getByTestId("available-input-helpers").first(), ).toBeVisible(); }); }); diff --git a/src/frontend/tests/end-to-end/filterSidebar.spec.ts b/src/frontend/tests/end-to-end/filterSidebar.spec.ts index 9b5273fbc..c07cffd4b 100644 --- a/src/frontend/tests/end-to-end/filterSidebar.spec.ts +++ b/src/frontend/tests/end-to-end/filterSidebar.spec.ts @@ -91,7 +91,7 @@ test("LLMChain - Filter", async ({ page }) => { await expect(page.getByTestId("dataAPI Request")).toBeVisible(); await expect(page.getByTestId("helpersChat Memory")).toBeVisible(); await expect(page.getByTestId("vectorstoresAstra DB")).toBeVisible(); - await expect(page.getByTestId("langchain_utilitiesSearchApi")).toBeVisible(); + await expect(page.getByTestId("toolsSearch API")).toBeVisible(); await expect(page.getByTestId("prototypesSub Flow")).toBeVisible(); await expect( page.getByTestId("retrieversSelf Query Retriever"), @@ -99,16 +99,14 @@ test("LLMChain - Filter", async ({ page }) => { await expect( page.getByTestId("textsplittersCharacterTextSplitter"), ).toBeVisible(); - await expect(page.getByTestId("toolsSearchApi")).toBeVisible(); + await expect(page.getByTestId("toolsSearch API")).toBeVisible(); await page.getByPlaceholder("Search").click(); await expect(page.getByTestId("dataAPI Request")).not.toBeVisible(); await expect(page.getByTestId("helpersChat Memory")).not.toBeVisible(); await expect(page.getByTestId("vectorstoresAstra DB")).not.toBeVisible(); - await expect( - page.getByTestId("langchain_utilitiesSearchApi"), - ).not.toBeVisible(); + await expect(page.getByTestId("toolsSearch API")).not.toBeVisible(); await expect(page.getByTestId("prototypesSub Flow")).not.toBeVisible(); await expect( page.getByTestId("retrieversSelf Query Retriever"), @@ -116,5 +114,5 @@ test("LLMChain - Filter", async ({ page }) => { await expect( page.getByTestId("textsplittersCharacterTextSplitter"), ).not.toBeVisible(); - await expect(page.getByTestId("toolsSearchApi")).not.toBeVisible(); + await expect(page.getByTestId("toolsSearch API")).not.toBeVisible(); }); diff --git a/src/frontend/tests/end-to-end/generalBugs-shard-5.spec.ts b/src/frontend/tests/end-to-end/generalBugs-shard-5.spec.ts index b41a411b7..f0319244f 100644 --- a/src/frontend/tests/end-to-end/generalBugs-shard-5.spec.ts +++ b/src/frontend/tests/end-to-end/generalBugs-shard-5.spec.ts @@ -218,10 +218,11 @@ test("should be able to see output preview from grouped components", async ({ await page.getByTestId("button_run_text output").last().click(); - await page.waitForSelector("text=Text Output built successfully", { - timeout: 30000, - }); + await page.waitForSelector("text=built successfully", { timeout: 30000 }); + await page.getByText("built successfully").last().click({ + timeout: 15000, + }); await page.waitForTimeout(3000); expect( diff --git a/src/frontend/tests/end-to-end/inputComponent.spec.ts b/src/frontend/tests/end-to-end/inputComponent.spec.ts index 0ea77b473..07ea32451 100644 --- a/src/frontend/tests/end-to-end/inputComponent.spec.ts +++ b/src/frontend/tests/end-to-end/inputComponent.spec.ts @@ -130,11 +130,11 @@ test("InputComponent", async ({ page }) => { expect(false).toBeTruthy(); } - await page.getByTestId("popover-anchor-input-collection_name-edit").click(); await page .getByTestId("popover-anchor-input-collection_name-edit") .fill("NEW_collection_name_test_123123123!@#$&*(&%$@ร‡ร‡ร‡ร€รตe"); + await page.waitForTimeout(1000); await page.getByText("Close").last().click(); const plusButtonLocator = page.getByTestId("input-collection_name"); @@ -147,11 +147,6 @@ test("InputComponent", async ({ page }) => { await page.getByTestId("more-options-modal").click(); await page.getByTestId("edit-button-modal").click(); - await page.locator('//*[@id="showcollection_name"]').click(); - expect( - await page.locator('//*[@id="showcollection_name"]').isChecked(), - ).toBeTruthy(); - await page.getByText("Close").last().click(); let value = await page diff --git a/src/frontend/tests/end-to-end/store-shard-1.spec.ts b/src/frontend/tests/end-to-end/store-shard-1.spec.ts index 5b1d4e5be..6deebf10a 100644 --- a/src/frontend/tests/end-to-end/store-shard-1.spec.ts +++ b/src/frontend/tests/end-to-end/store-shard-1.spec.ts @@ -15,6 +15,26 @@ test("should like and add components and flows", 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 Project", { exact: true }).click(); + await page.waitForTimeout(5000); + modalCount = await page.getByTestId("modal-title")?.count(); + } + + await page.getByText("Close", { exact: true }).click(); + + await page.waitForTimeout(1000); + await page.getByTestId("button-store").click(); await page.waitForTimeout(1000);