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,8 +35,10 @@ 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.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 })
}
})
@ -57,8 +59,12 @@ Cypress.Commands.add("deleteApp", name => {
.then(val => {
if (val.length > 0) {
cy.searchForApplication(name)
cy.get(".appGrid").children().within(() => {
cy.get(".title").children().within(() => {
cy.get(".appGrid")
.children()
.within(() => {
cy.get(".title")
.children()
.within(() => {
cy.get(".spectrum-Icon").click()
})
})
@ -67,12 +73,11 @@ Cypress.Commands.add("deleteApp", name => {
cy.get("input").type(name)
})
cy.get(".spectrum-Button--warning").click()
}
else {
} else {
return
}
})
})
})
Cypress.Commands.add("deleteAllApps", () => {
cy.visit(`localhost:${Cypress.env("PORT")}/builder`)
@ -81,9 +86,13 @@ Cypress.Commands.add("deleteAllApps", () => {
.its("body")
.then(val => {
for (let i = 0; i < val.length; i++) {
cy.get(".spectrum-Heading").eq(1).then((app) => {
cy.get(".spectrum-Heading")
.eq(1)
.then(app => {
const name = app.text()
cy.get(".title").children().within(() => {
cy.get(".title")
.children()
.within(() => {
cy.get(".spectrum-Icon").eq(0).click()
})
cy.get(".spectrum-Menu").contains("Delete").click()
@ -114,7 +123,10 @@ 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-Modal")
.contains("Budibase DB")
.click()
.then(() => {
cy.get(".spectrum-Button").contains("Continue").click({ force: true })
})
cy.get(".spectrum-Modal").within(() => {
@ -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,7 +318,11 @@ 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(".form-row")
.contains("Host")
.parent()
.children()
.within(() => {
cy.get(".spectrum-Textfield").within(() => {
cy.get("input").clear().type("3.251.63.170")
})
@ -314,7 +330,11 @@ Cypress.Commands.add("addSqlDatasourceConfig", (sqlType, noFetch) => {
})
// Database Name
cy.get(".spectrum-Dialog-grid").within(() => {
cy.get(".form-row").contains("Database").parent().children().within(() => {
cy.get(".form-row")
.contains("Database")
.parent()
.children()
.within(() => {
cy.get(".spectrum-Textfield").within(() => {
if (sqlType == "PostgreSQL") {
cy.get("input").clear().type("test")
@ -327,7 +347,11 @@ Cypress.Commands.add("addSqlDatasourceConfig", (sqlType, noFetch) => {
})
// User
cy.get(".spectrum-Dialog-grid").within(() => {
cy.get(".form-row").contains("User").parent().children().within(() => {
cy.get(".form-row")
.contains("User")
.parent()
.children()
.within(() => {
cy.get(".spectrum-Textfield").within(() => {
if (sqlType == "PostgreSQL") {
cy.get("input").clear().type("admin")
@ -340,7 +364,11 @@ Cypress.Commands.add("addSqlDatasourceConfig", (sqlType, noFetch) => {
})
// Password
cy.get(".spectrum-Dialog-grid").within(() => {
cy.get(".form-row").contains("Password").parent().children().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")
@ -352,9 +380,11 @@ Cypress.Commands.add("addSqlDatasourceConfig", (sqlType, noFetch) => {
})
})
// 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)
})
})