From 6d27499475d416dbfc847d5a9c53fe57f1b10c53 Mon Sep 17 00:00:00 2001 From: Andrew Risse <52644157+andrewrisse@users.noreply.github.com> Date: Mon, 5 Aug 2024 08:22:47 -0600 Subject: [PATCH] chore(ui): improve reliability of playwright test in workflow --- .github/workflows/e2e-llama-cpp-python.yaml | 1 - .github/workflows/e2e-playwright.yaml | 1 - .github/workflows/e2e-text-embeddings.yaml | 1 - .github/workflows/e2e-vllm.yaml | 1 - .github/workflows/e2e-whisper.yaml | 1 - .github/workflows/lint.yaml | 1 - .github/workflows/pytest.yaml | 1 - .../src/routes/chat/(settings)/api-keys/+page.svelte | 1 + .../routes/chat/(settings)/file-management/+page.svelte | 1 + src/leapfrogai_ui/tests/api-keys.test.ts | 2 +- src/leapfrogai_ui/tests/file-management.test.ts | 8 ++++---- src/leapfrogai_ui/tests/helpers/fileHelpers.ts | 2 +- src/leapfrogai_ui/tests/helpers/helpers.ts | 5 ++++- 13 files changed, 12 insertions(+), 14 deletions(-) diff --git a/.github/workflows/e2e-llama-cpp-python.yaml b/.github/workflows/e2e-llama-cpp-python.yaml index d2f0c777c..91671539b 100644 --- a/.github/workflows/e2e-llama-cpp-python.yaml +++ b/.github/workflows/e2e-llama-cpp-python.yaml @@ -5,7 +5,6 @@ on: pull_request: types: - ready_for_review - - review_requested - synchronize - milestoned paths: diff --git a/.github/workflows/e2e-playwright.yaml b/.github/workflows/e2e-playwright.yaml index bf6524f9b..3c9ed5e4b 100644 --- a/.github/workflows/e2e-playwright.yaml +++ b/.github/workflows/e2e-playwright.yaml @@ -5,7 +5,6 @@ on: pull_request: types: - ready_for_review - - review_requested - synchronize - milestoned paths: diff --git a/.github/workflows/e2e-text-embeddings.yaml b/.github/workflows/e2e-text-embeddings.yaml index d601bf75c..c9788426a 100644 --- a/.github/workflows/e2e-text-embeddings.yaml +++ b/.github/workflows/e2e-text-embeddings.yaml @@ -5,7 +5,6 @@ on: pull_request: types: - ready_for_review - - review_requested - synchronize - milestoned paths: diff --git a/.github/workflows/e2e-vllm.yaml b/.github/workflows/e2e-vllm.yaml index 7c41a5fc2..94d81110b 100644 --- a/.github/workflows/e2e-vllm.yaml +++ b/.github/workflows/e2e-vllm.yaml @@ -5,7 +5,6 @@ on: pull_request: types: - ready_for_review - - review_requested - synchronize - milestoned paths: diff --git a/.github/workflows/e2e-whisper.yaml b/.github/workflows/e2e-whisper.yaml index 6b365f890..696e3a136 100644 --- a/.github/workflows/e2e-whisper.yaml +++ b/.github/workflows/e2e-whisper.yaml @@ -5,7 +5,6 @@ on: pull_request: types: - ready_for_review - - review_requested - synchronize - milestoned paths: diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 7450aa4ee..53be4a941 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -3,7 +3,6 @@ on: pull_request: types: - ready_for_review - - review_requested - synchronize - milestoned diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml index 3c53ca973..091dd3d45 100644 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -3,7 +3,6 @@ on: pull_request: types: - ready_for_review - - review_requested - synchronize - milestoned paths: diff --git a/src/leapfrogai_ui/src/routes/chat/(settings)/api-keys/+page.svelte b/src/leapfrogai_ui/src/routes/chat/(settings)/api-keys/+page.svelte index 621906058..8c4b4ad62 100644 --- a/src/leapfrogai_ui/src/routes/chat/(settings)/api-keys/+page.svelte +++ b/src/leapfrogai_ui/src/routes/chat/(settings)/api-keys/+page.svelte @@ -125,6 +125,7 @@
API Keys File Management
{ await page.getByRole('button', { name: 'Close', exact: true }).click({ force: true }); await expect(page.getByText('Save secret key')).not.toBeVisible(); - const row = await getTableRow(page, keyName); + const row = await getTableRow(page, keyName, 'api-keys-table'); await row.getByRole('checkbox').check(); const deleteBtn = page.getByRole('button', { name: 'delete' }); await deleteBtn.click(); diff --git a/src/leapfrogai_ui/tests/file-management.test.ts b/src/leapfrogai_ui/tests/file-management.test.ts index eb561ae51..e76b357d5 100644 --- a/src/leapfrogai_ui/tests/file-management.test.ts +++ b/src/leapfrogai_ui/tests/file-management.test.ts @@ -103,8 +103,8 @@ test('confirms any affected assistants then deletes multiple files', async ({ await expect(page.getByText(`${filename2} imported successfully`)).toBeVisible(); await expect(page.getByText(`${filename2} imported successfully`)).not.toBeVisible(); - const row1 = await getTableRow(page, filename1); - const row2 = await getTableRow(page, filename2); + const row1 = await getTableRow(page, filename1, 'file-management-table'); + const row2 = await getTableRow(page, filename2, 'file-management-table'); expect(row1).not.toBeNull(); expect(row2).not.toBeNull(); @@ -131,7 +131,7 @@ test('it cancels the delete confirmation modal', async ({ page, openAIClient }) await expect(page.getByText(`${filename} imported successfully`)).toBeVisible(); await expect(page.getByText(`${filename} imported successfully`)).not.toBeVisible(); // wait for upload to finish - const row = await getTableRow(page, filename); + const row = await getTableRow(page, filename, 'file-management-table'); await row.getByRole('checkbox').check(); await initiateDeletion(page, filename); @@ -169,7 +169,7 @@ test('shows an error toast when there is an error deleting a file', async ({ await expect(page.getByText(`${filename} imported successfully`)).toBeVisible(); await expect(page.getByText(`${filename} imported successfully`)).not.toBeVisible(); // wait for upload to finish - const row = await getTableRow(page, filename); + const row = await getTableRow(page, filename, 'file-management-table'); await row.getByRole('checkbox').check(); await initiateDeletion(page, filename); diff --git a/src/leapfrogai_ui/tests/helpers/fileHelpers.ts b/src/leapfrogai_ui/tests/helpers/fileHelpers.ts index 69ccee49c..14df9ea01 100644 --- a/src/leapfrogai_ui/tests/helpers/fileHelpers.ts +++ b/src/leapfrogai_ui/tests/helpers/fileHelpers.ts @@ -191,7 +191,7 @@ export const testFileUpload = async (filename: string, page: Page, openAIClient: await loadFileManagementPage(page); await uploadFile(page, filename); - const row = await getTableRow(page, filename); + const row = await getTableRow(page, filename, 'file-management-table'); expect(row).not.toBeNull(); const uploadingFileIcon = row!.getByTestId('uploading-file-spinner'); diff --git a/src/leapfrogai_ui/tests/helpers/helpers.ts b/src/leapfrogai_ui/tests/helpers/helpers.ts index f77fb0daa..cbed3fcf8 100644 --- a/src/leapfrogai_ui/tests/helpers/helpers.ts +++ b/src/leapfrogai_ui/tests/helpers/helpers.ts @@ -35,7 +35,10 @@ export const loadApiKeyPage = async (page: Page) => { await page.waitForURL('/chat/api-keys'); await expect(page).toHaveTitle('LeapfrogAI - API Keys'); }; -export const getTableRow = async (page: Page, textToSearchWith: string) => { +export const getTableRow = async (page: Page, textToSearchWith: string, tableTestId = '') => { + if (tableTestId) { + await expect(page.getByTestId(tableTestId).getByText(textToSearchWith)).toBeVisible(); + } const rows = page.locator('table tr'); let targetRow; for (let i = 0; i < (await rows.count()); i++) {