Browse Source

Fixing test cases, making it possible to still run automations via env variable.

master
mike12345567 5 years ago
parent
commit
500179e312
  1. 1
      packages/builder/cypress/setup.js
  2. 22
      packages/server/src/automations/triggers.js
  3. 1
      packages/server/src/environment.js

1
packages/builder/cypress/setup.js

@ -23,6 +23,7 @@ process.env.MINIO_SECRET_KEY = "budibase"
process.env.COUCH_DB_USER = "budibase" process.env.COUCH_DB_USER = "budibase"
process.env.COUCH_DB_PASSWORD = "budibase" process.env.COUCH_DB_PASSWORD = "budibase"
process.env.INTERNAL_API_KEY = "budibase" process.env.INTERNAL_API_KEY = "budibase"
process.env.ALLOW_DEV_AUTOMATIONS = 1
// Stop info logs polluting test outputs // Stop info logs polluting test outputs
process.env.LOG_LEVEL = "error" process.env.LOG_LEVEL = "error"

22
packages/server/src/automations/triggers.js

@ -8,6 +8,7 @@ const { isDevAppID } = require("../db/utils")
const { queue } = require("./bullboard") const { queue } = require("./bullboard")
const { checkTestFlag } = require("../utilities/redis") const { checkTestFlag } = require("../utilities/redis")
const utils = require("./utils") const utils = require("./utils")
const env = require("../environment")
const TRIGGER_DEFINITIONS = definitions const TRIGGER_DEFINITIONS = definitions
@ -30,21 +31,24 @@ async function queueRelevantRowAutomations(event, eventType) {
}) })
for (let automation of automations) { for (let automation of automations) {
// don't queue events which are for dev apps, only way to test automations is
// running tests on them
// in production the test flag will never be checked due to lazy evaluation (first always false)
if (isDevAppID(event.appId) && !(await checkTestFlag(automation._id))) {
return
}
let automationDef = automation.definition let automationDef = automation.definition
let automationTrigger = automationDef ? automationDef.trigger : {} let automationTrigger = automationDef ? automationDef.trigger : {}
// don't queue events which are for dev apps, only way to test automations is
// running tests on them, in production the test flag will never
// be checked due to lazy evaluation (first always false)
if ( if (
!automationTrigger.inputs || !env.ALLOW_DEV_AUTOMATIONS &&
automationTrigger.inputs.tableId !== event.row.tableId isDevAppID(event.appId) &&
!(await checkTestFlag(automation._id))
) { ) {
continue continue
} }
await queue.add({ automation, event }) if (
automationTrigger.inputs &&
automationTrigger.inputs.tableId === event.row.tableId
) {
await queue.add({ automation, event })
}
} }
} }

1
packages/server/src/environment.js

@ -55,6 +55,7 @@ module.exports = {
BUDIBASE_API_KEY: process.env.BUDIBASE_API_KEY, BUDIBASE_API_KEY: process.env.BUDIBASE_API_KEY,
USERID_API_KEY: process.env.USERID_API_KEY, USERID_API_KEY: process.env.USERID_API_KEY,
DEPLOYMENT_CREDENTIALS_URL: process.env.DEPLOYMENT_CREDENTIALS_URL, DEPLOYMENT_CREDENTIALS_URL: process.env.DEPLOYMENT_CREDENTIALS_URL,
ALLOW_DEV_AUTOMATIONS: process.env.ALLOW_DEV_AUTOMATIONS,
_set(key, value) { _set(key, value) {
process.env[key] = value process.env[key] = value
module.exports[key] = value module.exports[key] = value

Loading…
Cancel
Save