From 60592616f80063a2069272ad17088e4f9684e9ec Mon Sep 17 00:00:00 2001 From: Mitch-Budibase Date: Mon, 27 Jun 2022 18:28:21 +0100 Subject: [PATCH] Test Refactoring AdminAndManagement + Datasources tests are being being refactored here --- .../adminAndManagement/userManagement.spec.js | 31 ++++++++++++------- .../cypress/integration/appOverview.spec.js | 6 +--- .../integration/datasources/mySql.spec.js | 3 +- .../integration/datasources/oracle.spec.js | 1 + .../datasources/postgreSql.spec.js | 8 ++++- packages/builder/cypress/support/commands.js | 1 + 6 files changed, 31 insertions(+), 19 deletions(-) diff --git a/packages/builder/cypress/integration/adminAndManagement/userManagement.spec.js b/packages/builder/cypress/integration/adminAndManagement/userManagement.spec.js index 265ccdb5ed..3c23086136 100644 --- a/packages/builder/cypress/integration/adminAndManagement/userManagement.spec.js +++ b/packages/builder/cypress/integration/adminAndManagement/userManagement.spec.js @@ -20,8 +20,10 @@ filterTests(["smoke", "all"], () => { cy.contains("bbuser").click() // Confirm development and admin access are disabled for (let i = 4; i < 6; i++) { + cy.wait(500) cy.get(interact.FIELD).eq(i).within(() => { - cy.get(interact.SPECTRUM_SWITCH_INPUT).should('be.disabled') + //cy.get(interact.SPECTRUM_SWITCH_INPUT).should('be.disabled') + cy.get(".spectrum-Switch-switch").should('not.be.checked') }) } // Existing apps appear within the No Access table @@ -80,6 +82,7 @@ filterTests(["smoke", "all"], () => { .click({ force: true }) }) cy.reload() + cy.wait(1000) } // Confirm roles exist within Configure roles table cy.get(interact.SPECTRUM_TABLE, { timeout: 2000 }) @@ -171,12 +174,13 @@ filterTests(["smoke", "all"], () => { it("Should edit user details within user details page", () => { // Add First name cy.get(interact.FIELD, { timeout: 500 }).eq(2).within(() => { - cy.get(interact.SPECTRUM_TEXTFIELD_INPUT).type("bb") + cy.get(interact.SPECTRUM_TEXTFIELD_INPUT, { timeout: 500 }).type("bb") }) // Add Last name cy.get(interact.FIELD).eq(3).within(() => { cy.get(interact.SPECTRUM_TEXTFIELD_INPUT).type("test") }) + cy.get(interact.FIELD).eq(0).click() // Reload page cy.reload() @@ -185,20 +189,23 @@ filterTests(["smoke", "all"], () => { cy.get(interact.SPECTRUM_TEXTFIELD_INPUT).should('have.value', "bb") }) cy.get(interact.FIELD).eq(3).within(() => { - cy.get(interact.SPECTRUM_TEXTFIELD_INPUT).should('have.value', "test") + cy.get(interact.SPECTRUM_TEXTFIELD_INPUT, { timeout: 500 }).should('have.value', "test") }) }) it("should reset the users password", () => { - cy.get(interact.REGENERATE, { timeout: 500 }).click({ force: true }) + cy.get(interact.REGENERATE, { timeout: 500 }).contains("Force password reset").click({ force: true }) // Reset password modal - const newPwd = cy.get(interact.SPECTRUM_TEXTFIELD_INPUT).its('value') + cy.get(interact.SPECTRUM_DIALOG_GRID) + .find(interact.SPECTRUM_TEXTFIELD_INPUT).invoke('val').as('pwd') cy.get(interact.SPECTRUM_BUTTON).contains("Reset password").click({ force: true }) // Logout, then login with new password cy.logOut() - cy.login("bbuser@test.com", newPwd) + cy.get('@pwd').then((pwd) => { + cy.login("bbuser@test.com", pwd) + }) // Reset password screen for (let i = 0; i < 2; i++) { @@ -207,15 +214,15 @@ filterTests(["smoke", "all"], () => { cy.get(interact.SPECTRUM_BUTTON).contains("Reset your password").click({ force: true }) // Confirm user logged in afer password change - cy.get(".user-dropdown .avatar > .icon").click({ force: true }) + cy.get(".avatar > .icon").click({ force: true }) - cy.get(".spectrum-Popover[data-cy='user-menu']").within(() => { - cy.get("li[data-cy='user-info']").click({ force: true }) - }) - cy.get(interact.SPECTRUM_TEXTFIELD_INPUT).its('value').should('eq', 'bbuser@test.com') + cy.get(".spectrum-Menu-item").contains("Update user information").click({ force: true }) + cy.get(interact.SPECTRUM_TEXTFIELD_INPUT) + .eq(0) + .invoke('val').should('eq', 'bbuser@test.com') // Logout and login as previous user - cy.logOut() + cy.logoutNoAppGrid() cy.login() }) diff --git a/packages/builder/cypress/integration/appOverview.spec.js b/packages/builder/cypress/integration/appOverview.spec.js index b25a53a916..a78578facf 100644 --- a/packages/builder/cypress/integration/appOverview.spec.js +++ b/packages/builder/cypress/integration/appOverview.spec.js @@ -158,11 +158,7 @@ filterTests(["all"], () => { .contains("Manage") .eq(0) .click({ force: true }) - cy.wait(1000) - cy.get(".app-overview-actions-icon").within(() => { - cy.get(".spectrum-Icon").click({ force: true }) - }) - cy.get(".spectrum-Menu").contains("Edit icon").click() + cy.get(".app-icon", { timwout: 1000 }).click({ force: true }) // Select random icon cy.get(".grid").within(() => { cy.get(".icon-item") diff --git a/packages/builder/cypress/integration/datasources/mySql.spec.js b/packages/builder/cypress/integration/datasources/mySql.spec.js index a83ab9a615..b79f5af9c6 100644 --- a/packages/builder/cypress/integration/datasources/mySql.spec.js +++ b/packages/builder/cypress/integration/datasources/mySql.spec.js @@ -135,7 +135,7 @@ filterTests(["all"], () => { cy.get(".spectrum-Table") .eq(1) .within(() => { - cy.get(".spectrum-Table-row").eq(0).click({ force: true }) + cy.get(".spectrum-Table-cell").eq(0).click({ force: true }) }) cy.get(".spectrum-Dialog-grid", { timeout: 500 }).within(() => { cy.get(".spectrum-Button") @@ -143,6 +143,7 @@ filterTests(["all"], () => { .click({ force: true }) }) cy.reload() + cy.wait(500) } // Confirm relationships no longer exist cy.get(".spectrum-Body").should( diff --git a/packages/builder/cypress/integration/datasources/oracle.spec.js b/packages/builder/cypress/integration/datasources/oracle.spec.js index 531f36eae7..92a5737ff9 100644 --- a/packages/builder/cypress/integration/datasources/oracle.spec.js +++ b/packages/builder/cypress/integration/datasources/oracle.spec.js @@ -18,6 +18,7 @@ filterTests(["all"], () => { cy.get(".spectrum-Button") .contains("Skip table fetch") .click({ force: true }) + cy.wait(500) // Confirm config contains localhost cy.get(".spectrum-Textfield-input", { timeout: 500 }) .eq(1) diff --git a/packages/builder/cypress/integration/datasources/postgreSql.spec.js b/packages/builder/cypress/integration/datasources/postgreSql.spec.js index db4b506669..de959e203c 100644 --- a/packages/builder/cypress/integration/datasources/postgreSql.spec.js +++ b/packages/builder/cypress/integration/datasources/postgreSql.spec.js @@ -35,6 +35,7 @@ filterTests(["all"], () => { // Check response from datasource after adding configuration cy.wait("@datasource") cy.get("@datasource").its("response.statusCode").should("eq", 200) + cy.wait(2000) // Confirm fetch tables was successful cy.get(".spectrum-Table") .eq(0) @@ -113,12 +114,13 @@ filterTests(["all"], () => { cy.get(".spectrum-Table") .eq(1) .within(() => { - cy.get(".spectrum-Table-row").eq(0).click({ force: true }) + cy.get(".spectrum-Table-cell").eq(0).click({ force: true }) }) cy.get(".spectrum-Dialog-grid", { timeout: 500 }).within(() => { cy.get(".spectrum-Button").contains("Delete").click({ force: true }) }) cy.reload() + cy.wait(500) // Confirm relationship was deleted cy.get(".spectrum-Table") .eq(1) @@ -228,7 +230,10 @@ filterTests(["all"], () => { // Run and Save query cy.get(".spectrum-Button").contains("Run Query").click({ force: true }) + cy.wait(500) cy.get(".spectrum-Button", { timeout: 500 }).contains("Save Query").click({ force: true }) + //cy.reload() + //cy.wait(500) cy.get(".nav-item").should("contain", queryRename) }) @@ -268,6 +273,7 @@ filterTests(["all"], () => { .click({ force: true }) }) cy.reload() + cy.wait(1000) } } }) diff --git a/packages/builder/cypress/support/commands.js b/packages/builder/cypress/support/commands.js index 099f57932d..8d60d243e0 100644 --- a/packages/builder/cypress/support/commands.js +++ b/packages/builder/cypress/support/commands.js @@ -650,6 +650,7 @@ Cypress.Commands.add("selectExternalDatasource", datasourceName => { cy.get(".spectrum-Dialog-grid").within(() => { cy.get(".spectrum-Button").contains("Continue").click({ force: true }) }) + cy.wait(500) }) Cypress.Commands.add("addDatasourceConfig", (datasource, skipFetch) => {