diff --git a/packages/builder/src/builderStore/store/workflow/tests/Workflow.spec.js b/packages/builder/src/builderStore/store/workflow/tests/Workflow.spec.js
index fd14404a5f..4d270ea611 100644
--- a/packages/builder/src/builderStore/store/workflow/tests/Workflow.spec.js
+++ b/packages/builder/src/builderStore/store/workflow/tests/Workflow.spec.js
@@ -1,57 +1,48 @@
-import Workflow from "../Workflow";
-import TEST_WORKFLOW from "./testWorkflow";
+import Workflow from "../Workflow"
+import TEST_WORKFLOW from "./testWorkflow"
const TEST_BLOCK = {
- id: "VFWeZcIPx",
- name: "Update UI State",
- tagline: "Update {{path}} to {{value}}",
- icon: "ri-refresh-line",
- description: "Update your User Interface with some data.",
- environment: "CLIENT",
- params: {
- path: "string",
- value: "longText",
- },
- args: {
- path: "foo",
- value: "started...",
- },
- actionId: "SET_STATE",
- type: "ACTION",
+ id: "AUXJQGZY7",
+ name: "Delay",
+ icon: "ri-time-fill",
+ tagline: "Delay for {{time}} milliseconds",
+ description: "Delay the workflow until an amount of time has passed.",
+ params: { time: "number" },
+ type: "LOGIC",
+ args: { time: "5000" },
+ stepId: "DELAY",
}
describe("Workflow Data Object", () => {
let workflow
beforeEach(() => {
- workflow = new Workflow({ ...TEST_WORKFLOW });
- });
+ workflow = new Workflow({ ...TEST_WORKFLOW })
+ })
it("adds a workflow block to the workflow", () => {
- workflow.addBlock(TEST_BLOCK);
+ workflow.addBlock(TEST_BLOCK)
expect(workflow.workflow.definition)
})
it("updates a workflow block with new attributes", () => {
- const firstBlock = workflow.workflow.definition.steps[0];
+ const firstBlock = workflow.workflow.definition.steps[0]
const updatedBlock = {
...firstBlock,
- name: "UPDATED"
- };
- workflow.updateBlock(updatedBlock, firstBlock.id);
+ name: "UPDATED",
+ }
+ workflow.updateBlock(updatedBlock, firstBlock.id)
expect(workflow.workflow.definition.steps[0]).toEqual(updatedBlock)
})
it("deletes a workflow block successfully", () => {
const { steps } = workflow.workflow.definition
- const originalLength = steps.length
+ const originalLength = steps.length
- const lastBlock = steps[steps.length - 1];
- workflow.deleteBlock(lastBlock.id);
- expect(workflow.workflow.definition.steps.length).toBeLessThan(originalLength);
- })
-
- it("builds a tree that gets rendered in the flowchart builder", () => {
- expect(Workflow.buildUiTree(TEST_WORKFLOW.definition)).toMatchSnapshot();
+ const lastBlock = steps[steps.length - 1]
+ workflow.deleteBlock(lastBlock.id)
+ expect(workflow.workflow.definition.steps.length).toBeLessThan(
+ originalLength
+ )
})
})
diff --git a/packages/builder/src/builderStore/store/workflow/tests/__snapshots__/Workflow.spec.js.snap b/packages/builder/src/builderStore/store/workflow/tests/__snapshots__/Workflow.spec.js.snap
deleted file mode 100644
index 732764a082..0000000000
--- a/packages/builder/src/builderStore/store/workflow/tests/__snapshots__/Workflow.spec.js.snap
+++ /dev/null
@@ -1,49 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`Workflow Data Object builds a tree that gets rendered in the flowchart builder 1`] = `
-Array [
- Object {
- "args": Object {
- "time": 3000,
- },
- "body": "Delay for 3000 milliseconds",
- "heading": "DELAY",
- "id": "zJQcZUgDS",
- "name": "Delay",
- "params": Object {
- "time": "number",
- },
- "type": "LOGIC",
- },
- Object {
- "args": Object {
- "path": "foo",
- "value": "finished",
- },
- "body": "Update foo to finished",
- "heading": "SET_STATE",
- "id": "3RSTO7BMB",
- "name": "Update UI State",
- "params": Object {
- "path": "string",
- "value": "longText",
- },
- "type": "ACTION",
- },
- Object {
- "args": Object {
- "path": "foo",
- "value": "started...",
- },
- "body": "Update foo to started...",
- "heading": "SET_STATE",
- "id": "VFWeZcIPx",
- "name": "Update UI State",
- "params": Object {
- "path": "string",
- "value": "longText",
- },
- "type": "ACTION",
- },
-]
-`;
diff --git a/packages/builder/src/builderStore/store/workflow/tests/testWorkflow.js b/packages/builder/src/builderStore/store/workflow/tests/testWorkflow.js
index 90c4b17924..96999277eb 100644
--- a/packages/builder/src/builderStore/store/workflow/tests/testWorkflow.js
+++ b/packages/builder/src/builderStore/store/workflow/tests/testWorkflow.js
@@ -1,63 +1,78 @@
export default {
- _id: "53b6148c65d1429c987e046852d11611",
- _rev: "4-02c6659734934895812fa7be0215ee59",
- name: "Test Workflow",
+ name: "Test workflow",
definition: {
steps: [
{
- id: "VFWeZcIPx",
- name: "Update UI State",
- tagline: "Update {{path}} to {{value}}",
- icon: "ri-refresh-line",
- description: "Update your User Interface with some data.",
- environment: "CLIENT",
+ id: "ANBDINAPS",
+ description: "Send an email.",
+ tagline: "Send email to {{to}}",
+ icon: "ri-mail-open-fill",
+ name: "Send Email",
params: {
- path: "string",
- value: "longText",
+ to: "string",
+ from: "string",
+ subject: "longText",
+ text: "longText",
},
- args: {
- path: "foo",
- value: "started...",
- },
- actionId: "SET_STATE",
type: "ACTION",
- },
- {
- id: "zJQcZUgDS",
- name: "Delay",
- icon: "ri-time-fill",
- tagline: "Delay for {{time}} milliseconds",
- description: "Delay the workflow until an amount of time has passed.",
- environment: "CLIENT",
- params: {
- time: "number",
- },
args: {
- time: 3000,
+ text: "A user was created!",
+ subject: "New Budibase User",
+ from: "budimaster@budibase.com",
+ to: "test@test.com",
},
- actionId: "DELAY",
- type: "LOGIC",
- },
- {
- id: "3RSTO7BMB",
- name: "Update UI State",
- tagline: "Update {{path}} to {{value}}",
- icon: "ri-refresh-line",
- description: "Update your User Interface with some data.",
- environment: "CLIENT",
- params: {
- path: "string",
- value: "longText",
- },
- args: {
- path: "foo",
- value: "finished",
- },
- actionId: "SET_STATE",
- type: "ACTION",
+ stepId: "SEND_EMAIL",
},
],
+ trigger: {
+ id: "iRzYMOqND",
+ name: "Record Saved",
+ event: "record:save",
+ icon: "ri-save-line",
+ tagline: "Record is added to {{model.name}}",
+ description: "Fired when a record is saved to your database.",
+ params: { model: "model" },
+ type: "TRIGGER",
+ args: {
+ model: {
+ type: "model",
+ views: {},
+ name: "users",
+ schema: {
+ name: {
+ type: "string",
+ constraints: {
+ type: "string",
+ length: { maximum: 123 },
+ presence: { allowEmpty: false },
+ },
+ name: "name",
+ },
+ age: {
+ type: "number",
+ constraints: {
+ type: "number",
+ presence: { allowEmpty: false },
+ numericality: {
+ greaterThanOrEqualTo: "",
+ lessThanOrEqualTo: "",
+ },
+ },
+ name: "age",
+ },
+ },
+ _id: "c6b4e610cd984b588837bca27188a451",
+ _rev: "7-b8aa1ce0b53e88928bb88fc11bdc0aff",
+ },
+ },
+ stepId: "RECORD_SAVED",
+ },
},
type: "workflow",
- live: true,
+ ok: true,
+ id: "b384f861f4754e1693835324a7fcca62",
+ rev: "1-aa1c2cbd868ef02e26f8fad531dd7e37",
+ live: false,
+ _id: "b384f861f4754e1693835324a7fcca62",
+ _rev: "108-4116829ec375e0481d0ecab9e83a2caf",
}