From 40dfde522bd42cc37b42d019165afa8571e40ad9 Mon Sep 17 00:00:00 2001 From: kevmodrome Date: Thu, 11 Jun 2020 17:10:26 +0200 Subject: [PATCH] make tests less brittle --- .../integration/createWorkflow.spec.js | 20 ++++++++++++----- packages/builder/cypress/support/commands.js | 22 +++++++++---------- .../src/components/common/Textbox.svelte | 1 + .../CreateEditModel/CreateEditModel.svelte | 5 ++++- .../ModelDataTable/modals/CreateUser.svelte | 17 +++++++++++--- .../modals/RecordFieldControl.svelte | 2 ++ .../WorkflowBuilder/WorkflowBuilder.svelte | 1 + 7 files changed, 47 insertions(+), 21 deletions(-) diff --git a/packages/builder/cypress/integration/createWorkflow.spec.js b/packages/builder/cypress/integration/createWorkflow.spec.js index 62f00e92d2..b4d83e228b 100644 --- a/packages/builder/cypress/integration/createWorkflow.spec.js +++ b/packages/builder/cypress/integration/createWorkflow.spec.js @@ -3,7 +3,7 @@ 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!') }) @@ -18,11 +18,13 @@ context('Create a workflow', () => { cy.get('input').type('Add Record') cy.contains('Save').click() + // Add trigger cy.get('[data-cy=add-workflow-component]').click() - cy.contains('Actions').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(':nth-child(2) > .budibase__input').type('goodboy') cy.get(':nth-child(3) > .budibase__input').type('11') @@ -30,10 +32,16 @@ context('Create a workflow', () => { cy.get('[data-cy=save-workflow-setup]').click() cy.get('.workflow-button').click() + // Activate Workflow + cy.get('[data-cy=activate-workflow]').click() + }) - it('should be able to run', () => { - cy.contains('frontend').click() - cy.addButtonComponent() + it('should add record when a new record is added', () => { + cy.contains('backend').click() + + cy.addRecord('bob', '15') + + cy.contains('goodboy').should('have.text', 'goodboy') }) }) \ No newline at end of file diff --git a/packages/builder/cypress/support/commands.js b/packages/builder/cypress/support/commands.js index 7a3d276425..8e8c31d798 100644 --- a/packages/builder/cypress/support/commands.js +++ b/packages/builder/cypress/support/commands.js @@ -37,21 +37,20 @@ Cypress.Commands.add("createApp", (name, description) => { }) Cypress.Commands.add("createModel", (modelName, firstField, secondField) => { // Enter model name - cy.get('.budibase__input') + cy.get('[data-cy=Name]').click() .type(modelName) // Add 'name' field - cy.get('.new-field') - .click() - cy.get('.budibase__input').first() + cy.get('[data-cy=add-new-model-field]').click() + cy.get('[data-cy=Name]').click() .type(firstField) cy.contains('Save').click() // Add 'age' field - cy.get('.new-field') - .click() - cy.get('.budibase__input').first() + cy.get('[data-cy=add-new-model-field]').click() + + cy.get('[data-cy=Name]').click() .type(secondField) cy.get('select').select('number') cy.contains('Save').click() @@ -64,7 +63,8 @@ Cypress.Commands.add("addRecord", (firstField, secondField) => { cy.contains('Create new record') .click() - cy.get(':nth-child(1) > .uk-input').type(firstField).get(':nth-child(2) > .uk-input').type(secondField) + cy.get('[data-cy=name-input]').click().type(firstField) + cy.get('[data-cy=age-input]').click().type(secondField) // Save cy.contains('Save').click() @@ -75,9 +75,9 @@ Cypress.Commands.add("createUser", (username, password, level) => { cy.get('.nav-group-header > .ri-add-line') .click() - cy.get(':nth-child(2) > .uk-input').type(username) - cy.get(':nth-child(3) > .uk-input').type(password) - cy.get('.uk-select').select(level) + cy.get('[data-cy=username]').type(username) + cy.get('[data-cy=password]').type(password) + cy.get('[data-cy=accessLevel]').select(level) // Save cy.contains('Save').click() diff --git a/packages/builder/src/components/common/Textbox.svelte b/packages/builder/src/components/common/Textbox.svelte index f94cc2a44e..5249bf731a 100644 --- a/packages/builder/src/components/common/Textbox.svelte +++ b/packages/builder/src/components/common/Textbox.svelte @@ -13,6 +13,7 @@
Fields -
(showFieldView = true)}> +
(showFieldView = true)}> Add new field
diff --git a/packages/builder/src/components/database/ModelDataTable/modals/CreateUser.svelte b/packages/builder/src/components/database/ModelDataTable/modals/CreateUser.svelte index d5c924405f..714e822d16 100644 --- a/packages/builder/src/components/database/ModelDataTable/modals/CreateUser.svelte +++ b/packages/builder/src/components/database/ModelDataTable/modals/CreateUser.svelte @@ -29,15 +29,26 @@
- +
- +
- diff --git a/packages/builder/src/components/database/ModelDataTable/modals/RecordFieldControl.svelte b/packages/builder/src/components/database/ModelDataTable/modals/RecordFieldControl.svelte index 5c308a7abb..6d37246be9 100644 --- a/packages/builder/src/components/database/ModelDataTable/modals/RecordFieldControl.svelte +++ b/packages/builder/src/components/database/ModelDataTable/modals/RecordFieldControl.svelte @@ -32,6 +32,7 @@ {#if type === 'select'} {:else} 0} {checked} diff --git a/packages/builder/src/components/workflow/WorkflowBuilder/WorkflowBuilder.svelte b/packages/builder/src/components/workflow/WorkflowBuilder/WorkflowBuilder.svelte index 506575f05d..dd5eb7b138 100644 --- a/packages/builder/src/components/workflow/WorkflowBuilder/WorkflowBuilder.svelte +++ b/packages/builder/src/components/workflow/WorkflowBuilder/WorkflowBuilder.svelte @@ -50,6 +50,7 @@ class:highlighted={!workflowLive} class:hoverable={!workflowLive} class="play-button hoverable" + data-cy="activate-workflow" on:click={() => setWorkflowLive(true)}>