2020-06-09 13:52:00 +02:00
|
|
|
// ***********************************************
|
|
|
|
// This example commands.js shows you how to
|
|
|
|
// create various custom commands and overwrite
|
|
|
|
// existing commands.
|
|
|
|
//
|
|
|
|
// For more comprehensive examples of custom
|
|
|
|
// commands please read more here:
|
|
|
|
// https://on.cypress.io/custom-commands
|
|
|
|
// ***********************************************
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// -- This is a parent command --
|
|
|
|
// Cypress.Commands.add("login", (email, password) => { ... })
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// -- This is a child command --
|
|
|
|
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// -- This is a dual command --
|
|
|
|
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// -- This will overwrite an existing command --
|
|
|
|
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
|
2020-06-11 12:04:31 +02:00
|
|
|
|
|
|
|
Cypress.Commands.add("createApp", (name, description) => {
|
|
|
|
cy.get('.banner-button')
|
|
|
|
.click()
|
|
|
|
.get('input[name="name"]')
|
|
|
|
.type(name).should('have.value', name)
|
|
|
|
|
|
|
|
cy.get('textarea[name="description"]')
|
|
|
|
.type(description).should('have.value', description)
|
|
|
|
|
|
|
|
cy.contains('Save').click()
|
|
|
|
})
|
|
|
|
Cypress.Commands.add("createModel", (modelName, firstField, secondField) => {
|
|
|
|
// Enter model name
|
|
|
|
cy.get('.budibase__input')
|
|
|
|
.type(modelName)
|
|
|
|
|
|
|
|
// Add 'name' field
|
|
|
|
cy.get('.new-field')
|
|
|
|
.click()
|
|
|
|
cy.get('.budibase__input').first()
|
|
|
|
.type(firstField)
|
|
|
|
cy.contains('Save').click()
|
|
|
|
|
|
|
|
|
|
|
|
// Add 'age' field
|
|
|
|
cy.get('.new-field')
|
|
|
|
.click()
|
|
|
|
cy.get('.budibase__input').first()
|
|
|
|
.type(secondField)
|
|
|
|
cy.get('select').select('number')
|
|
|
|
cy.contains('Save').click()
|
|
|
|
cy.contains(secondField).should('exist')
|
|
|
|
|
|
|
|
// Save model
|
|
|
|
cy.contains('Save').click()
|
|
|
|
})
|
|
|
|
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)
|
|
|
|
|
|
|
|
// Save
|
|
|
|
cy.contains('Save').click()
|
|
|
|
})
|
|
|
|
|
|
|
|
Cypress.Commands.add("createUser", (username, password, level) => {
|
|
|
|
// Create User
|
|
|
|
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)
|
|
|
|
|
|
|
|
// Save
|
|
|
|
cy.contains('Save').click()
|
2020-06-11 12:56:16 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
Cypress.Commands.add("addHeadlineComponent", (text) => {
|
|
|
|
cy.get('.switcher > :nth-child(2)').click()
|
|
|
|
|
2020-06-11 16:40:07 +02:00
|
|
|
cy.get('[data-cy=Text]').click()
|
|
|
|
cy.get('[data-cy=Headline]').click()
|
2020-06-11 12:56:16 +02:00
|
|
|
cy.get('.tabs > :nth-child(2)').click()
|
|
|
|
cy.get('input[type="text"]')
|
|
|
|
.type(text)
|
|
|
|
cy.contains('Design').click()
|
2020-06-11 16:40:07 +02:00
|
|
|
})
|
|
|
|
Cypress.Commands.add("addButtonComponent", (text) => {
|
|
|
|
cy.get('.switcher > :nth-child(2)').click()
|
|
|
|
|
|
|
|
cy.get('[data-cy=Button]').click()
|
2020-06-11 12:04:31 +02:00
|
|
|
})
|