2020-06-09 23:52:00 +12: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 22:04:31 +12:00
|
|
|
|
2020-08-06 02:18:28 +12: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
|
2020-10-29 06:40:14 +13:00
|
|
|
cy.get("input[name=apiKey]")
|
|
|
|
.type(name)
|
|
|
|
.should("have.value", name)
|
2020-08-06 02:18:28 +12:00
|
|
|
cy.contains("Next").click()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.then(() => {
|
|
|
|
cy.get("input[name=applicationName]")
|
|
|
|
.type(name)
|
|
|
|
.should("have.value", name)
|
|
|
|
|
|
|
|
cy.contains("Next").click()
|
|
|
|
|
2020-12-05 01:22:45 +13:00
|
|
|
cy.get("input[name=email]")
|
2020-10-29 06:40:14 +13:00
|
|
|
.click()
|
2020-12-05 01:22:45 +13:00
|
|
|
.type("test@test.com")
|
2020-10-29 06:40:14 +13:00
|
|
|
cy.get("input[name=password]")
|
|
|
|
.click()
|
|
|
|
.type("test")
|
2020-08-06 02:18:28 +12:00
|
|
|
cy.contains("Submit").click()
|
2020-10-28 04:26:07 +13:00
|
|
|
cy.get("[data-cy=new-table]", {
|
2020-09-05 11:03:08 +12:00
|
|
|
timeout: 20000,
|
2020-08-06 02:18:28 +12:00
|
|
|
}).should("be.visible")
|
|
|
|
})
|
2020-06-11 22:04:31 +12:00
|
|
|
})
|
2020-08-06 02:18:28 +12:00
|
|
|
|
2020-09-03 23:02:15 +12:00
|
|
|
Cypress.Commands.add("createTestTableWithData", () => {
|
|
|
|
cy.createTable("dog")
|
2020-10-05 23:13:09 +13:00
|
|
|
cy.addColumn("dog", "name", "Text")
|
2020-09-03 23:02:15 +12:00
|
|
|
cy.addColumn("dog", "age", "Number")
|
|
|
|
})
|
|
|
|
|
2020-08-11 02:34:37 +12:00
|
|
|
Cypress.Commands.add("createTable", tableName => {
|
2020-10-10 06:49:23 +13:00
|
|
|
// Enter table name
|
2020-10-28 04:26:07 +13:00
|
|
|
cy.get("[data-cy=new-table]").click()
|
2020-10-08 23:36:16 +13:00
|
|
|
cy.get(".modal").within(() => {
|
2020-10-29 06:40:14 +13:00
|
|
|
cy.get("input")
|
|
|
|
.first()
|
|
|
|
.type(tableName)
|
|
|
|
cy.get(".buttons")
|
|
|
|
.contains("Create")
|
|
|
|
.click()
|
2020-10-08 23:36:16 +13:00
|
|
|
})
|
2020-08-11 02:34:37 +12:00
|
|
|
cy.contains(tableName).should("be.visible")
|
|
|
|
})
|
2020-06-12 04:14:28 +12:00
|
|
|
|
2020-08-11 02:34:37 +12:00
|
|
|
Cypress.Commands.add("addColumn", (tableName, columnName, type) => {
|
|
|
|
// Select Table
|
2020-10-28 04:26:07 +13:00
|
|
|
cy.contains(".nav-item", tableName).click()
|
2020-08-11 04:51:30 +12:00
|
|
|
cy.contains("Create New Column").click()
|
2020-06-12 04:14:28 +12:00
|
|
|
|
2020-10-05 23:13:09 +13:00
|
|
|
// Configure column
|
2020-10-27 10:43:04 +13:00
|
|
|
cy.get(".actions").within(() => {
|
2020-10-29 06:40:14 +13:00
|
|
|
cy.get("input")
|
|
|
|
.first()
|
|
|
|
.type(columnName)
|
2020-10-15 20:17:26 +13:00
|
|
|
// Unset table display column
|
|
|
|
cy.contains("display column").click()
|
2020-10-05 23:13:09 +13:00
|
|
|
cy.get("select").select(type)
|
|
|
|
cy.contains("Save").click()
|
|
|
|
})
|
2020-06-11 22:04:31 +12:00
|
|
|
})
|
2020-08-06 02:18:28 +12:00
|
|
|
|
2020-10-10 07:10:28 +13:00
|
|
|
Cypress.Commands.add("addRow", values => {
|
2020-08-11 04:51:30 +12:00
|
|
|
cy.contains("Create New Row").click()
|
2020-06-11 22:04:31 +12:00
|
|
|
|
2020-10-05 23:13:09 +13:00
|
|
|
cy.get(".modal").within(() => {
|
|
|
|
for (let i = 0; i < values.length; i++) {
|
2020-10-29 06:40:14 +13:00
|
|
|
cy.get("input")
|
|
|
|
.eq(i)
|
|
|
|
.type(values[i])
|
2020-10-05 23:13:09 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
// Save
|
2020-10-29 06:40:14 +13:00
|
|
|
cy.get(".buttons")
|
|
|
|
.contains("Create")
|
|
|
|
.click()
|
2020-10-05 23:13:09 +13:00
|
|
|
})
|
2020-06-11 22:04:31 +12:00
|
|
|
})
|
|
|
|
|
2020-12-08 07:08:20 +13:00
|
|
|
Cypress.Commands.add("createUser", (email, password, role) => {
|
2020-06-12 04:14:28 +12:00
|
|
|
// Create User
|
2020-08-06 02:18:28 +12:00
|
|
|
cy.contains("Users").click()
|
2020-06-11 22:04:31 +12:00
|
|
|
|
2020-12-15 02:33:34 +13:00
|
|
|
cy.contains("Create New User").click()
|
2020-11-28 02:17:31 +13:00
|
|
|
|
|
|
|
cy.get(".modal").within(() => {
|
|
|
|
cy.get("input")
|
|
|
|
.first()
|
2020-12-09 02:16:53 +13:00
|
|
|
.type(email)
|
2020-11-28 02:17:31 +13:00
|
|
|
cy.get("input")
|
|
|
|
.eq(1)
|
2020-12-09 02:16:53 +13:00
|
|
|
.type(password)
|
2020-11-28 02:17:31 +13:00
|
|
|
cy.get("select")
|
|
|
|
.first()
|
2020-12-03 02:20:56 +13:00
|
|
|
.select(role)
|
2020-11-28 02:17:31 +13:00
|
|
|
|
|
|
|
// Save
|
|
|
|
cy.get(".buttons")
|
2020-12-09 02:16:53 +13:00
|
|
|
.contains("Create User")
|
2020-11-28 02:17:31 +13:00
|
|
|
.click()
|
|
|
|
})
|
2020-06-11 22:56:16 +12:00
|
|
|
})
|
|
|
|
|
2020-06-12 04:14:28 +12:00
|
|
|
Cypress.Commands.add("addHeadlineComponent", text => {
|
|
|
|
cy.get(".switcher > :nth-child(2)").click()
|
2020-06-11 22:56:16 +12:00
|
|
|
|
2020-06-12 04:14:28 +12:00
|
|
|
cy.get("[data-cy=Text]").click()
|
|
|
|
cy.get("[data-cy=Headline]").click()
|
|
|
|
cy.get(".tabs > :nth-child(2)").click()
|
2020-08-06 02:18:28 +12:00
|
|
|
cy.contains("Settings").click()
|
|
|
|
cy.get('input[name="text"]').type(text)
|
2020-06-12 04:14:28 +12:00
|
|
|
cy.contains("Design").click()
|
2020-06-12 02:40:07 +12:00
|
|
|
})
|
2020-06-12 04:14:28 +12:00
|
|
|
Cypress.Commands.add("addButtonComponent", () => {
|
|
|
|
cy.get(".switcher > :nth-child(2)").click()
|
2020-06-12 02:40:07 +12:00
|
|
|
|
2020-06-12 04:14:28 +12:00
|
|
|
cy.get("[data-cy=Button]").click()
|
|
|
|
})
|
2020-06-25 03:16:06 +12:00
|
|
|
|
2020-06-25 03:20:58 +12:00
|
|
|
Cypress.Commands.add("navigateToFrontend", () => {
|
2020-10-28 04:26:07 +13:00
|
|
|
cy.contains("design").click()
|
2020-06-25 03:16:06 +12:00
|
|
|
})
|
|
|
|
|
|
|
|
Cypress.Commands.add("createScreen", (screenName, route) => {
|
2020-10-28 04:26:07 +13:00
|
|
|
cy.get("[data-cy=new-screen]").click()
|
2020-10-06 00:37:03 +13:00
|
|
|
cy.get(".modal").within(() => {
|
2020-10-29 06:40:14 +13:00
|
|
|
cy.get("input")
|
|
|
|
.eq(0)
|
|
|
|
.type(screenName)
|
2020-10-06 00:37:03 +13:00
|
|
|
if (route) {
|
2020-10-29 06:40:14 +13:00
|
|
|
cy.get("input")
|
|
|
|
.eq(1)
|
|
|
|
.type(route)
|
2020-10-06 00:37:03 +13:00
|
|
|
}
|
2020-06-25 03:20:58 +12:00
|
|
|
cy.contains("Create Screen").click()
|
|
|
|
})
|
|
|
|
cy.get(".nav-items-container").within(() => {
|
2020-11-21 00:41:17 +13:00
|
|
|
cy.contains(route).should("exist")
|
2020-06-25 03:20:58 +12:00
|
|
|
})
|
|
|
|
})
|