Fixing conditional issues.

This commit is contained in:
mike12345567 2021-06-07 16:59:54 +01:00
parent e75b1338c2
commit 1f798f594d
1 changed files with 20 additions and 27 deletions

View File

@ -18,10 +18,6 @@ export function checkIfElementExists(el) {
}) })
} }
async function isFirstApp() {
return checkIfElementExists(".empty-wrapper")
}
Cypress.Commands.add("login", () => { Cypress.Commands.add("login", () => {
cy.visit(`localhost:${Cypress.env("PORT")}/builder`) cy.visit(`localhost:${Cypress.env("PORT")}/builder`)
cy.wait(500) cy.wait(500)
@ -47,10 +43,7 @@ Cypress.Commands.add("login", () => {
Cypress.Commands.add("createApp", name => { Cypress.Commands.add("createApp", name => {
cy.visit(`localhost:${Cypress.env("PORT")}/builder`) cy.visit(`localhost:${Cypress.env("PORT")}/builder`)
cy.wait(500) cy.wait(500)
isFirstApp().then(isFirst => { cy.contains(/Create (new )?app/).click()
const buttonText = isFirst ? "Create app" : "Create new app"
cy.contains(buttonText).click()
cy.get("body").then(() => {
cy.get(".spectrum-Modal") cy.get(".spectrum-Modal")
.within(() => { .within(() => {
cy.get("input").eq(0).type(name).should("have.value", name).blur() cy.get("input").eq(0).type(name).should("have.value", name).blur()
@ -62,15 +55,15 @@ Cypress.Commands.add("createApp", name => {
}).should("be.visible") }).should("be.visible")
}) })
}) })
})
})
Cypress.Commands.add("deleteApp", () => { Cypress.Commands.add("deleteApp", () => {
cy.visit(`localhost:${Cypress.env("PORT")}/builder`) cy.visit(`localhost:${Cypress.env("PORT")}/builder`)
cy.wait(1000) cy.wait(1000)
cy.request(`localhost:${Cypress.env("PORT")}/api/applications?status=all`)
isFirstApp().then(isFirst => { .its("body")
if (!isFirst) { .then(val => {
console.log(val)
if (val.length > 0) {
cy.get(".hoverable > use").click() cy.get(".hoverable > use").click()
cy.contains("Delete").click() cy.contains("Delete").click()
cy.get(".spectrum-Button--warning").click() cy.get(".spectrum-Button--warning").click()