From b645d17c878d55feb5e886c7c5e70f2436c22bab Mon Sep 17 00:00:00 2001 From: cristhianzl Date: Wed, 26 Jun 2024 20:30:27 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20(typescript=5Ftest.yml):=20add?= =?UTF-8?q?=20OPENAI=5FAPI=5FKEY=20to=20environment=20variables=20in=20CI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ✅ (basicExamples.spec.ts): refactor API key check to run at the start of tests --- .github/workflows/typescript_test.yml | 2 + .../tests/end-to-end/basicExamples.spec.ts | 40 +++++++++---------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/.github/workflows/typescript_test.yml b/.github/workflows/typescript_test.yml index 2f387393b..5b060f5e7 100644 --- a/.github/workflows/typescript_test.yml +++ b/.github/workflows/typescript_test.yml @@ -25,6 +25,8 @@ jobs: matrix: shardIndex: [1, 2, 3, 4, 5] shardTotal: [5] + env: + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} steps: - name: Checkout code uses: actions/checkout@v4 diff --git a/src/frontend/tests/end-to-end/basicExamples.spec.ts b/src/frontend/tests/end-to-end/basicExamples.spec.ts index 30f97a559..b4533a6f8 100644 --- a/src/frontend/tests/end-to-end/basicExamples.spec.ts +++ b/src/frontend/tests/end-to-end/basicExamples.spec.ts @@ -2,6 +2,11 @@ import { expect, test } from "@playwright/test"; import path from "path"; 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); + } + await page.goto("/"); await page.waitForTimeout(2000); @@ -32,11 +37,6 @@ test("Basic Prompting (Hello, World)", 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 ?? ""); @@ -90,6 +90,11 @@ test("Basic Prompting (Hello, World)", async ({ page }) => { }); 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); + } + await page.goto("/"); await page.waitForTimeout(2000); @@ -117,11 +122,6 @@ test("Memory Chatbot", 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 ?? ""); @@ -185,6 +185,11 @@ test("Memory Chatbot", async ({ page }) => { }); 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); + } + await page.goto("/"); await page.waitForTimeout(2000); @@ -212,11 +217,6 @@ test("Document QA", 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 ?? ""); @@ -279,6 +279,11 @@ test("Document QA", async ({ page }) => { }); 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); + } + await page.goto("/"); await page.waitForTimeout(2000); @@ -306,11 +311,6 @@ test("Blog Writer", 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 ?? "");