Update commands.js

A few formatting based changes for this file
This commit is contained in:
Mitch-Budibase 2021-11-15 15:40:48 +00:00
parent 9f1f9304bd
commit 348c4ed75b
1 changed files with 113 additions and 81 deletions

View File

@ -35,11 +35,13 @@ Cypress.Commands.add("login", () => {
Cypress.Commands.add("createApp", name => {
cy.visit(`localhost:${Cypress.env("PORT")}/builder`)
cy.wait(500)
cy.request(`localhost:${Cypress.env("PORT")}/api/applications?status=all`).its('body').then((body) => {
if( body.length > 0) {
cy.get(".spectrum-Button").contains("Create app").click({ force: true })
}
})
cy.request(`localhost:${Cypress.env("PORT")}/api/applications?status=all`)
.its("body")
.then(body => {
if (body.length > 0) {
cy.get(".spectrum-Button").contains("Create app").click({ force: true })
}
})
cy.contains(/Start from scratch/).dblclick()
cy.get(".spectrum-Modal").within(() => {
cy.get("input").eq(0).type(name).should("have.value", name).blur()
@ -53,48 +55,55 @@ Cypress.Commands.add("deleteApp", name => {
cy.visit(`localhost:${Cypress.env("PORT")}/builder`)
cy.wait(2000)
cy.request(`localhost:${Cypress.env("PORT")}/api/applications?status=all`)
.its("body")
.then(val => {
if (val.length > 0) {
cy.searchForApplication(name)
cy.get(".appGrid").children().within(() => {
cy.get(".title").children().within(() => {
cy.get(".spectrum-Icon").click()
.its("body")
.then(val => {
if (val.length > 0) {
cy.searchForApplication(name)
cy.get(".appGrid")
.children()
.within(() => {
cy.get(".title")
.children()
.within(() => {
cy.get(".spectrum-Icon").click()
})
})
cy.get(".spectrum-Menu").contains("Delete").click()
cy.get(".spectrum-Dialog-grid").within(() => {
cy.get("input").type(name)
})
})
cy.get(".spectrum-Menu").contains("Delete").click()
cy.get(".spectrum-Dialog-grid").within(() => {
cy.get("input").type(name)
})
cy.get(".spectrum-Button--warning").click()
}
else {
return
}
})
})
cy.get(".spectrum-Button--warning").click()
} else {
return
}
})
})
Cypress.Commands.add("deleteAllApps", () => {
cy.visit(`localhost:${Cypress.env("PORT")}/builder`)
cy.wait(500)
cy.request(`localhost:${Cypress.env("PORT")}/api/applications?status=all`)
.its("body")
.then(val => {
for (let i = 0; i < val.length; i++) {
cy.get(".spectrum-Heading").eq(1).then((app) => {
const name = app.text()
cy.get(".title").children().within(() => {
cy.get(".spectrum-Icon").eq(0).click()
})
cy.get(".spectrum-Menu").contains("Delete").click()
cy.get(".spectrum-Dialog-grid").within(() => {
cy.get("input").type(name)
cy.get(".spectrum-Button--warning").click()
})
cy.reload()
})
}
})
.its("body")
.then(val => {
for (let i = 0; i < val.length; i++) {
cy.get(".spectrum-Heading")
.eq(1)
.then(app => {
const name = app.text()
cy.get(".title")
.children()
.within(() => {
cy.get(".spectrum-Icon").eq(0).click()
})
cy.get(".spectrum-Menu").contains("Delete").click()
cy.get(".spectrum-Dialog-grid").within(() => {
cy.get("input").type(name)
cy.get(".spectrum-Button--warning").click()
})
cy.reload()
})
}
})
})
Cypress.Commands.add("createTestApp", () => {
@ -114,9 +123,12 @@ Cypress.Commands.add("createTable", (tableName, initialTable) => {
cy.get(".add-button").click()
}
cy.wait(7000)
cy.get(".spectrum-Modal").contains("Budibase DB").click().then(() => {
cy.get(".spectrum-Button").contains("Continue").click({ force: true })
})
cy.get(".spectrum-Modal")
.contains("Budibase DB")
.click()
.then(() => {
cy.get(".spectrum-Button").contains("Continue").click({ force: true })
})
cy.get(".spectrum-Modal").within(() => {
cy.wait(1000)
cy.get("input").first().type(tableName).blur()
@ -280,7 +292,7 @@ Cypress.Commands.add("searchForApplication", appName => {
cy.get(".filter").then(() => {
cy.get(".spectrum-Textfield").within(() => {
cy.get("input").eq(0).type(appName)
})
})
})
// Confirms app exists after search
cy.get(".appGrid").contains(appName)
@ -290,7 +302,7 @@ Cypress.Commands.add("selectExternalDatasource", datasourceName => {
// Navigates to Data Section
cy.navigateToDataSection()
// Open Data Source modal
cy.get('.nav').within(() => {
cy.get(".nav").within(() => {
cy.get(".add-button").click()
})
// Clicks specified datasource & continue
@ -306,55 +318,73 @@ Cypress.Commands.add("addSqlDatasourceConfig", (sqlType, noFetch) => {
// Host IP Address
cy.wait(500)
cy.get(".spectrum-Dialog-grid").within(() => {
cy.get(".form-row").contains("Host").parent().children().within(() => {
cy.get(".spectrum-Textfield").within(() => {
cy.get("input").clear().type("3.251.63.170")
cy.get(".form-row")
.contains("Host")
.parent()
.children()
.within(() => {
cy.get(".spectrum-Textfield").within(() => {
cy.get("input").clear().type("3.251.63.170")
})
})
})
})
// Database Name
cy.get(".spectrum-Dialog-grid").within(() => {
cy.get(".form-row").contains("Database").parent().children().within(() => {
cy.get(".spectrum-Textfield").within(() => {
if (sqlType == "PostgreSQL") {
cy.get("input").clear().type("test")
}
if (sqlType == "MySQL") {
cy.get("input").clear().type("mysql")
}
cy.get(".form-row")
.contains("Database")
.parent()
.children()
.within(() => {
cy.get(".spectrum-Textfield").within(() => {
if (sqlType == "PostgreSQL") {
cy.get("input").clear().type("test")
}
if (sqlType == "MySQL") {
cy.get("input").clear().type("mysql")
}
})
})
})
})
// User
// User
cy.get(".spectrum-Dialog-grid").within(() => {
cy.get(".form-row").contains("User").parent().children().within(() => {
cy.get(".spectrum-Textfield").within(() => {
if (sqlType == "PostgreSQL") {
cy.get("input").clear().type("admin")
}
if (sqlType == "MySQL") {
cy.get("input").clear().type("root")
}
cy.get(".form-row")
.contains("User")
.parent()
.children()
.within(() => {
cy.get(".spectrum-Textfield").within(() => {
if (sqlType == "PostgreSQL") {
cy.get("input").clear().type("admin")
}
if (sqlType == "MySQL") {
cy.get("input").clear().type("root")
}
})
})
})
})
// Password
cy.get(".spectrum-Dialog-grid").within(() => {
cy.get(".form-row").contains("Password").parent().children().within(() => {
cy.get(".spectrum-Textfield").within(() => {
if (sqlType == "PostgreSQL") {
cy.get("input").clear().type("8cb2b6f4-4b33-4e86-b790-74eee608a4e9")
}
if (sqlType == "MySQL") {
cy.get("input").clear().type("abdc321d-4d21-4fc7-8d20-f40ab9fe6db0")
}
cy.get(".form-row")
.contains("Password")
.parent()
.children()
.within(() => {
cy.get(".spectrum-Textfield").within(() => {
if (sqlType == "PostgreSQL") {
cy.get("input").clear().type("8cb2b6f4-4b33-4e86-b790-74eee608a4e9")
}
if (sqlType == "MySQL") {
cy.get("input").clear().type("abdc321d-4d21-4fc7-8d20-f40ab9fe6db0")
}
})
})
})
})
// Click to fetch tables
if (!noFetch){
if (!noFetch) {
cy.get(".spectrum-Dialog-grid").within(() => {
cy.get(".spectrum-Button").contains("Fetch tables from database").click({ force: true })
cy.get(".spectrum-Button")
.contains("Fetch tables from database")
.click({ force: true })
cy.wait(1000)
})
}
@ -370,7 +400,9 @@ Cypress.Commands.add("addRestDatasourceConfig", restUrl => {
})
// Click Save and continue to query
cy.get(".spectrum-Dialog-grid").within(() => {
cy.get(".spectrum-Button").contains("Save and continue to query").click({ force: true })
cy.get(".spectrum-Button")
.contains("Save and continue to query")
.click({ force: true })
cy.wait(500)
})
})