From 2fb7777c5d7847fb20fcc7d80f44a1a7623f45b7 Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Wed, 18 May 2022 16:21:17 +0100 Subject: [PATCH 1/4] Return QA templates when TEST_ENV environmentvariable is set --- packages/frontend-core/src/api/templates.js | 2 +- packages/server/src/api/controllers/templates.js | 3 ++- packages/server/src/environment.js | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/frontend-core/src/api/templates.js b/packages/frontend-core/src/api/templates.js index 3c474dabc6..660a85d745 100644 --- a/packages/frontend-core/src/api/templates.js +++ b/packages/frontend-core/src/api/templates.js @@ -29,7 +29,7 @@ export const buildTemplateEndpoints = API => ({ */ getAppTemplates: async () => { return await API.get({ - url: "/api/templates?type=app", + url: "/api/templates", }) }, }) diff --git a/packages/server/src/api/controllers/templates.js b/packages/server/src/api/controllers/templates.js index 03dbbd2ee2..e18da3b9d3 100644 --- a/packages/server/src/api/controllers/templates.js +++ b/packages/server/src/api/controllers/templates.js @@ -1,12 +1,13 @@ const fetch = require("node-fetch") const { downloadTemplate } = require("../../utilities/fileSystem") +const env = require("../../environment") // development flag, can be used to test against templates exported locally const DEFAULT_TEMPLATES_BUCKET = "prod-budi-templates.s3-eu-west-1.amazonaws.com" exports.fetch = async function (ctx) { - const { type = "app" } = ctx.query + let type = env.TEST_ENV ? "qa" : "app" let response, error = false try { diff --git a/packages/server/src/environment.js b/packages/server/src/environment.js index ff1061dbaf..d9fa28ecff 100644 --- a/packages/server/src/environment.js +++ b/packages/server/src/environment.js @@ -78,6 +78,7 @@ module.exports = { ALLOW_DEV_AUTOMATIONS: process.env.ALLOW_DEV_AUTOMATIONS, DISABLE_THREADING: process.env.DISABLE_THREADING, SQL_MAX_ROWS: process.env.SQL_MAX_ROWS, + TEST_ENV: true, _set(key, value) { process.env[key] = value module.exports[key] = value From ae8548b15358a1ca5d94786017e36f5ef3d5440f Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Wed, 18 May 2022 16:30:05 +0100 Subject: [PATCH 2/4] remove test boolean --- packages/server/src/environment.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/src/environment.js b/packages/server/src/environment.js index d9fa28ecff..f06c369cd0 100644 --- a/packages/server/src/environment.js +++ b/packages/server/src/environment.js @@ -78,7 +78,7 @@ module.exports = { ALLOW_DEV_AUTOMATIONS: process.env.ALLOW_DEV_AUTOMATIONS, DISABLE_THREADING: process.env.DISABLE_THREADING, SQL_MAX_ROWS: process.env.SQL_MAX_ROWS, - TEST_ENV: true, + TEST_ENV: process.env.TEST_ENV, _set(key, value) { process.env[key] = value module.exports[key] = value From f999554361f3b2458b3ef933a9542bea70dae0c2 Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Thu, 19 May 2022 10:24:19 +0100 Subject: [PATCH 3/4] use env variable as the folder setting --- packages/server/src/api/controllers/templates.js | 2 +- packages/server/src/environment.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/server/src/api/controllers/templates.js b/packages/server/src/api/controllers/templates.js index e18da3b9d3..57a175d4ff 100644 --- a/packages/server/src/api/controllers/templates.js +++ b/packages/server/src/api/controllers/templates.js @@ -7,7 +7,7 @@ const DEFAULT_TEMPLATES_BUCKET = "prod-budi-templates.s3-eu-west-1.amazonaws.com" exports.fetch = async function (ctx) { - let type = env.TEST_ENV ? "qa" : "app" + let type = env.TEMPLATE_REPOSITORY || "app" let response, error = false try { diff --git a/packages/server/src/environment.js b/packages/server/src/environment.js index f06c369cd0..fd28e4c369 100644 --- a/packages/server/src/environment.js +++ b/packages/server/src/environment.js @@ -78,7 +78,7 @@ module.exports = { ALLOW_DEV_AUTOMATIONS: process.env.ALLOW_DEV_AUTOMATIONS, DISABLE_THREADING: process.env.DISABLE_THREADING, SQL_MAX_ROWS: process.env.SQL_MAX_ROWS, - TEST_ENV: process.env.TEST_ENV, + TEMPLATE_REPOSITORY: process.env.TEMPLATE_REPOSITORY, _set(key, value) { process.env[key] = value module.exports[key] = value From a7a27aa34966e73c21f35e123c81c529cec5b8bc Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Thu, 19 May 2022 10:56:51 +0100 Subject: [PATCH 4/4] default value for env variable --- packages/server/src/api/controllers/templates.js | 2 +- packages/server/src/environment.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/server/src/api/controllers/templates.js b/packages/server/src/api/controllers/templates.js index 57a175d4ff..3a1cafdf5a 100644 --- a/packages/server/src/api/controllers/templates.js +++ b/packages/server/src/api/controllers/templates.js @@ -7,7 +7,7 @@ const DEFAULT_TEMPLATES_BUCKET = "prod-budi-templates.s3-eu-west-1.amazonaws.com" exports.fetch = async function (ctx) { - let type = env.TEMPLATE_REPOSITORY || "app" + let type = env.TEMPLATE_REPOSITORY let response, error = false try { diff --git a/packages/server/src/environment.js b/packages/server/src/environment.js index fd28e4c369..4807ef5493 100644 --- a/packages/server/src/environment.js +++ b/packages/server/src/environment.js @@ -78,7 +78,7 @@ module.exports = { ALLOW_DEV_AUTOMATIONS: process.env.ALLOW_DEV_AUTOMATIONS, DISABLE_THREADING: process.env.DISABLE_THREADING, SQL_MAX_ROWS: process.env.SQL_MAX_ROWS, - TEMPLATE_REPOSITORY: process.env.TEMPLATE_REPOSITORY, + TEMPLATE_REPOSITORY: process.env.TEMPLATE_REPOSITORY || "app", _set(key, value) { process.env[key] = value module.exports[key] = value