diff --git a/packages/backend-core/src/cache/appMetadata.ts b/packages/backend-core/src/cache/appMetadata.ts index 0c320ec776..420456fd41 100644 --- a/packages/backend-core/src/cache/appMetadata.ts +++ b/packages/backend-core/src/cache/appMetadata.ts @@ -55,7 +55,7 @@ export async function getAppMetadata(appId: string): Promise { throw err } } - // needed for cypress/some scenarios where the caching happens + // needed for some scenarios where the caching happens // so quickly the requests can get slightly out of sync // might store its invalid just before it stores its valid if (isInvalid(metadata)) { diff --git a/packages/backend-core/src/environment.ts b/packages/backend-core/src/environment.ts index 05fcbffd46..3894bdd0f7 100644 --- a/packages/backend-core/src/environment.ts +++ b/packages/backend-core/src/environment.ts @@ -2,15 +2,15 @@ import { existsSync, readFileSync } from "fs" import { ServiceType } from "@budibase/types" function isTest() { - return isCypress() || isJest() + return isJest() } function isJest() { - return !!(process.env.NODE_ENV === "jest" || process.env.JEST_WORKER_ID) -} - -function isCypress() { - return process.env.NODE_ENV === "cypress" + return ( + process.env.NODE_ENV === "jest" || + (process.env.JEST_WORKER_ID != null && + process.env.JEST_WORKER_ID !== "null") + ) } function isDev() { diff --git a/packages/server/src/environment.ts b/packages/server/src/environment.ts index 06fd659911..a1701535ce 100644 --- a/packages/server/src/environment.ts +++ b/packages/server/src/environment.ts @@ -3,28 +3,8 @@ import { ServiceType } from "@budibase/types" coreEnv._set("SERVICE_TYPE", ServiceType.APPS) import { join } from "path" -function isTest() { - return isCypress() || isJest() -} - -function isJest() { - return ( - process.env.NODE_ENV === "jest" || - (process.env.JEST_WORKER_ID != null && - process.env.JEST_WORKER_ID !== "null") - ) -} - -function isDev() { - return process.env.NODE_ENV !== "production" -} - -function isCypress() { - return process.env.NODE_ENV === "cypress" -} - let LOADED = false -if (!LOADED && isDev() && !isTest()) { +if (!LOADED && coreEnv.isDev() && !coreEnv.isTest()) { require("dotenv").config({ path: join(__dirname, "..", ".env"), }) @@ -93,12 +73,12 @@ const environment = { // @ts-ignore environment[key] = value }, - isTest, - isJest, - isCypress, - isDev, + isTest: coreEnv.isTest, + isJest: coreEnv.isJest, + + isDev: coreEnv.isDev, isProd: () => { - return !isDev() + return !coreEnv.isDev() }, isInThread: () => { return process.env.FORKED_PROCESS @@ -108,7 +88,7 @@ const environment = { } // threading can cause memory issues with node-ts in development -if (isDev() && environment.DISABLE_THREADING == null) { +if (coreEnv.isDev() && environment.DISABLE_THREADING == null) { environment._set("DISABLE_THREADING", "1") } diff --git a/packages/server/src/sdk/app/rows/search/internal.ts b/packages/server/src/sdk/app/rows/search/internal.ts index dfc5b7dcab..4cdeca87f6 100644 --- a/packages/server/src/sdk/app/rows/search/internal.ts +++ b/packages/server/src/sdk/app/rows/search/internal.ts @@ -34,11 +34,6 @@ import pick from "lodash/pick" export async function search(options: SearchParams) { const { tableId } = options - // Fetch the whole table when running in cypress, as search doesn't work - if (!env.COUCH_DB_URL && env.isCypress()) { - return { rows: await fetch(tableId) } - } - const { paginate, query } = options const params: InternalSearchParams = { diff --git a/packages/worker/src/api/controllers/system/environment.ts b/packages/worker/src/api/controllers/system/environment.ts index 729a00fa88..a63533e1bb 100644 --- a/packages/worker/src/api/controllers/system/environment.ts +++ b/packages/worker/src/api/controllers/system/environment.ts @@ -10,7 +10,6 @@ export const fetch = async (ctx: Ctx) => { accountPortalUrl: env.ACCOUNT_PORTAL_URL, disableAccountPortal: env.DISABLE_ACCOUNT_PORTAL, baseUrl: env.PLATFORM_URL, - // in test need to pretend its in production for the UI (Cypress) - isDev: env.isDev() && !env.isTest(), + isDev: env.isDev(), } } diff --git a/packages/worker/src/environment.ts b/packages/worker/src/environment.ts index c357ceb65b..2d5ecbd868 100644 --- a/packages/worker/src/environment.ts +++ b/packages/worker/src/environment.ts @@ -4,20 +4,8 @@ import { join } from "path" coreEnv._set("SERVICE_TYPE", ServiceType.WORKER) -function isDev() { - return process.env.NODE_ENV !== "production" -} - -function isTest() { - return ( - process.env.NODE_ENV === "jest" || - process.env.NODE_ENV === "cypress" || - process.env.JEST_WORKER_ID != null - ) -} - let LOADED = false -if (!LOADED && isDev() && !isTest()) { +if (!LOADED && coreEnv.isDev() && !coreEnv.isTest()) { require("dotenv").config({ path: join(__dirname, "..", ".env"), }) @@ -85,16 +73,16 @@ const environment = { // @ts-ignore environment[key] = value }, - isDev, - isTest, + isDev: coreEnv.isDev, + isTest: coreEnv.isTest, isProd: () => { - return !isDev() + return !coreEnv.isDev() }, } // if some var haven't been set, define them if (!environment.APPS_URL) { - environment.APPS_URL = isDev() + environment.APPS_URL = coreEnv.isDev() ? "http://localhost:4001" : "http://app-service:4002" }