From 921eb39227a31e23a360332b621bfbfdf02a86f2 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 25 May 2021 11:06:50 +0100 Subject: [PATCH] Fixing the creation of user in cypress. --- packages/builder/cypress/support/commands.js | 29 +++++++++----------- packages/server/src/utilities/redis.js | 8 ++++-- packages/worker/src/utilities/redis.js | 8 ++++-- 3 files changed, 25 insertions(+), 20 deletions(-) diff --git a/packages/builder/cypress/support/commands.js b/packages/builder/cypress/support/commands.js index 80d38937ac..94a22295f2 100644 --- a/packages/builder/cypress/support/commands.js +++ b/packages/builder/cypress/support/commands.js @@ -12,22 +12,19 @@ Cypress.Commands.add("login", () => { cy.visit(`localhost:${Cypress.env("PORT")}/builder`) - // 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() - // }) + cy.url().then(url => { + if (url.includes("builder/admin")) { + // 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("Create super admin user").click() + } + // login + cy.get("input").first().type("test@test.com") + cy.get('input[type="password"]').type("test") + cy.get("button").first().click() + }) }) }) diff --git a/packages/server/src/utilities/redis.js b/packages/server/src/utilities/redis.js index ae18b82e02..18acb1aaa5 100644 --- a/packages/server/src/utilities/redis.js +++ b/packages/server/src/utilities/redis.js @@ -12,8 +12,12 @@ exports.init = async () => { } exports.shutdown = async () => { - await devAppClient.finish() - await debounceClient.finish() + if (devAppClient != null) { + await devAppClient.finish() + } + if (debounceClient != null) { + await debounceClient.finish() + } } exports.doesUserHaveLock = async (devAppId, user) => { diff --git a/packages/worker/src/utilities/redis.js b/packages/worker/src/utilities/redis.js index 28162a0c14..0ef6c8ea19 100644 --- a/packages/worker/src/utilities/redis.js +++ b/packages/worker/src/utilities/redis.js @@ -51,8 +51,12 @@ exports.init = async () => { * make sure redis connection is closed. */ exports.shutdown = async () => { - await pwResetClient.finish() - await invitationClient.finish() + if (pwResetClient != null) { + await pwResetClient.finish() + } + if (invitationClient != null) { + await invitationClient.finish() + } } /**