diff --git a/.github/workflows/budibase_ci.yml b/.github/workflows/budibase_ci.yml index f4c17b64ea..e03768a420 100644 --- a/.github/workflows/budibase_ci.yml +++ b/.github/workflows/budibase_ci.yml @@ -16,7 +16,7 @@ jobs: strategy: matrix: - node-version: [10.x] + node-version: [12.x] steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2cfe328312..290f614e20 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,7 +15,7 @@ jobs: strategy: matrix: os: [macos-latest, ubuntu-latest, windows-latest] - node-version: [10.x] + node-version: [12.x] steps: - uses: actions/checkout@v2 diff --git a/packages/builder/src/components/automation/SetupPanel/ParamInputs/RecordSelector.svelte b/packages/builder/src/components/automation/SetupPanel/ParamInputs/RecordSelector.svelte index a9f9286ef2..1e52ea33a1 100644 --- a/packages/builder/src/components/automation/SetupPanel/ParamInputs/RecordSelector.svelte +++ b/packages/builder/src/components/automation/SetupPanel/ParamInputs/RecordSelector.svelte @@ -12,6 +12,10 @@ // Ensure any nullish modelId values get set to empty string so // that the select works $: if (value?.modelId == null) value = { modelId: "" } + + function schemaHasOptions(schema) { + return !!schema.constraints?.inclusion?.length + }
@@ -27,18 +31,15 @@
{#each schemaFields as [field, schema]}
- {#if schema.constraints?.inclusion?.length} + {#if schemaHasOptions(schema)}
{field}
- {#each schema.constraints.inclusion as option} {/each} - {:else if schema.type === "string" || schema.type === "number"} + {:else if schema.type === 'string' || schema.type === 'number'} diff --git a/packages/server/src/api/routes/tests/automation.spec.js b/packages/server/src/api/routes/tests/automation.spec.js index 18730acad6..43dcde517a 100644 --- a/packages/server/src/api/routes/tests/automation.spec.js +++ b/packages/server/src/api/routes/tests/automation.spec.js @@ -13,6 +13,7 @@ const { const { delay } = require("./testUtils") +const MAX_RETRIES = 4 const TEST_AUTOMATION = { _id: "Test Automation", name: "My Automation", @@ -168,11 +169,18 @@ describe("/automations", () => { expect(res.body.message).toEqual(`Automation ${automation._id} has been triggered.`) expect(res.body.automation.name).toEqual(TEST_AUTOMATION.name) // wait for automation to complete in background - await delay(500) - let elements = await getAllFromModel(request, app._id, instance._id, model._id) - expect(elements.length).toEqual(1) - expect(elements[0].name).toEqual("Test") - expect(elements[0].description).toEqual("TEST") + for (let tries = 0; tries < MAX_RETRIES; tries++) { + let elements = await getAllFromModel(request, app._id, instance._id, model._id) + // don't test it unless there are values to test + if (elements.length === 1) { + expect(elements.length).toEqual(1) + expect(elements[0].name).toEqual("Test") + expect(elements[0].description).toEqual("TEST") + return + } + await delay(500) + } + throw "Failed to find the records" }) }) diff --git a/packages/server/src/automations/index.js b/packages/server/src/automations/index.js index 9685e63f51..b6463e73ec 100644 --- a/packages/server/src/automations/index.js +++ b/packages/server/src/automations/index.js @@ -25,6 +25,7 @@ module.exports.init = function() { if (environment.BUDIBASE_ENVIRONMENT === "PRODUCTION") { await runWorker(job) } else { + console.log("Testing standard thread") await singleThread(job) } }) diff --git a/packages/server/src/automations/thread.js b/packages/server/src/automations/thread.js index f8a9509996..15445c26f5 100644 --- a/packages/server/src/automations/thread.js +++ b/packages/server/src/automations/thread.js @@ -10,11 +10,14 @@ function cleanMustache(string) { "]": "", } let regex = new RegExp(/{{[^}}]*}}/g) - let match - while ((match = regex.exec(string)) !== null) { + let matches = string.match(regex) + if (matches == null) { + return string + } + for (let match of matches) { let baseIdx = string.indexOf(match) for (let key of Object.keys(charToReplace)) { - let idxChar = match[0].indexOf(key) + let idxChar = match.indexOf(key) if (idxChar !== -1) { string = string.slice(baseIdx, baseIdx + idxChar) + diff --git a/packages/server/src/middleware/joi-validator.js b/packages/server/src/middleware/joi-validator.js index b204d70c84..7ded06fe81 100644 --- a/packages/server/src/middleware/joi-validator.js +++ b/packages/server/src/middleware/joi-validator.js @@ -1,18 +1,19 @@ function validate(schema, property) { // Return a Koa middleware function return (ctx, next) => { - if (schema) { - let params = - ctx[property] != null - ? ctx[property] - : ctx.request[property] != null - ? ctx.request[property] - : null - const { error } = schema.validate(params) - if (error) { - ctx.throw(400, `Invalid ${property} - ${error.message}`) - return - } + if (!schema) { + return next() + } + let params = null + if (ctx[property] != null) { + params = ctx[property] + } else if (ctx.request[property] != null) { + params = ctx.request[property] + } + const { error } = schema.validate(params) + if (error) { + ctx.throw(400, `Invalid ${property} - ${error.message}`) + return } return next() }