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
|
|
|
|
2020-08-05 16:18:28 +02:00
|
|
|
Cypress.Commands.add("createApp", name => {
|
|
|
|
cy.contains("Create New Web App").click()
|
|
|
|
|
|
|
|
cy.get("body")
|
|
|
|
.then($body => {
|
|
|
|
if ($body.find("input[name=apiKey]").length) {
|
|
|
|
// input was found, do something else here
|
|
|
|
cy.get("input[name=apiKey]")
|
|
|
|
.type(name)
|
|
|
|
.should("have.value", name)
|
|
|
|
cy.contains("Next").click()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.then(() => {
|
|
|
|
cy.get("input[name=applicationName]")
|
|
|
|
.type(name)
|
|
|
|
.should("have.value", name)
|
|
|
|
|
|
|
|
cy.contains("Next").click()
|
|
|
|
|
|
|
|
cy.get("input[name=username]")
|
|
|
|
.click()
|
|
|
|
.type("test")
|
|
|
|
cy.get("input[name=password]")
|
|
|
|
.click()
|
|
|
|
.type("test")
|
|
|
|
cy.contains("Submit").click()
|
|
|
|
cy.contains("Create New Table", {
|
|
|
|
timeout: 10000,
|
|
|
|
}).should("be.visible")
|
|
|
|
})
|
2020-06-11 12:04:31 +02:00
|
|
|
})
|
2020-08-05 16:18:28 +02:00
|
|
|
|
2020-08-10 16:34:37 +02:00
|
|
|
Cypress.Commands.add("createTable", tableName => {
|
2020-06-11 18:14:28 +02:00
|
|
|
// Enter model name
|
2020-08-05 16:18:28 +02:00
|
|
|
cy.contains("Create New Table").click()
|
2020-08-10 16:34:37 +02:00
|
|
|
cy.get("[placeholder='Table Name']").type(tableName)
|
2020-06-11 18:14:28 +02:00
|
|
|
|
|
|
|
// Add 'name' field
|
2020-08-10 16:34:37 +02:00
|
|
|
cy.contains("Save").click()
|
|
|
|
cy.contains(tableName).should("be.visible")
|
|
|
|
})
|
2020-06-11 18:14:28 +02:00
|
|
|
|
2020-08-10 16:34:37 +02:00
|
|
|
Cypress.Commands.add("addColumn", (tableName, columnName, type) => {
|
|
|
|
// Select Table
|
|
|
|
cy.contains(tableName).click()
|
2020-08-10 18:51:30 +02:00
|
|
|
cy.contains("Create New Column").click()
|
2020-06-11 18:14:28 +02:00
|
|
|
|
2020-08-10 18:51:30 +02:00
|
|
|
cy.get("[placeholder=Name]").type(columnName)
|
|
|
|
cy.get("select").select(type)
|
|
|
|
|
|
|
|
cy.contains("Save Column")
|
2020-06-11 18:14:28 +02:00
|
|
|
|
2020-08-10 16:34:37 +02:00
|
|
|
cy.contains("Save").click()
|
2020-06-11 12:04:31 +02:00
|
|
|
})
|
2020-08-05 16:18:28 +02:00
|
|
|
|
2020-08-10 18:51:30 +02:00
|
|
|
Cypress.Commands.add("addRecord", values => {
|
|
|
|
cy.contains("Create New Row").click()
|
2020-06-11 12:04:31 +02:00
|
|
|
|
2020-08-10 18:51:30 +02:00
|
|
|
for (let i = 0; i < values.length; i++) {
|
2020-08-11 12:23:07 +02:00
|
|
|
cy.get("input")
|
|
|
|
.eq(i)
|
|
|
|
.type(values[i])
|
2020-08-10 18:51:30 +02:00
|
|
|
}
|
2020-06-11 12:04:31 +02:00
|
|
|
|
2020-06-11 18:14:28 +02:00
|
|
|
// Save
|
|
|
|
cy.contains("Save").click()
|
2020-06-11 12:04:31 +02:00
|
|
|
})
|
|
|
|
|
2020-08-05 16:18:28 +02:00
|
|
|
Cypress.Commands.add("createUser", (username, password) => {
|
2020-06-11 18:14:28 +02:00
|
|
|
// Create User
|
2020-08-05 16:18:28 +02:00
|
|
|
cy.get(".toprightnav > .settings").click()
|
|
|
|
cy.contains("Users").click()
|
2020-06-11 12:04:31 +02:00
|
|
|
|
2020-08-05 16:18:28 +02:00
|
|
|
cy.get("[name=Name]")
|
|
|
|
.first()
|
|
|
|
.type(username)
|
|
|
|
cy.get("[name=Password]")
|
|
|
|
.first()
|
|
|
|
.type(password)
|
2020-06-11 12:04:31 +02:00
|
|
|
|
2020-06-11 18:14:28 +02:00
|
|
|
// Save
|
2020-08-05 16:18:28 +02:00
|
|
|
cy.get(".create-button").click()
|
2020-06-11 12:56:16 +02:00
|
|
|
})
|
|
|
|
|
2020-06-11 18:14:28 +02:00
|
|
|
Cypress.Commands.add("addHeadlineComponent", text => {
|
|
|
|
cy.get(".switcher > :nth-child(2)").click()
|
2020-06-11 12:56:16 +02:00
|
|
|
|
2020-06-11 18:14:28 +02:00
|
|
|
cy.get("[data-cy=Text]").click()
|
|
|
|
cy.get("[data-cy=Headline]").click()
|
|
|
|
cy.get(".tabs > :nth-child(2)").click()
|
2020-08-05 16:18:28 +02:00
|
|
|
cy.contains("Settings").click()
|
|
|
|
cy.get('input[name="text"]').type(text)
|
2020-06-11 18:14:28 +02:00
|
|
|
cy.contains("Design").click()
|
2020-06-11 16:40:07 +02:00
|
|
|
})
|
2020-06-11 18:14:28 +02:00
|
|
|
Cypress.Commands.add("addButtonComponent", () => {
|
|
|
|
cy.get(".switcher > :nth-child(2)").click()
|
2020-06-11 16:40:07 +02:00
|
|
|
|
2020-06-11 18:14:28 +02:00
|
|
|
cy.get("[data-cy=Button]").click()
|
|
|
|
})
|
2020-06-24 17:16:06 +02:00
|
|
|
|
2020-06-24 17:20:58 +02:00
|
|
|
Cypress.Commands.add("navigateToFrontend", () => {
|
|
|
|
cy.contains("frontend").click()
|
2020-06-24 17:16:06 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
Cypress.Commands.add("createScreen", (screenName, route) => {
|
2020-06-24 17:20:58 +02:00
|
|
|
cy.get(".newscreen").click()
|
|
|
|
cy.get(".uk-input:first").type(screenName)
|
|
|
|
if (route) {
|
|
|
|
cy.get(".uk-input:last").type(route)
|
|
|
|
}
|
|
|
|
cy.get(".uk-modal-footer").within(() => {
|
|
|
|
cy.contains("Create Screen").click()
|
|
|
|
})
|
|
|
|
cy.get(".nav-items-container").within(() => {
|
|
|
|
cy.contains(screenName).should("exist")
|
|
|
|
})
|
|
|
|
})
|