From 2787bec4fb715f48a0903fbf3103999d6375e9ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Boschi?= Date: Tue, 2 Jul 2024 15:20:13 +0200 Subject: [PATCH] ci: skip tests with openai key required (#2477) * ci: skip tests with openai key required * ci: skip tests with openai key required * ci: skip tests with openai key required * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- .github/workflows/python_test.yml | 2 +- src/frontend/tests/end-to-end/Basic Prompting.spec.ts | 8 ++++---- src/frontend/tests/end-to-end/Blog Writer.spec.ts | 8 ++++---- src/frontend/tests/end-to-end/Document QA.spec.ts | 8 ++++---- src/frontend/tests/end-to-end/Memory Chatbot.spec.ts | 8 ++++---- .../tests/end-to-end/chatInputOutputUser-shard-0.spec.ts | 9 ++++----- .../tests/end-to-end/chatInputOutputUser-shard-1.spec.ts | 9 ++++----- .../tests/end-to-end/chatInputOutputUser-shard-2.spec.ts | 9 ++++----- src/frontend/tests/end-to-end/decisionFlow.spec.ts | 9 ++++----- .../tests/end-to-end/generalBugs-shard-0.spec.ts | 9 ++++----- .../tests/end-to-end/generalBugs-shard-1.spec.ts | 8 ++++---- .../tests/end-to-end/generalBugs-shard-2.spec.ts | 8 ++++---- .../tests/end-to-end/generalBugs-shard-3.spec.ts | 8 ++++---- src/frontend/tests/end-to-end/textInputOutput.spec.ts | 9 ++++----- tests/test_endpoints.py | 7 +++++++ 15 files changed, 60 insertions(+), 59 deletions(-) diff --git a/.github/workflows/python_test.yml b/.github/workflows/python_test.yml index e6db706e8..623f87404 100644 --- a/.github/workflows/python_test.yml +++ b/.github/workflows/python_test.yml @@ -37,7 +37,7 @@ jobs: poetry install - name: Run unit tests run: | - make unit_tests args="-n auto" + make unit_tests - name: Test CLI run: | poetry run python -m langflow run --host 127.0.0.1 --port 7860 --backend-only & 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 aff45928c..47b2aff23 100644 --- a/src/frontend/tests/end-to-end/Basic Prompting.spec.ts +++ b/src/frontend/tests/end-to-end/Basic Prompting.spec.ts @@ -1,10 +1,10 @@ import { expect, test } from "@playwright/test"; test("Basic Prompting (Hello, World)", 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); - } + test.skip( + !process?.env?.OPENAI_API_KEY, + "OPENAI_API_KEY required to run this test", + ); await page.goto("/"); await page.waitForTimeout(2000); diff --git a/src/frontend/tests/end-to-end/Blog Writer.spec.ts b/src/frontend/tests/end-to-end/Blog Writer.spec.ts index 68c6c0bf3..b0cbfbec1 100644 --- a/src/frontend/tests/end-to-end/Blog Writer.spec.ts +++ b/src/frontend/tests/end-to-end/Blog Writer.spec.ts @@ -2,10 +2,10 @@ import { expect, test } from "@playwright/test"; import path from "path"; test("Blog Writer", 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); - } + test.skip( + !process?.env?.OPENAI_API_KEY, + "OPENAI_API_KEY required to run this test", + ); await page.goto("/"); await page.waitForTimeout(2000); diff --git a/src/frontend/tests/end-to-end/Document QA.spec.ts b/src/frontend/tests/end-to-end/Document QA.spec.ts index 03ff442df..682c71d6e 100644 --- a/src/frontend/tests/end-to-end/Document QA.spec.ts +++ b/src/frontend/tests/end-to-end/Document QA.spec.ts @@ -2,10 +2,10 @@ import { expect, test } from "@playwright/test"; import path from "path"; test("Document QA", 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); - } + test.skip( + !process?.env?.OPENAI_API_KEY, + "OPENAI_API_KEY required to run this test", + ); await page.goto("/"); await page.waitForTimeout(2000); diff --git a/src/frontend/tests/end-to-end/Memory Chatbot.spec.ts b/src/frontend/tests/end-to-end/Memory Chatbot.spec.ts index 861cc6d0f..86103469d 100644 --- a/src/frontend/tests/end-to-end/Memory Chatbot.spec.ts +++ b/src/frontend/tests/end-to-end/Memory Chatbot.spec.ts @@ -2,10 +2,10 @@ import { expect, test } from "@playwright/test"; import path from "path"; test("Memory Chatbot", 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); - } + test.skip( + !process?.env?.OPENAI_API_KEY, + "OPENAI_API_KEY required to run this test", + ); await page.goto("/"); await page.waitForTimeout(2000); 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 72c451c10..1a8eedb45 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 @@ -7,6 +7,10 @@ test("user must be able to send an image on chat", async ({ page }) => { if (!process.env.CI) { dotenv.config({ path: path.resolve(__dirname, "../../.env") }); } + test.skip( + !process?.env?.OPENAI_API_KEY, + "OPENAI_API_KEY required to run this test", + ); await page.goto("/"); @@ -38,11 +42,6 @@ test("user must be able to send an image on chat", async ({ page }) => { await page.getByTitle("zoom out").click(); await page.getByTitle("zoom out").click(); - 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 .getByTestId("popover-anchor-input-openai_api_key") .fill(process.env.OPENAI_API_KEY ?? ""); diff --git a/src/frontend/tests/end-to-end/chatInputOutputUser-shard-1.spec.ts b/src/frontend/tests/end-to-end/chatInputOutputUser-shard-1.spec.ts index 50fbdba0a..d9d6a2933 100644 --- a/src/frontend/tests/end-to-end/chatInputOutputUser-shard-1.spec.ts +++ b/src/frontend/tests/end-to-end/chatInputOutputUser-shard-1.spec.ts @@ -7,6 +7,10 @@ test("user must be able to see output inspection", async ({ page }) => { if (!process.env.CI) { dotenv.config({ path: path.resolve(__dirname, "../../.env") }); } + test.skip( + !process?.env?.OPENAI_API_KEY, + "OPENAI_API_KEY required to run this test", + ); await page.goto("/"); @@ -38,11 +42,6 @@ test("user must be able to see output inspection", async ({ page }) => { await page.getByTitle("zoom out").click(); await page.getByTitle("zoom out").click(); - 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 .getByTestId("popover-anchor-input-openai_api_key") .fill(process.env.OPENAI_API_KEY ?? ""); diff --git a/src/frontend/tests/end-to-end/chatInputOutputUser-shard-2.spec.ts b/src/frontend/tests/end-to-end/chatInputOutputUser-shard-2.spec.ts index 8f77262ba..afbedca30 100644 --- a/src/frontend/tests/end-to-end/chatInputOutputUser-shard-2.spec.ts +++ b/src/frontend/tests/end-to-end/chatInputOutputUser-shard-2.spec.ts @@ -7,6 +7,10 @@ test("user must interact with chat with Input/Output", async ({ page }) => { if (!process.env.CI) { dotenv.config({ path: path.resolve(__dirname, "../../.env") }); } + test.skip( + !process?.env?.OPENAI_API_KEY, + "OPENAI_API_KEY required to run this test", + ); await page.goto("/"); @@ -38,11 +42,6 @@ test("user must interact with chat with Input/Output", async ({ page }) => { await page.getByTitle("zoom out").click(); await page.getByTitle("zoom out").click(); - 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 .getByTestId("popover-anchor-input-openai_api_key") .fill(process.env.OPENAI_API_KEY ?? ""); diff --git a/src/frontend/tests/end-to-end/decisionFlow.spec.ts b/src/frontend/tests/end-to-end/decisionFlow.spec.ts index 7d15bfff2..d275e43a8 100644 --- a/src/frontend/tests/end-to-end/decisionFlow.spec.ts +++ b/src/frontend/tests/end-to-end/decisionFlow.spec.ts @@ -1,6 +1,10 @@ import { expect, test } from "@playwright/test"; test("should create a flow with decision", async ({ page }) => { + test.skip( + !process?.env?.OPENAI_API_KEY, + "OPENAI_API_KEY required to run this test", + ); await page.goto("/"); await page.locator("span").filter({ hasText: "My Collection" }).isVisible(); await page.waitForTimeout(2000); @@ -536,11 +540,6 @@ AI: await page.locator('//*[@id="react-flow-id"]').hover(); - 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 .getByTestId("popover-anchor-input-openai_api_key") .fill(process.env.OPENAI_API_KEY ?? ""); diff --git a/src/frontend/tests/end-to-end/generalBugs-shard-0.spec.ts b/src/frontend/tests/end-to-end/generalBugs-shard-0.spec.ts index 77d90bd3e..be387f18b 100644 --- a/src/frontend/tests/end-to-end/generalBugs-shard-0.spec.ts +++ b/src/frontend/tests/end-to-end/generalBugs-shard-0.spec.ts @@ -46,6 +46,10 @@ test("erase button should clear the chat messages", async ({ page }) => { if (!process.env.CI) { dotenv.config({ path: path.resolve(__dirname, "../../.env") }); } + test.skip( + !process?.env?.OPENAI_API_KEY, + "OPENAI_API_KEY required to run this test", + ); await page.goto("/"); @@ -75,11 +79,6 @@ test("erase button should clear the chat messages", async ({ page }) => { await page.getByTitle("zoom out").click(); await page.getByTitle("zoom out").click(); - 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 .getByTestId("popover-anchor-input-openai_api_key") .fill(process.env.OPENAI_API_KEY ?? ""); 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 index bd4c72e28..f2fafcc08 100644 --- a/src/frontend/tests/end-to-end/generalBugs-shard-1.spec.ts +++ b/src/frontend/tests/end-to-end/generalBugs-shard-1.spec.ts @@ -3,10 +3,10 @@ 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); - } + test.skip( + !process?.env?.OPENAI_API_KEY, + "OPENAI_API_KEY required to run this test", + ); await page.goto("/"); await page.waitForTimeout(2000); diff --git a/src/frontend/tests/end-to-end/generalBugs-shard-2.spec.ts b/src/frontend/tests/end-to-end/generalBugs-shard-2.spec.ts index fb5f5129b..4da6c3e30 100644 --- a/src/frontend/tests/end-to-end/generalBugs-shard-2.spec.ts +++ b/src/frontend/tests/end-to-end/generalBugs-shard-2.spec.ts @@ -1,10 +1,10 @@ import { expect, test } from "@playwright/test"; test("should use webhook component on API", 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); - } + test.skip( + !process?.env?.OPENAI_API_KEY, + "OPENAI_API_KEY required to run this test", + ); await page.goto("/"); await page.waitForTimeout(2000); diff --git a/src/frontend/tests/end-to-end/generalBugs-shard-3.spec.ts b/src/frontend/tests/end-to-end/generalBugs-shard-3.spec.ts index 445c870d3..cbcd9f671 100644 --- a/src/frontend/tests/end-to-end/generalBugs-shard-3.spec.ts +++ b/src/frontend/tests/end-to-end/generalBugs-shard-3.spec.ts @@ -80,10 +80,10 @@ test("should copy code from playground modal", async ({ page }) => { await page.getByTitle("zoom out").click(); await page.getByTitle("zoom out").click(); - if (!process?.env?.OPENAI_API_KEY) { - //You must set the OPENAI_API_KEY on .env file to run this test - expect(false).toBe(true); - } + test.skip( + !process?.env?.OPENAI_API_KEY, + "OPENAI_API_KEY required to run this test", + ); await page .getByTestId("popover-anchor-input-openai_api_key") diff --git a/src/frontend/tests/end-to-end/textInputOutput.spec.ts b/src/frontend/tests/end-to-end/textInputOutput.spec.ts index dc7e8c2d5..f7ca18684 100644 --- a/src/frontend/tests/end-to-end/textInputOutput.spec.ts +++ b/src/frontend/tests/end-to-end/textInputOutput.spec.ts @@ -6,6 +6,10 @@ test("TextInputOutputComponent", async ({ page }) => { if (!process.env.CI) { dotenv.config({ path: path.resolve(__dirname, "../../.env") }); } + test.skip( + !process?.env?.OPENAI_API_KEY, + "OPENAI_API_KEY required to run this test", + ); await page.goto("/"); await page.waitForTimeout(2000); @@ -171,11 +175,6 @@ test("TextInputOutputComponent", async ({ page }) => { // Release the mouse await page.mouse.up(); - 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 .getByTestId("popover-anchor-input-input_value") .nth(0) diff --git a/tests/test_endpoints.py b/tests/test_endpoints.py index d1c72f938..519d792a5 100644 --- a/tests/test_endpoints.py +++ b/tests/test_endpoints.py @@ -426,6 +426,7 @@ def test_build_vertex_invalid_vertex_id(client, added_flow_with_prompt_and_histo assert response.status_code == 500 +@pytest.mark.api_key_required def test_successful_run_no_payload(client, starter_project, created_api_key): headers = {"x-api-key": created_api_key.api_key} flow_id = starter_project["id"] @@ -454,6 +455,7 @@ def test_successful_run_no_payload(client, starter_project, created_api_key): assert all([result is not None for result in inner_results]), (outputs_dict, output_results_has_results) +@pytest.mark.api_key_required def test_successful_run_with_output_type_text(client, starter_project, created_api_key): headers = {"x-api-key": created_api_key.api_key} flow_id = starter_project["id"] @@ -484,6 +486,7 @@ def test_successful_run_with_output_type_text(client, starter_project, created_a assert all([key in result for result in inner_results for key in expected_keys]), outputs_dict +@pytest.mark.api_key_required def test_successful_run_with_output_type_any(client, starter_project, created_api_key): # This one should have both the ChatOutput and TextOutput components headers = {"x-api-key": created_api_key.api_key} @@ -515,6 +518,7 @@ def test_successful_run_with_output_type_any(client, starter_project, created_ap assert all([key in result for result in inner_results for key in expected_keys]), outputs_dict +@pytest.mark.api_key_required def test_successful_run_with_output_type_debug(client, starter_project, created_api_key): # This one should return outputs for all components # Let's just check the amount of outputs(there should be 7) @@ -540,6 +544,7 @@ def test_successful_run_with_output_type_debug(client, starter_project, created_ assert len(outputs_dict.get("outputs")) == 4 +@pytest.mark.api_key_required # To test input_type wel'l just set it with output_type debug and check if the value is correct def test_successful_run_with_input_type_text(client, starter_project, created_api_key): headers = {"x-api-key": created_api_key.api_key} @@ -572,6 +577,7 @@ def test_successful_run_with_input_type_text(client, starter_project, created_ap # Now do the same for "chat" input type +@pytest.mark.api_key_required def test_successful_run_with_input_type_chat(client, starter_project, created_api_key): headers = {"x-api-key": created_api_key.api_key} flow_id = starter_project["id"] @@ -604,6 +610,7 @@ def test_successful_run_with_input_type_chat(client, starter_project, created_ap ), chat_input_outputs +@pytest.mark.api_key_required def test_successful_run_with_input_type_any(client, starter_project, created_api_key): headers = {"x-api-key": created_api_key.api_key} flow_id = starter_project["id"]