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