Clean cypress refs
This commit is contained in:
parent
0f9552560b
commit
205d33f172
|
@ -55,7 +55,7 @@ export async function getAppMetadata(appId: string): Promise<App | DeletedApp> {
|
|||
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)) {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
|
||||
|
|
|
@ -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<any> = {
|
||||
|
|
|
@ -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(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue