diff --git a/packages/builder/cypress/integration/createWorkflow.spec.js b/packages/builder/cypress/integration/createWorkflow.spec.js index e7fe34b630..833777f106 100644 --- a/packages/builder/cypress/integration/createWorkflow.spec.js +++ b/packages/builder/cypress/integration/createWorkflow.spec.js @@ -1,46 +1,52 @@ -context('Create a workflow', () => { +context("Create a workflow", () => { + before(() => { + cy.server() + cy.visit("localhost:4001/_builder") - before(() => { - cy.server() - cy.visit('localhost:4001/_builder') + cy.createApp( + "Workflow Test App", + "This app is used to test that workflows do in fact work!" + ) + }) - cy.createApp('Workflow Test App', 'This app is used to test that workflows do in fact work!') - }) + // https://on.cypress.io/interacting-with-elements + it("should create a workflow", () => { + cy.createTestTableWithData() - // https://on.cypress.io/interacting-with-elements - it('should create a workflow', () => { - cy.createTestTableWithData() + cy.contains("workflow").click() + cy.contains("Create New Workflow").click() + cy.get("input").type("Add Record") + cy.contains("Save").click() - cy.contains('workflow').click() - cy.contains('Create New Workflow').click() - cy.get('input').type('Add Record') - cy.contains('Save').click() + // Add trigger + cy.get("[data-cy=add-workflow-component]").click() + cy.get("[data-cy=RECORD_SAVED]").click() + cy.get(".budibase__input").select("dog") - // Add trigger - cy.get('[data-cy=add-workflow-component]').click() - cy.get('[data-cy=RECORD_SAVED]').click() - cy.get('.budibase__input').select('dog') + // Create action + cy.get("[data-cy=SAVE_RECORD]").click() + cy.get(".budibase__input").select("dog") + cy.get(".container input") + .first() + .type("goodboy") + cy.get(".container input") + .eq(1) + .type("11") - // Create action - cy.get('[data-cy=SAVE_RECORD]').click() - cy.get('.container input').first().type('goodboy') - cy.get('.container input').eq(1).type('11') + // Save + cy.contains("Save Workflow").click() - // Save - cy.contains('Save Workflow').click() + // Activate Workflow + cy.get("[data-cy=activate-workflow]").click() + cy.contains("Add Record").should("be.visible") + cy.get(".stop-button.highlighted").should("be.visible") + }) - // Activate Workflow - cy.get('[data-cy=activate-workflow]').click() - cy.contains("Add Record").should("be.visible") - cy.get(".stop-button.highlighted").should("be.visible") - }) + it("should add record when a new record is added", () => { + cy.contains("backend").click() - it('should add record when a new record is added', () => { - cy.contains('backend').click() - - cy.addRecord(["Rover", 15]) - cy.reload() - cy.contains('goodboy').should('have.text', 'goodboy') - - }) -}) \ No newline at end of file + cy.addRecord(["Rover", 15]) + cy.reload() + cy.contains("goodboy").should("have.text", "goodboy") + }) +}) diff --git a/packages/builder/cypress/videos/createWorkflow.spec.js.mp4 b/packages/builder/cypress/videos/createWorkflow.spec.js.mp4 index 52116ef9e9..22fd8541c7 100644 Binary files a/packages/builder/cypress/videos/createWorkflow.spec.js.mp4 and b/packages/builder/cypress/videos/createWorkflow.spec.js.mp4 differ diff --git a/packages/builder/src/builderStore/store/workflow/Workflow.js b/packages/builder/src/builderStore/store/workflow/Workflow.js index a69db28aad..8ac6664e91 100644 --- a/packages/builder/src/builderStore/store/workflow/Workflow.js +++ b/packages/builder/src/builderStore/store/workflow/Workflow.js @@ -16,8 +16,9 @@ export default class Workflow { addBlock(block) { // Make sure to add trigger if doesn't exist if (!this.hasTrigger() && block.type === "TRIGGER") { - this.workflow.definition.trigger = { id: generate(), ...block } - return + const trigger = { id: generate(), ...block } + this.workflow.definition.trigger = trigger + return trigger } const newBlock = { id: generate(), ...block }