From 4b92b5557b204335a8688dd61e56b8c266a15036 Mon Sep 17 00:00:00 2001 From: Mitch-Budibase Date: Wed, 22 Jun 2022 18:55:43 +0100 Subject: [PATCH] AdminAndManagement test changes + Commands update Specifically changes for accountPortals & userManagement Commands - Delete user function added - Few timing changes --- .../adminAndManagement/accountPortals.spec.js | 8 +++- .../adminAndManagement/userManagement.spec.js | 17 +------ packages/builder/cypress/support/commands.js | 45 ++++++++++++++----- 3 files changed, 42 insertions(+), 28 deletions(-) diff --git a/packages/builder/cypress/integration/adminAndManagement/accountPortals.spec.js b/packages/builder/cypress/integration/adminAndManagement/accountPortals.spec.js index c65f818a26..c615b2b4e6 100644 --- a/packages/builder/cypress/integration/adminAndManagement/accountPortals.spec.js +++ b/packages/builder/cypress/integration/adminAndManagement/accountPortals.spec.js @@ -113,7 +113,7 @@ filterTests(["smoke", "all"], () => { cy.get(".app").should('not.exist') // No apps -> no roles assigned to user cy.get(interact.CONTAINER).should('contain', bbUserEmail) // Message containing users email - cy.logOut() + cy.logoutNoAppGrid() }) const bbUserLogin = () => { @@ -121,5 +121,11 @@ filterTests(["smoke", "all"], () => { cy.logOut() cy.login(bbUserEmail, "test") } + + after(() => { + cy.login() + // Delete BB user + cy.deleteUser(bbUserEmail) + }) }) }) diff --git a/packages/builder/cypress/integration/adminAndManagement/userManagement.spec.js b/packages/builder/cypress/integration/adminAndManagement/userManagement.spec.js index 323f401ff8..265ccdb5ed 100644 --- a/packages/builder/cypress/integration/adminAndManagement/userManagement.spec.js +++ b/packages/builder/cypress/integration/adminAndManagement/userManagement.spec.js @@ -220,22 +220,7 @@ filterTests(["smoke", "all"], () => { }) it("should delete a user", () => { - // Navigate to test user - cy.contains("Users").click() - cy.contains("bbuser").click() - - // Click Delete user button - cy.get(interact.SPECTRUM_BUTTON) - .contains("Delete user") - .click({ force: true }) - .then(() => { - // Confirm deletion within modal - cy.get(interact.SPECTRUM_DIALOG_GRID, { timeout: 500 }).within(() => { - cy.get(interact.SPECTRUM_BUTTON) - .contains("Delete user") - .click({ force: true }) - }) - }) + cy.deleteUser("bbuser@test.com") cy.get(interact.SPECTRUM_TABLE, { timeout: 4000 }).should("not.have.text", "bbuser") }) }) diff --git a/packages/builder/cypress/support/commands.js b/packages/builder/cypress/support/commands.js index e84f604122..c98ea17d80 100644 --- a/packages/builder/cypress/support/commands.js +++ b/packages/builder/cypress/support/commands.js @@ -32,7 +32,7 @@ Cypress.Commands.add("login", (email, password) => { }) Cypress.Commands.add("logOut", () => { - cy.visit(`${Cypress.config().baseUrl}/builder`) + cy.visit(`${Cypress.config().baseUrl}/builder`, { timeout: 2000 }) cy.get(".user-dropdown .avatar > .icon").click({ force: true }) cy.get(".spectrum-Popover[data-cy='user-menu']").within(() => { cy.get("li[data-cy='user-logout']").click({ force: true }) @@ -54,16 +54,38 @@ Cypress.Commands.add("createUser", email => { // quick hacky recorded way to create a user cy.contains("Users").click() cy.get(`[data-cy="add-user"]`).click() - cy.get(".spectrum-Picker-label").click() - cy.get(".spectrum-Menu-item:nth-child(2) > .spectrum-Menu-itemLabel").click() + cy.get(".spectrum-Dialog-grid").within(() => { + cy.get(".spectrum-Picker-label").click() + cy.get( + ".spectrum-Menu-item:nth-child(2) > .spectrum-Menu-itemLabel" + ).click() - // Onboarding type selector - cy.get( - ":nth-child(2) > .spectrum-Form-itemField > .spectrum-Textfield > .spectrum-Textfield-input" - ) - .first() - .type(email, { force: true }) - cy.get(".spectrum-Button--cta").click({ force: true }) + // Onboarding type selector + cy.get(".spectrum-Textfield-input") + .eq(0) + .first() + .type(email, { force: true }) + cy.get(".spectrum-Button--cta").click({ force: true }) + }) +}) + +Cypress.Commands.add("deleteUser", email => { + // Assumes user has access to Users section + cy.contains("Users", { timeout: 2000 }).click() + cy.contains(email).click() + + // Click Delete user button + cy.get(".spectrum-Button") + .contains("Delete user") + .click({ force: true }) + .then(() => { + // Confirm deletion within modal + cy.get(".spectrum-Dialog-grid", { timeout: 500 }).within(() => { + cy.get(".spectrum-Button") + .contains("Delete user") + .click({ force: true }) + }) + }) }) Cypress.Commands.add("updateUserInformation", (firstName, lastName) => { @@ -377,7 +399,8 @@ Cypress.Commands.add("createTable", (tableName, initialTable) => { cy.navigateToDataSection() cy.get(`[data-cy="new-table"]`).click() } - cy.get(".spectrum-Dialog-grid", { timeout: 5000 }) + cy.wait(500) + cy.get(".spectrum-Dialog-grid") .contains("Budibase DB") .click({ force: true }) .then(() => {