Only use fetch for search when running in cypress

This commit is contained in:
Andrew Kingston 2021-09-29 18:22:56 +01:00
parent a50d46ba32
commit 1b60fb5988
2 changed files with 7 additions and 2 deletions

View File

@ -351,8 +351,8 @@ exports.bulkDestroy = async ctx => {
} }
exports.search = async ctx => { exports.search = async ctx => {
// Fetch the whole table when running tests, as search doesn't work // Fetch the whole table when running in cypress, as search doesn't work
if (env.isTest()) { if (env.isCypress()) {
return { rows: await exports.fetch(ctx) } return { rows: await exports.fetch(ctx) }
} }

View File

@ -13,6 +13,10 @@ function isDev() {
) )
} }
function isCypress() {
return process.env.NODE_ENV === "cypress"
}
let LOADED = false let LOADED = false
if (!LOADED && isDev() && !isTest()) { if (!LOADED && isDev() && !isTest()) {
require("dotenv").config() require("dotenv").config()
@ -61,6 +65,7 @@ module.exports = {
module.exports[key] = value module.exports[key] = value
}, },
isTest, isTest,
isCypress,
isDev, isDev,
isProd: () => { isProd: () => {
return !isDev() return !isDev()