Fix cypress test for create workflow

This commit is contained in:
Andrew Kingston 2020-09-14 13:29:32 +01:00
parent 12d44ffcad
commit 62d37254ea
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.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')
})
})
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) {
// 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 }