From 6a8bf943a89532ebbd5f0ebef2ad6108691f50d5 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Thu, 14 Oct 2021 15:26:38 +0100 Subject: [PATCH 1/3] Fixing issue #3005 - when a filter step is executed it now will fill in the history with a status describing that it stopped, this stops any errors from occurring. --- .../FlowChart/FlowItem.svelte | 2 +- packages/server/src/automations/thread.js | 22 +++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte index e69f5ec204..74e82a2da7 100644 --- a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte +++ b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte @@ -103,7 +103,7 @@ {block?.name?.toUpperCase() || ""} - {#if testResult} + {#if testResult && testResult[0]} resultsModal.show()}> Date: Thu, 14 Oct 2021 16:16:20 +0100 Subject: [PATCH 2/3] Fixing some issues which were causing errors during the cypress test runs, such as not redirect /api/system/ requests to the worker. --- packages/server/src/api/controllers/dev.js | 24 ++++++++++++------- packages/server/src/api/routes/dev.js | 13 ++++++---- .../src/utilities/rowProcessor/index.js | 4 ++++ 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/packages/server/src/api/controllers/dev.js b/packages/server/src/api/controllers/dev.js index d75c4032d7..c43de7f553 100644 --- a/packages/server/src/api/controllers/dev.js +++ b/packages/server/src/api/controllers/dev.js @@ -7,11 +7,13 @@ const { clearLock } = require("../../utilities/redis") const { Replication } = require("@budibase/auth").db const { DocumentTypes } = require("../../db/utils") -async function redirect(ctx, method) { +async function redirect(ctx, method, path = "global") { const { devPath } = ctx.params const queryString = ctx.originalUrl.split("?")[1] || "" const response = await fetch( - checkSlashesInUrl(`${env.WORKER_URL}/api/global/${devPath}?${queryString}`), + checkSlashesInUrl( + `${env.WORKER_URL}/api/${path}/${devPath}?${queryString}` + ), request( ctx, { @@ -41,16 +43,22 @@ async function redirect(ctx, method) { ctx.cookies } -exports.redirectGet = async ctx => { - await redirect(ctx, "GET") +exports.buildRedirectGet = path => { + return async ctx => { + await redirect(ctx, "GET", path) + } } -exports.redirectPost = async ctx => { - await redirect(ctx, "POST") +exports.buildRedirectPost = path => { + return async ctx => { + await redirect(ctx, "POST", path) + } } -exports.redirectDelete = async ctx => { - await redirect(ctx, "DELETE") +exports.buildRedirectDelete = path => { + return async ctx => { + await redirect(ctx, "DELETE", path) + } } exports.clearLock = async ctx => { diff --git a/packages/server/src/api/routes/dev.js b/packages/server/src/api/routes/dev.js index 7612d332dd..0d9bd118aa 100644 --- a/packages/server/src/api/routes/dev.js +++ b/packages/server/src/api/routes/dev.js @@ -6,11 +6,16 @@ const { BUILDER } = require("@budibase/auth/permissions") const router = Router() -if (env.isDev() || env.isTest()) { +function redirectPath(path) { router - .get("/api/global/:devPath(.*)", controller.redirectGet) - .post("/api/global/:devPath(.*)", controller.redirectPost) - .delete("/api/global/:devPath(.*)", controller.redirectDelete) + .get(`/api/${path}/:devPath(.*)`, controller.buildRedirectGet(path)) + .post(`/api/${path}/:devPath(.*)`, controller.buildRedirectPost(path)) + .delete(`/api/${path}/:devPath(.*)`, controller.buildRedirectDelete(path)) +} + +if (env.isDev() || env.isTest()) { + redirectPath("global") + redirectPath("system") } router diff --git a/packages/server/src/utilities/rowProcessor/index.js b/packages/server/src/utilities/rowProcessor/index.js index 55af87bc13..7d4ae3016e 100644 --- a/packages/server/src/utilities/rowProcessor/index.js +++ b/packages/server/src/utilities/rowProcessor/index.js @@ -150,6 +150,10 @@ exports.processAutoColumn = processAutoColumn * @returns {object} The coerced value */ exports.coerce = (row, type) => { + // no coercion specified for type, skip it + if (!TYPE_TRANSFORM_MAP[type]) { + return row + } // eslint-disable-next-line no-prototype-builtins if (TYPE_TRANSFORM_MAP[type].hasOwnProperty(row)) { return TYPE_TRANSFORM_MAP[type][row] From 33e5946f59b51ba93f116d963d9b65f6919f0d5a Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Thu, 14 Oct 2021 16:37:11 +0100 Subject: [PATCH 3/3] Fixing an issue with mongo test failing in Node 16 due to unhandled promise rejections. --- .../server/src/integrations/tests/mongo.spec.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/server/src/integrations/tests/mongo.spec.js b/packages/server/src/integrations/tests/mongo.spec.js index ce44617eb1..430ccc1c3a 100644 --- a/packages/server/src/integrations/tests/mongo.spec.js +++ b/packages/server/src/integrations/tests/mongo.spec.js @@ -27,7 +27,7 @@ describe("MongoDB Integration", () => { const body = { name: "Hello" } - const response = await config.integration.create({ + await config.integration.create({ index: indexName, json: body, extra: { collection: 'testCollection', actionTypes: 'insertOne'} @@ -54,7 +54,7 @@ describe("MongoDB Integration", () => { }, extra: { collection: 'testCollection', actionTypes: 'deleteOne'} } - const response = await config.integration.delete(query) + await config.integration.delete(query) expect(config.integration.client.deleteOne).toHaveBeenCalledWith(query.json) }) @@ -65,7 +65,7 @@ describe("MongoDB Integration", () => { }, extra: { collection: 'testCollection', actionTypes: 'updateOne'} } - const response = await config.integration.update(query) + await config.integration.update(query) expect(config.integration.client.updateOne).toHaveBeenCalledWith(query.json) }) @@ -75,10 +75,14 @@ describe("MongoDB Integration", () => { const query = { extra: { collection: 'testCollection', actionTypes: 'deleteOne'} } - // Weird, need to do an IIFE for jest to recognize that it throws - expect(() => config.integration.read(query)()).toThrow(expect.any(Object)) + let error = null + try { + await config.integration.read(query) + } catch (err) { + error = err + } + expect(error).toBeDefined() restore() }) - }) \ No newline at end of file