From 7cf81c063a33811f5616ae8ea2ed2e216751e114 Mon Sep 17 00:00:00 2001 From: kevmodrome Date: Thu, 11 Jun 2020 16:40:07 +0200 Subject: [PATCH] adds some data-cy properties to a number of elements and starts work on workflow tests --- .../cypress/integration/createModel.spec.js | 4 +- .../integration/createWorkflow.spec.js | 39 +++++++++++++++++++ packages/builder/cypress/support/commands.js | 10 +++-- .../userInterface/CategoryTab.svelte | 1 + .../userInterface/ItemTab/Item.svelte | 6 ++- .../workflow/SetupPanel/SetupPanel.svelte | 5 ++- .../BlockList/WorkflowBlock.svelte | 5 ++- .../WorkflowPanel/WorkflowPanel.svelte | 2 + 8 files changed, 63 insertions(+), 9 deletions(-) create mode 100644 packages/builder/cypress/integration/createWorkflow.spec.js diff --git a/packages/builder/cypress/integration/createModel.spec.js b/packages/builder/cypress/integration/createModel.spec.js index 061dadaa3d..3d46316607 100644 --- a/packages/builder/cypress/integration/createModel.spec.js +++ b/packages/builder/cypress/integration/createModel.spec.js @@ -1,6 +1,7 @@ context('Create a Model', () => { before(() => { + Cypress.Cookies.preserveOnce('builder:token') cy.visit('localhost:4001/_builder') // https://on.cypress.io/type cy.createApp('Model App', 'Model App Description') @@ -15,9 +16,6 @@ context('Create a Model', () => { cy.get('.title').should('have.text', 'dog') }) it('should add a record', () => { - // Page needs to be reloaded for some reason, cookie might be remove between tests? - cy.reload() - cy.addRecord('bob', '15') cy.contains('bob').should('have.text', 'bob') diff --git a/packages/builder/cypress/integration/createWorkflow.spec.js b/packages/builder/cypress/integration/createWorkflow.spec.js new file mode 100644 index 0000000000..62f00e92d2 --- /dev/null +++ b/packages/builder/cypress/integration/createWorkflow.spec.js @@ -0,0 +1,39 @@ +context('Create a workflow', () => { + + before(() => { + Cypress.Cookies.preserveOnce('builder:token') + cy.visit('localhost:4001/_builder') + // https://on.cypress.io/type + 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.createModel('dog', 'name', 'age') + cy.createUser('bbuser', 'test', 'ADMIN') + + + cy.contains('workflow').click() + cy.get('.new-workflow-button').click() + cy.get('input').type('Add Record') + cy.contains('Save').click() + + cy.get('[data-cy=add-workflow-component]').click() + cy.contains('Actions').click() + + cy.get('[data-cy=SAVE_RECORD]').click() + + cy.get(':nth-child(2) > .budibase__input').type('goodboy') + cy.get(':nth-child(3) > .budibase__input').type('11') + + // Save + cy.get('[data-cy=save-workflow-setup]').click() + cy.get('.workflow-button').click() + + }) + it('should be able to run', () => { + cy.contains('frontend').click() + cy.addButtonComponent() + + }) +}) \ No newline at end of file diff --git a/packages/builder/cypress/support/commands.js b/packages/builder/cypress/support/commands.js index ffe265a2a2..7a3d276425 100644 --- a/packages/builder/cypress/support/commands.js +++ b/packages/builder/cypress/support/commands.js @@ -84,13 +84,17 @@ Cypress.Commands.add("createUser", (username, password, level) => { }) Cypress.Commands.add("addHeadlineComponent", (text) => { - // Create User cy.get('.switcher > :nth-child(2)').click() - cy.contains('Text').click() - cy.contains('Headline').click() + cy.get('[data-cy=Text]').click() + cy.get('[data-cy=Headline]').click() cy.get('.tabs > :nth-child(2)').click() cy.get('input[type="text"]') .type(text) cy.contains('Design').click() +}) +Cypress.Commands.add("addButtonComponent", (text) => { + cy.get('.switcher > :nth-child(2)').click() + + cy.get('[data-cy=Button]').click() }) \ No newline at end of file diff --git a/packages/builder/src/components/userInterface/CategoryTab.svelte b/packages/builder/src/components/userInterface/CategoryTab.svelte index 074839eca2..5f7c3e584e 100644 --- a/packages/builder/src/components/userInterface/CategoryTab.svelte +++ b/packages/builder/src/components/userInterface/CategoryTab.svelte @@ -7,6 +7,7 @@
{#each categories as category}
  • onClick(category)} class:active={selectedCategory === category}> {category.name} diff --git a/packages/builder/src/components/userInterface/ItemTab/Item.svelte b/packages/builder/src/components/userInterface/ItemTab/Item.svelte index e5b36d0183..4e2806b018 100644 --- a/packages/builder/src/components/userInterface/ItemTab/Item.svelte +++ b/packages/builder/src/components/userInterface/ItemTab/Item.svelte @@ -3,7 +3,11 @@ export let item -
    +
    diff --git a/packages/builder/src/components/workflow/SetupPanel/SetupPanel.svelte b/packages/builder/src/components/workflow/SetupPanel/SetupPanel.svelte index 456505a4a8..eb88f6bb23 100644 --- a/packages/builder/src/components/workflow/SetupPanel/SetupPanel.svelte +++ b/packages/builder/src/components/workflow/SetupPanel/SetupPanel.svelte @@ -96,7 +96,10 @@ {#if workflowBlock}
    -