Changing how connection is waited for.

This commit is contained in:
mike12345567 2021-05-24 16:31:50 +01:00
parent ec85f13d5a
commit bd0f78e38e
2 changed files with 22 additions and 7 deletions

View File

@ -68,9 +68,13 @@ function waitForConnection() {
resolve()
return
}
CLIENT.on("connect", () => {
// check if the connection is ready
const interval = setInterval(() => {
if (CONNECTED) {
clearInterval(interval)
resolve()
})
}
}, 500)
})
}

View File

@ -11,14 +11,25 @@ Cypress.Commands.add("login", () => {
if (cookie) return
cy.visit(`localhost:${Cypress.env("PORT")}/builder`)
cy.contains("Create Test User").click()
cy.get("button").then(btn => {
const adminUserButton = "Create super admin user"
console.log(btn.first().first())
if (!btn.first().contains(adminUserButton)) {
// create admin user
cy.get("input").first().type("test@test.com")
cy.get('input[type="password"]').first().type("test")
cy.get('input[type="password"]').eq(1).type("test")
cy.contains(adminUserButton).click()
}
// login
cy.get("input").first().type("test@test.com")
cy.get('input[type="password"]').type("test")
cy.contains("Login").click()
})
})
})
Cypress.Commands.add("createApp", name => {
cy.visit(`localhost:${Cypress.env("PORT")}/builder`)