From bd0f78e38ea93736f5de7d7436ff03d63033f066 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Mon, 24 May 2021 16:31:50 +0100 Subject: [PATCH] Changing how connection is waited for. --- packages/auth/src/redis/index.js | 10 +++++++--- packages/builder/cypress/support/commands.js | 19 +++++++++++++++---- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/packages/auth/src/redis/index.js b/packages/auth/src/redis/index.js index a3cb6385e6..044a8bcaf9 100644 --- a/packages/auth/src/redis/index.js +++ b/packages/auth/src/redis/index.js @@ -68,9 +68,13 @@ function waitForConnection() { resolve() return } - CLIENT.on("connect", () => { - resolve() - }) + // check if the connection is ready + const interval = setInterval(() => { + if (CONNECTED) { + clearInterval(interval) + resolve() + } + }, 500) }) } diff --git a/packages/builder/cypress/support/commands.js b/packages/builder/cypress/support/commands.js index 4f759a60ea..62365cbe87 100644 --- a/packages/builder/cypress/support/commands.js +++ b/packages/builder/cypress/support/commands.js @@ -11,12 +11,23 @@ Cypress.Commands.add("login", () => { if (cookie) return cy.visit(`localhost:${Cypress.env("PORT")}/builder`) - cy.contains("Create Test User").click() - cy.get("input").first().type("test@test.com") - cy.get('input[type="password"]').type("test") + 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() + } - cy.contains("Login").click() + // login + cy.get("input").first().type("test@test.com") + cy.get('input[type="password"]').type("test") + cy.contains("Login").click() + }) }) })