Fix cypress test for create workflow

This commit is contained in:
Andrew Kingston 2020-09-14 13:29:32 +01:00
parent 6fe55814c2
commit 8befaee4d0
3 changed files with 46 additions and 39 deletions

View File

@ -1,46 +1,52 @@
context('Create a workflow', () => { context("Create a workflow", () => {
before(() => {
cy.server()
cy.visit("localhost:4001/_builder")
before(() => { cy.createApp(
cy.server() "Workflow Test App",
cy.visit('localhost:4001/_builder') "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 cy.contains("workflow").click()
it('should create a workflow', () => { cy.contains("Create New Workflow").click()
cy.createTestTableWithData() cy.get("input").type("Add Record")
cy.contains("Save").click()
cy.contains('workflow').click() // Add trigger
cy.contains('Create New Workflow').click() cy.get("[data-cy=add-workflow-component]").click()
cy.get('input').type('Add Record') cy.get("[data-cy=RECORD_SAVED]").click()
cy.contains('Save').click() cy.get(".budibase__input").select("dog")
// Add trigger // Create action
cy.get('[data-cy=add-workflow-component]').click() cy.get("[data-cy=SAVE_RECORD]").click()
cy.get('[data-cy=RECORD_SAVED]').click() cy.get(".budibase__input").select("dog")
cy.get('.budibase__input').select('dog') cy.get(".container input")
.first()
.type("goodboy")
cy.get(".container input")
.eq(1)
.type("11")
// Create action // Save
cy.get('[data-cy=SAVE_RECORD]').click() cy.contains("Save Workflow").click()
cy.get('.container input').first().type('goodboy')
cy.get('.container input').eq(1).type('11')
// Save // Activate Workflow
cy.contains('Save Workflow').click() cy.get("[data-cy=activate-workflow]").click()
cy.contains("Add Record").should("be.visible")
cy.get(".stop-button.highlighted").should("be.visible")
})
// Activate Workflow it("should add record when a new record is added", () => {
cy.get('[data-cy=activate-workflow]').click() cy.contains("backend").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.addRecord(["Rover", 15])
cy.contains('backend').click() cy.reload()
cy.contains("goodboy").should("have.text", "goodboy")
cy.addRecord(["Rover", 15]) })
cy.reload() })
cy.contains('goodboy').should('have.text', 'goodboy')
})
})

View File

@ -16,8 +16,9 @@ export default class Workflow {
addBlock(block) { addBlock(block) {
// Make sure to add trigger if doesn't exist // Make sure to add trigger if doesn't exist
if (!this.hasTrigger() && block.type === "TRIGGER") { if (!this.hasTrigger() && block.type === "TRIGGER") {
this.workflow.definition.trigger = { id: generate(), ...block } const trigger = { id: generate(), ...block }
return this.workflow.definition.trigger = trigger
return trigger
} }
const newBlock = { id: generate(), ...block } const newBlock = { id: generate(), ...block }