From 4b6cbe47fc74586d765881df6ed7521757eff800 Mon Sep 17 00:00:00 2001 From: cristhianzl Date: Fri, 28 Jun 2024 11:33:01 -0300 Subject: [PATCH 1/8] =?UTF-8?q?=F0=9F=90=9B=20(messagesPage):=20fix=20sele?= =?UTF-8?q?ction=20mapping=20to=20use=20row.id=20instead=20of=20row.index?= =?UTF-8?q?=20=E2=9C=85=20(tests):=20add=20end-to-end=20tests=20for=20basi?= =?UTF-8?q?c=20prompting=20and=20general=20bugs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ✅ (tests): add end-to-end test for deleting rows from table message 🔧 (tsconfig.json): update test file name for generalBugs to shard-0 spec --- .../SettingsPage/pages/messagesPage/index.tsx | 4 +- ...c Prompting.ts => Basic Prompting.spec.ts} | 15 +++- ...gs.spec.ts => generalBugs-shard-0.spec.ts} | 0 .../end-to-end/generalBugs-shard-1.spec.ts | 89 +++++++++++++++++++ src/frontend/tsconfig.json | 2 +- 5 files changed, 102 insertions(+), 8 deletions(-) rename src/frontend/tests/end-to-end/{Basic Prompting.ts => Basic Prompting.spec.ts} (92%) rename src/frontend/tests/end-to-end/{generalBugs.spec.ts => generalBugs-shard-0.spec.ts} (100%) create mode 100644 src/frontend/tests/end-to-end/generalBugs-shard-1.spec.ts diff --git a/src/frontend/src/pages/SettingsPage/pages/messagesPage/index.tsx b/src/frontend/src/pages/SettingsPage/pages/messagesPage/index.tsx index c3172f152..c908f79a4 100644 --- a/src/frontend/src/pages/SettingsPage/pages/messagesPage/index.tsx +++ b/src/frontend/src/pages/SettingsPage/pages/messagesPage/index.tsx @@ -66,9 +66,7 @@ export default function MessagesPage() { ]} overlayNoRowsTemplate="No data available" onSelectionChanged={(event: SelectionChangedEvent) => { - setSelectedRows( - event.api.getSelectedRows().map((row) => row.index), - ); + setSelectedRows(event.api.getSelectedRows().map((row) => row.id)); }} rowSelection="multiple" suppressRowClickSelection={true} diff --git a/src/frontend/tests/end-to-end/Basic Prompting.ts b/src/frontend/tests/end-to-end/Basic Prompting.spec.ts similarity index 92% rename from src/frontend/tests/end-to-end/Basic Prompting.ts rename to src/frontend/tests/end-to-end/Basic Prompting.spec.ts index 0fdb56e41..aff45928c 100644 --- a/src/frontend/tests/end-to-end/Basic Prompting.ts +++ b/src/frontend/tests/end-to-end/Basic Prompting.spec.ts @@ -1,5 +1,4 @@ import { expect, test } from "@playwright/test"; -import path from "path"; test("Basic Prompting (Hello, World)", async ({ page }) => { if (!process?.env?.OPENAI_API_KEY) { @@ -67,10 +66,18 @@ test("Basic Prompting (Hello, World)", async ({ page }) => { .getByTestId("input-chat-playground") .last() .fill("Say hello as a pirate"); - await page.getByTestId("icon-LucideSend").last().click(); - await page.waitForTimeout(3000); - await page.getByText("Ahoy").last().isVisible(); + await page.waitForSelector('[data-testid="icon-LucideSend"]', { + timeout: 100000, + }); + + await page.getByTestId("icon-LucideSend").last().click(); + + await page.waitForSelector("text=matey", { + timeout: 100000, + }); + + await page.getByText("matey").last().isVisible(); await page.getByText("Default Session").last().click(); await page.getByText("timestamp", { exact: true }).last().isVisible(); diff --git a/src/frontend/tests/end-to-end/generalBugs.spec.ts b/src/frontend/tests/end-to-end/generalBugs-shard-0.spec.ts similarity index 100% rename from src/frontend/tests/end-to-end/generalBugs.spec.ts rename to src/frontend/tests/end-to-end/generalBugs-shard-0.spec.ts diff --git a/src/frontend/tests/end-to-end/generalBugs-shard-1.spec.ts b/src/frontend/tests/end-to-end/generalBugs-shard-1.spec.ts new file mode 100644 index 000000000..bd4c72e28 --- /dev/null +++ b/src/frontend/tests/end-to-end/generalBugs-shard-1.spec.ts @@ -0,0 +1,89 @@ +import { expect, test } from "@playwright/test"; +import * as dotenv from "dotenv"; +import path from "path"; + +test("should delete rows from table message", async ({ page }) => { + if (!process?.env?.OPENAI_API_KEY) { + //You must set the OPENAI_API_KEY on .env file to run this test + expect(false).toBe(true); + } + + 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 Project", { exact: true }).click(); + await page.waitForTimeout(5000); + modalCount = await page.getByTestId("modal-title")?.count(); + } + + await page.getByRole("heading", { name: "Basic Prompting" }).click(); + + await page.waitForSelector('[title="fit view"]', { + timeout: 100000, + }); + + await page.getByTitle("fit view").click(); + await page.getByTitle("zoom out").click(); + await page.getByTitle("zoom out").click(); + await page.getByTitle("zoom out").click(); + + await page + .getByTestId("popover-anchor-input-openai_api_key") + .fill(process.env.OPENAI_API_KEY ?? ""); + + await page.getByTestId("dropdown-model_name").click(); + await page.getByTestId("gpt-4o-0-option").click(); + + await page.waitForTimeout(2000); + + await page.getByTestId("button_run_chat output").click(); + await page.waitForSelector("text=built successfully", { timeout: 30000 }); + + await page.getByText("built successfully").last().click({ + timeout: 15000, + }); + + await page.getByText("Playground", { exact: true }).click(); + await page + .getByText("No input message provided.", { exact: true }) + .last() + .isVisible(); + + await page.waitForSelector('[data-testid="input-chat-playground"]', { + timeout: 100000, + }); + + await page + .getByTestId("input-chat-playground") + .last() + .fill("Say hello as a pirate"); + await page.getByTestId("icon-LucideSend").last().click(); + + await page.waitForSelector("text=matey", { + timeout: 100000, + }); + + await page.getByText("Close").last().click(); + await page.getByTestId("user-profile-settings").last().click(); + await page.getByText("Settings").last().click(); + await page.getByText("Messages").last().click(); + + const label = "Press Space to toggle all rows selection (unchecked)"; + await page.getByLabel(label).first().click(); + + await page.getByTestId("icon-Trash2").first().click(); + + await page.waitForSelector("text=No Data Available", { timeout: 30000 }); + await page.getByText("No Data Available").isVisible(); +}); diff --git a/src/frontend/tsconfig.json b/src/frontend/tsconfig.json index d713c77f7..28cdcd18b 100644 --- a/src/frontend/tsconfig.json +++ b/src/frontend/tsconfig.json @@ -34,7 +34,7 @@ "tests/end-to-end/floatComponent.spec.ts", "tests/end-to-end/flowPage.spec.ts", "tests/end-to-end/flowSettings.spec.ts", - "tests/end-to-end/generalBugs.spec.ts", + "tests/end-to-end/generalBugs-shard-0.spec.ts", "tests/end-to-end/globalVariables.spec.ts", "tests/end-to-end/group.spec.ts", "tests/end-to-end/folders.spec.ts", From 8eae1cd8a85a8fd0a831bc786c894eb56adbd830 Mon Sep 17 00:00:00 2001 From: cristhianzl Date: Fri, 28 Jun 2024 12:03:54 -0300 Subject: [PATCH 2/8] added rerun tests --- .../tests/end-to-end/chatInputOutputUser-shard-0.spec.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/frontend/tests/end-to-end/chatInputOutputUser-shard-0.spec.ts b/src/frontend/tests/end-to-end/chatInputOutputUser-shard-0.spec.ts index 690a3b805..72c451c10 100644 --- a/src/frontend/tests/end-to-end/chatInputOutputUser-shard-0.spec.ts +++ b/src/frontend/tests/end-to-end/chatInputOutputUser-shard-0.spec.ts @@ -80,6 +80,10 @@ test("user must be able to send an image on chat", async ({ page }) => { { fileContent }, ); + await page.waitForSelector('[data-testid="input-chat-playground"]', { + timeout: 100000, + }); + // Locate the target element const element = await page.getByTestId("input-chat-playground"); From 224d447f6b40d7e2cf16f5ce0af06528fc2da76f Mon Sep 17 00:00:00 2001 From: cristhianzl Date: Fri, 28 Jun 2024 12:05:48 -0300 Subject: [PATCH 3/8] chore: Add branch input parameter to Frontend Tests workflow --- .github/workflows/typescript_test.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/typescript_test.yml b/.github/workflows/typescript_test.yml index 8b91001ca..13a2259b6 100644 --- a/.github/workflows/typescript_test.yml +++ b/.github/workflows/typescript_test.yml @@ -1,6 +1,12 @@ name: Run Frontend Tests on: + workflow_dispatch: + inputs: + branch: + description: "Branch to run tests on" + required: true + type: string pull_request: merge_group: @@ -19,8 +25,8 @@ jobs: strategy: fail-fast: false matrix: - shardIndex: [1, 2, 3, 4, 5, 6, 7, 8] - shardTotal: [8] + shardIndex: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] + shardTotal: [10] env: OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} STORE_API_KEY: ${{ secrets.STORE_API_KEY }} From 17165a00d3de87912a642ae28eceeb3a4e1e1b1a Mon Sep 17 00:00:00 2001 From: cristhianzl Date: Fri, 28 Jun 2024 14:26:10 -0300 Subject: [PATCH 4/8] remove console.log --- src/frontend/src/modals/IOModal/components/SessionView/index.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/frontend/src/modals/IOModal/components/SessionView/index.tsx b/src/frontend/src/modals/IOModal/components/SessionView/index.tsx index 70174ee72..21b64cfb1 100644 --- a/src/frontend/src/modals/IOModal/components/SessionView/index.tsx +++ b/src/frontend/src/modals/IOModal/components/SessionView/index.tsx @@ -52,7 +52,6 @@ export default function SessionView({ rows }: { rows: Array }) { ]} overlayNoRowsTemplate="No data available" onSelectionChanged={(event: SelectionChangedEvent) => { - console.log(event.api.getSelectedRows()); setSelectedRows(event.api.getSelectedRows().map((row) => row.id)); }} rowSelection="multiple" From 356905c38370f6afa8a3374ce10d8b645b4ef960 Mon Sep 17 00:00:00 2001 From: cristhianzl Date: Fri, 28 Jun 2024 15:03:32 -0300 Subject: [PATCH 5/8] test webhook --- .../components/codeTabsComponent/index.tsx | 4 +- .../end-to-end/generalBugs-shard-2.spec.ts | 56 ++++++++++++ .../end-to-end/generalBugs-shard-3.spec.ts | 89 +++++++++++++++++++ 3 files changed, 147 insertions(+), 2 deletions(-) create mode 100644 src/frontend/tests/end-to-end/generalBugs-shard-2.spec.ts create mode 100644 src/frontend/tests/end-to-end/generalBugs-shard-3.spec.ts diff --git a/src/frontend/src/components/codeTabsComponent/index.tsx b/src/frontend/src/components/codeTabsComponent/index.tsx index 4b22ac11e..c96e57264 100644 --- a/src/frontend/src/components/codeTabsComponent/index.tsx +++ b/src/frontend/src/components/codeTabsComponent/index.tsx @@ -147,7 +147,7 @@ export default function CodeTabsComponent({ )} - {Number(activeTab) < 5 && ( + {Number(activeTab) < 6 && ( <>