adds some data-cy properties to a number of elements and starts work on workflow tests

This commit is contained in:
kevmodrome 2020-06-11 16:40:07 +02:00
parent 0ab7b99f41
commit 5140069ed6
8 changed files with 63 additions and 9 deletions

View File

@ -1,6 +1,7 @@
context('Create a Model', () => { context('Create a Model', () => {
before(() => { before(() => {
Cypress.Cookies.preserveOnce('builder:token')
cy.visit('localhost:4001/_builder') cy.visit('localhost:4001/_builder')
// https://on.cypress.io/type // https://on.cypress.io/type
cy.createApp('Model App', 'Model App Description') cy.createApp('Model App', 'Model App Description')
@ -15,9 +16,6 @@ context('Create a Model', () => {
cy.get('.title').should('have.text', 'dog') cy.get('.title').should('have.text', 'dog')
}) })
it('should add a record', () => { 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.addRecord('bob', '15')
cy.contains('bob').should('have.text', 'bob') cy.contains('bob').should('have.text', 'bob')

View File

@ -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()
})
})

View File

@ -84,13 +84,17 @@ Cypress.Commands.add("createUser", (username, password, level) => {
}) })
Cypress.Commands.add("addHeadlineComponent", (text) => { Cypress.Commands.add("addHeadlineComponent", (text) => {
// Create User
cy.get('.switcher > :nth-child(2)').click() cy.get('.switcher > :nth-child(2)').click()
cy.contains('Text').click() cy.get('[data-cy=Text]').click()
cy.contains('Headline').click() cy.get('[data-cy=Headline]').click()
cy.get('.tabs > :nth-child(2)').click() cy.get('.tabs > :nth-child(2)').click()
cy.get('input[type="text"]') cy.get('input[type="text"]')
.type(text) .type(text)
cy.contains('Design').click() cy.contains('Design').click()
}) })
Cypress.Commands.add("addButtonComponent", (text) => {
cy.get('.switcher > :nth-child(2)').click()
cy.get('[data-cy=Button]').click()
})

View File

@ -7,6 +7,7 @@
<div class="tabs"> <div class="tabs">
{#each categories as category} {#each categories as category}
<li <li
data-cy={category.name}
on:click={() => onClick(category)} on:click={() => onClick(category)}
class:active={selectedCategory === category}> class:active={selectedCategory === category}>
{category.name} {category.name}

View File

@ -3,7 +3,11 @@
export let item export let item
</script> </script>
<div class="item-item" in:fly={{ y: 100, duration: 1000 }} on:click> <div
data-cy={item.name}
class="item-item"
in:fly={{ y: 100, duration: 1000 }}
on:click>
<div class="item-icon"> <div class="item-icon">
<i class={item.icon} /> <i class={item.icon} />
</div> </div>

View File

@ -96,7 +96,10 @@
{#if workflowBlock} {#if workflowBlock}
<WorkflowBlockSetup {workflowBlock} /> <WorkflowBlockSetup {workflowBlock} />
<div class="buttons"> <div class="buttons">
<button class="workflow-button hoverable" on:click={saveWorkflow}> <button
data-cy="save-workflow-setup"
class="workflow-button hoverable"
on:click={saveWorkflow}>
Save Workflow Save Workflow
</button> </button>
<button <button

View File

@ -15,7 +15,10 @@
} }
</script> </script>
<div class="workflow-block hoverable" on:click={addBlockToWorkflow}> <div
class="workflow-block hoverable"
on:click={addBlockToWorkflow}
data-cy={actionId}>
<div> <div>
<i class={blockDefinition.icon} /> <i class={blockDefinition.icon} />
</div> </div>

View File

@ -11,6 +11,7 @@
<header> <header>
<span <span
data-cy="workflow-list"
class="hoverable workflow-header" class="hoverable workflow-header"
class:selected={selectedTab === 'WORKFLOWS'} class:selected={selectedTab === 'WORKFLOWS'}
on:click={() => (selectedTab = 'WORKFLOWS')}> on:click={() => (selectedTab = 'WORKFLOWS')}>
@ -18,6 +19,7 @@
</span> </span>
{#if $workflowStore.currentWorkflow} {#if $workflowStore.currentWorkflow}
<span <span
data-cy="add-workflow-component"
class="hoverable" class="hoverable"
class:selected={selectedTab === 'ADD'} class:selected={selectedTab === 'ADD'}
on:click={() => (selectedTab = 'ADD')}> on:click={() => (selectedTab = 'ADD')}>