From 3a74df0a4a9d1cfe337fbd70032351b35c29aeb6 Mon Sep 17 00:00:00 2001 From: Sam Rose Date: Wed, 3 Jul 2024 17:04:31 +0100 Subject: [PATCH] Fix tests. --- packages/server/src/automations/tests/openai.spec.ts | 12 +++--------- .../server/src/tests/utilities/TestConfiguration.ts | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/packages/server/src/automations/tests/openai.spec.ts b/packages/server/src/automations/tests/openai.spec.ts index 44b410a0f1..6bebe16a49 100644 --- a/packages/server/src/automations/tests/openai.spec.ts +++ b/packages/server/src/automations/tests/openai.spec.ts @@ -43,9 +43,7 @@ describe("test the openai action", () => { it("should present the correct error message when the OPENAI_API_KEY variable isn't set", async () => { await config.withCoreEnv({ OPENAI_API_KEY: "" }, async () => { - let res = await runStep("OPENAI", { - prompt: OPENAI_PROMPT, - }) + let res = await runStep("OPENAI", { prompt: OPENAI_PROMPT }) expect(res.response).toEqual( "OpenAI API Key not configured - please add the OPENAI_API_KEY environment variable." ) @@ -54,17 +52,13 @@ describe("test the openai action", () => { }) it("should be able to receive a response from ChatGPT given a prompt", async () => { - const res = await runStep("OPENAI", { - prompt: OPENAI_PROMPT, - }) + const res = await runStep("OPENAI", { prompt: OPENAI_PROMPT }) expect(res.response).toEqual("This is a test") expect(res.success).toBeTruthy() }) it("should present the correct error message when a prompt is not provided", async () => { - const res = await runStep("OPENAI", { - prompt: null, - }) + const res = await runStep("OPENAI", { prompt: null }) expect(res.response).toEqual( "Budibase OpenAI Automation Failed: No prompt supplied" ) diff --git a/packages/server/src/tests/utilities/TestConfiguration.ts b/packages/server/src/tests/utilities/TestConfiguration.ts index 325d911f07..793bfa8c6a 100644 --- a/packages/server/src/tests/utilities/TestConfiguration.ts +++ b/packages/server/src/tests/utilities/TestConfiguration.ts @@ -290,7 +290,7 @@ export default class TestConfiguration { * that can be called to reset the environment variables to their original values. */ setCoreEnv(newEnvVars: Partial): () => void { - const oldEnv = cloneDeep(env) + const oldEnv = cloneDeep(coreEnv) let key: keyof typeof newEnvVars for (key in newEnvVars) {