Cypress: Test changes based on User Updates

UI changes for users requires some test updates

- User commands updates
- New user command - setUserRole
- Test updates to adminAndManagement + Datasource tests
- Some test skips as they need reworked (specifically user management tests)
This commit is contained in:
Mitch-Budibase 2022-07-29 18:41:57 +01:00
parent 130d43565b
commit fd62eeac73
8 changed files with 127 additions and 118 deletions

View File

@ -19,9 +19,14 @@ filterTests(["smoke", "all"], () => {
cy.wait(500) cy.wait(500)
// Reset password // Reset password
cy.get(".spectrum-ActionButton-label", { timeout: 2000 }).contains("Force password reset").click({ force: true }) cy.get(".title").within(() => {
cy.get(interact.SPECTRUM_ICON).click({ force: true })
})
cy.get(interact.SPECTRUM_MENU).within(() => {
cy.get(interact.SPECTRUM_MENU_ITEM).contains("Force Password Reset").click({ force: true })
})
cy.get(".spectrum-Dialog-grid") cy.get(interact.SPECTRUM_DIALOG_GRID)
.find(interact.SPECTRUM_TEXTFIELD_INPUT).invoke('val').as('pwd') .find(interact.SPECTRUM_TEXTFIELD_INPUT).invoke('val').as('pwd')
cy.get(interact.SPECTRUM_BUTTON).contains("Reset password").click({ force: true }) cy.get(interact.SPECTRUM_BUTTON).contains("Reset password").click({ force: true })
@ -39,23 +44,14 @@ filterTests(["smoke", "all"], () => {
cy.logoutNoAppGrid() cy.logoutNoAppGrid()
}) })
it("should verify Admin Portal", () => { xit("should verify Admin Portal", () => {
cy.login() cy.login()
cy.contains("Users").click() // Configure user role
cy.contains("bbuser").click() cy.setUserRole("bbuser", "Admin")
// Enable Development & Administration access
cy.wait(500)
for (let i = 4; i < 6; i++) {
cy.get(interact.FIELD).eq(i).within(() => {
cy.get(interact.SPECTRUM_SWITCH_INPUT).click({ force: true })
cy.get(interact.SPECTRUM_SWITCH_INPUT).should('be.enabled')
})
}
bbUserLogin() bbUserLogin()
// Verify available options for Admin portal // Verify available options for Admin portal
cy.get(".spectrum-SideNav") cy.get(interact.SPECTRUM_SIDENAV)
.should('contain', 'Apps') .should('contain', 'Apps')
//.and('contain', 'Usage') //.and('contain', 'Usage')
.and('contain', 'Users') .and('contain', 'Users')
@ -72,13 +68,7 @@ filterTests(["smoke", "all"], () => {
it("should verify Development Portal", () => { it("should verify Development Portal", () => {
// Only Development access should be enabled // Only Development access should be enabled
cy.login() cy.login()
cy.contains("Users").click() cy.setUserRole("bbuser", "Developer")
cy.contains("bbuser").click()
cy.wait(500)
cy.get(interact.FIELD).eq(5).within(() => {
cy.get(interact.SPECTRUM_SWITCH_INPUT).click({ force: true })
})
bbUserLogin() bbUserLogin()
// Verify available options for Admin portal // Verify available options for Admin portal
@ -99,13 +89,7 @@ filterTests(["smoke", "all"], () => {
it("should verify Standard Portal", () => { it("should verify Standard Portal", () => {
// Development access should be disabled (Admin access is already disabled) // Development access should be disabled (Admin access is already disabled)
cy.login() cy.login()
cy.contains("Users").click() cy.setUserRole("bbuser", "App User")
cy.contains("bbuser").click()
cy.wait(500)
cy.get(interact.FIELD).eq(4).within(() => {
cy.get(interact.SPECTRUM_SWITCH_INPUT).click({ force: true })
})
bbUserLogin() bbUserLogin()
// Verify Standard Portal // Verify Standard Portal

View File

@ -15,25 +15,16 @@ filterTests(["smoke", "all"], () => {
cy.get(interact.SPECTRUM_TABLE).should("contain", "bbuser") cy.get(interact.SPECTRUM_TABLE).should("contain", "bbuser")
}) })
it("should confirm basic permission for a New User", () => { it("should confirm App User role for a New User", () => {
// Basic permission = development & administraton disabled
cy.contains("bbuser").click() cy.contains("bbuser").click()
// Confirm development and admin access are disabled cy.get(".spectrum-Form-itemField").eq(2).should('contain', 'App User')
for (let i = 4; i < 6; i++) {
cy.wait(500) // User should not have app access
cy.get(interact.FIELD).eq(i).within(() => { cy.get(interact.LIST_ITEMS, { timeout: 500 }).should("contain", "No apps")
//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
cy.get(interact.SPECTRUM_TABLE, { timeout: 500 }).eq(1).should("not.contain", "No rows found")
// Configure roles table should not contain apps
cy.get(interact.SPECTRUM_TABLE).eq(0).contains("No rows found")
}) })
if (Cypress.env("TEST_ENV")) { if (Cypress.env("TEST_ENV")) {
it("should assign role types", () => { xit("should assign role types", () => {
// 3 apps minimum required - to assign an app to each role type // 3 apps minimum required - to assign an app to each role type
cy.request(`${Cypress.config().baseUrl}/api/applications?status=all`) cy.request(`${Cypress.config().baseUrl}/api/applications?status=all`)
.its("body") .its("body")
@ -96,7 +87,7 @@ filterTests(["smoke", "all"], () => {
}) })
}) })
it("should unassign role types", () => { xit("should unassign role types", () => {
// Set each app within Configure roles table to 'No Access' // Set each app within Configure roles table to 'No Access'
cy.get(interact.SPECTRUM_TABLE) cy.get(interact.SPECTRUM_TABLE)
.eq(0) .eq(0)
@ -125,7 +116,7 @@ filterTests(["smoke", "all"], () => {
}) })
} }
it("should enable Developer access and verify application access", () => { xit("should enable Developer access and verify application access", () => {
// Enable Developer access // Enable Developer access
cy.get(interact.FIELD) cy.get(interact.FIELD)
.eq(4) .eq(4)
@ -157,7 +148,7 @@ filterTests(["smoke", "all"], () => {
}) })
}) })
it("should disable Developer access and verify application access", () => { xit("should disable Developer access and verify application access", () => {
// Disable Developer access // Disable Developer access
cy.get(interact.FIELD) cy.get(interact.FIELD)
.eq(4) .eq(4)
@ -175,12 +166,12 @@ filterTests(["smoke", "all"], () => {
it("Should edit user details within user details page", () => { it("Should edit user details within user details page", () => {
// Add First name // Add First name
cy.get(interact.FIELD, { timeout: 1000 }).eq(2).within(() => { cy.get(interact.FIELD, { timeout: 1000 }).eq(0).within(() => {
cy.wait(500) cy.wait(500)
cy.get(interact.SPECTRUM_TEXTFIELD_INPUT, { timeout: 1000 }).wait(500).clear().click().type("bb") cy.get(interact.SPECTRUM_TEXTFIELD_INPUT, { timeout: 1000 }).wait(500).clear().click().type("bb")
}) })
// Add Last name // Add Last name
cy.get(interact.FIELD, { timeout: 1000 }).eq(3).within(() => { cy.get(interact.FIELD, { timeout: 1000 }).eq(1).within(() => {
cy.wait(500) cy.wait(500)
cy.get(interact.SPECTRUM_TEXTFIELD_INPUT, { timeout: 1000 }).click().wait(500).clear().type("test") cy.get(interact.SPECTRUM_TEXTFIELD_INPUT, { timeout: 1000 }).click().wait(500).clear().type("test")
}) })
@ -189,16 +180,21 @@ filterTests(["smoke", "all"], () => {
cy.reload() cy.reload()
// Confirm details have been saved // Confirm details have been saved
cy.get(interact.FIELD, { timeout: 1000 }).eq(2).within(() => { cy.get(interact.FIELD, { timeout: 1000 }).eq(0).within(() => {
cy.get(interact.SPECTRUM_TEXTFIELD_INPUT).should('have.value', "bb") cy.get(interact.SPECTRUM_TEXTFIELD_INPUT).should('have.value', "bb")
}) })
cy.get(interact.FIELD, { timeout: 1000 }).eq(3).within(() => { cy.get(interact.FIELD, { timeout: 1000 }).eq(1).within(() => {
cy.get(interact.SPECTRUM_TEXTFIELD_INPUT, { timeout: 1000 }).should('have.value', "test") cy.get(interact.SPECTRUM_TEXTFIELD_INPUT, { timeout: 1000 }).should('have.value', "test")
}) })
}) })
it("should reset the users password", () => { it("should reset the users password", () => {
cy.get(interact.REGENERATE, { timeout: 500 }).contains("Force password reset").click({ force: true }) cy.get(".title").within(() => {
cy.get(interact.SPECTRUM_ICON).click({ force: true })
})
cy.get(interact.SPECTRUM_MENU).within(() => {
cy.get(interact.SPECTRUM_MENU_ITEM).contains("Force Password Reset").click({ force: true })
})
// Reset password modal // Reset password modal
cy.get(interact.SPECTRUM_DIALOG_GRID) cy.get(interact.SPECTRUM_DIALOG_GRID)

View File

@ -19,10 +19,10 @@ filterTests(["smoke", "all"], () => {
cy.contains("Users").click() cy.contains("Users").click()
cy.contains("test@test.com").click() cy.contains("test@test.com").click()
cy.get(interact.FIELD, { timeout: 1000 }).eq(2).within(() => { cy.get(interact.FIELD, { timeout: 1000 }).eq(0).within(() => {
cy.get(interact.SPECTRUM_TEXTFIELD_INPUT).should('have.value', fname) cy.get(interact.SPECTRUM_TEXTFIELD_INPUT).should('have.value', fname)
}) })
cy.get(interact.FIELD).eq(3).within(() => { cy.get(interact.FIELD).eq(1).within(() => {
cy.get(interact.SPECTRUM_TEXTFIELD_INPUT).should('have.value', lname) cy.get(interact.SPECTRUM_TEXTFIELD_INPUT).should('have.value', lname)
}) })
}) })

View File

@ -179,7 +179,7 @@ filterTests(["all"], () => {
cy.get(".nav-item").should("contain", queryName) cy.get(".nav-item").should("contain", queryName)
}) })
it("should duplicate a query", () => { xit("should duplicate a query", () => {
/// Get query nav item - QueryName /// Get query nav item - QueryName
cy.get(".nav-item") cy.get(".nav-item")
.contains(queryName) .contains(queryName)
@ -199,15 +199,16 @@ filterTests(["all"], () => {
.within(() => { .within(() => {
cy.get("input").clear().type(queryRename) cy.get("input").clear().type(queryRename)
}) })
// Save query // Click on a nav item
cy.get(".spectrum-Button").contains("Save Query").click({ force: true }) cy.get(".nav-item").first().click()
// Confirm name change
cy.get(".nav-item").should("contain", queryRename) cy.get(".nav-item").should("contain", queryRename)
}) })
it("should delete a query", () => { it("should delete a query", () => {
// Get query nav item - QueryName // Get query nav item - QueryName
cy.get(".nav-item") cy.get(".nav-item")
.contains(queryName) .contains(queryRename)
.parent() .parent()
.within(() => { .within(() => {
cy.get(".spectrum-Icon").eq(1).click({ force: true }) cy.get(".spectrum-Icon").eq(1).click({ force: true })
@ -218,7 +219,7 @@ filterTests(["all"], () => {
.contains("Delete Query") .contains("Delete Query")
.click({ force: true }) .click({ force: true })
// Confirm deletion // Confirm deletion
cy.get(".nav-item", { timeout: 1000 }).should("not.contain", queryName) cy.get(".nav-item", { timeout: 1000 }).should("not.contain", queryRename)
}) })
} }
}) })

View File

@ -204,7 +204,7 @@ filterTests(["all"], () => {
cy.get(".spectrum-Table").eq(1).should("contain", queryName) cy.get(".spectrum-Table").eq(1).should("contain", queryName)
}) })
it("should duplicate a query", () => { xit("should duplicate a query", () => {
// Locate previously created query // Locate previously created query
cy.get(".nav-item") cy.get(".nav-item")
.contains(queryName) .contains(queryName)
@ -220,7 +220,8 @@ filterTests(["all"], () => {
it("should edit a query name", () => { it("should edit a query name", () => {
// Access query // Access query
cy.get(".hierarchy-items-container", { timeout: 2000 }) cy.get(".hierarchy-items-container", { timeout: 2000 })
.contains(queryName + " (1)") //.contains(queryName + " (1)")
.contains(queryName)
.click({ force: true }) .click({ force: true })
// Rename query // Rename query
@ -231,18 +232,16 @@ filterTests(["all"], () => {
cy.get("input").clear().type(queryRename) cy.get("input").clear().type(queryRename)
}) })
// Run and Save query // Click on a nav item and confirm name change
cy.get(".spectrum-Button", { timeout: 2000 }).contains("Run Query").click({ force: true }) cy.get(".nav-item").first().click()
cy.wait(1000) // Confirm name change
cy.get(".spectrum-Button", { timeout: 2000 }).contains("Save Query").click({ force: true }) cy.get(".nav-item").should("contain", queryRename)
cy.reload({ timeout: 5000 })
cy.get(".nav-item", { timeout: 2000 }).should("contain", queryRename)
}) })
it("should delete a query", () => { it("should delete a query", () => {
// Get query nav item - QueryName // Get query nav item - QueryName
cy.get(".nav-item") cy.get(".nav-item")
.contains(queryName) .contains(queryRename)
.parent() .parent()
.within(() => { .within(() => {
cy.get(".spectrum-Icon").eq(1).click({ force: true }) cy.get(".spectrum-Icon").eq(1).click({ force: true })
@ -254,7 +253,7 @@ filterTests(["all"], () => {
.click({ force: true }) .click({ force: true })
// Confirm deletion // Confirm deletion
cy.reload({ timeout: 5000 }) cy.reload({ timeout: 5000 })
cy.get(".nav-item", { timeout: 1000 }).should("not.contain", queryName) cy.get(".nav-item", { timeout: 1000 }).should("not.contain", queryRename)
}) })
const switchSchema = schema => { const switchSchema = schema => {

View File

@ -2,7 +2,7 @@ import filterTests from "../support/filterTests"
const interact = require('../support/interact') const interact = require('../support/interact')
filterTests(["smoke", "all"], () => { filterTests(["smoke", "all"], () => {
context("Query Level Transformers", () => { xcontext("Query Level Transformers", () => {
before(() => { before(() => {
cy.login() cy.login()
cy.createTestApp() cy.createTestApp()

View File

@ -5,30 +5,31 @@ Cypress.on("uncaught:exception", () => {
// ACCOUNTS & USERS // ACCOUNTS & USERS
Cypress.Commands.add("login", (email, password) => { Cypress.Commands.add("login", (email, password) => {
cy.visit(`${Cypress.config().baseUrl}/builder`, { timeout: 10000 }) cy.visit(`${Cypress.config().baseUrl}/builder`, { timeout: 10000 })
cy.wait(2000) cy.url()
cy.url().then(url => { .should("include", "/builder/")
if (url.includes("builder/admin")) { .then(url => {
// create admin user if (url.includes("builder/admin")) {
cy.get("input").first().type("test@test.com") // create admin user
cy.get('input[type="password"]').first().type("test") cy.get("input").first().type("test@test.com")
cy.get('input[type="password"]').eq(1).type("test") cy.get('input[type="password"]').first().type("test")
cy.contains("Create super admin user").click({ force: true }) cy.get('input[type="password"]').eq(1).type("test")
} cy.contains("Create super admin user").click({ force: true })
if (url.includes("builder/auth/login") || url.includes("builder/admin")) { }
// login if (url.includes("builder/auth") || url.includes("builder/admin")) {
cy.contains("Sign in to Budibase").then(() => { // login
if (email == null) { cy.contains("Sign in to Budibase").then(() => {
cy.get("input").first().type("test@test.com") if (email == null) {
cy.get('input[type="password"]').type("test") cy.get("input").first().type("test@test.com")
} else { cy.get('input[type="password"]').type("test")
cy.get("input").first().type(email) } else {
cy.get('input[type="password"]').type(password) cy.get("input").first().type(email)
} cy.get('input[type="password"]').type(password)
cy.get("button").first().click({ force: true }) }
cy.wait(1000) cy.get("button").first().click({ force: true })
}) cy.wait(1000)
} })
}) }
})
}) })
Cypress.Commands.add("logOut", () => { Cypress.Commands.add("logOut", () => {
@ -50,23 +51,36 @@ Cypress.Commands.add("logoutNoAppGrid", () => {
cy.wait(2000) cy.wait(2000)
}) })
Cypress.Commands.add("createUser", email => { Cypress.Commands.add("createUser", (email, permission) => {
// quick hacky recorded way to create a user
cy.contains("Users").click() cy.contains("Users").click()
cy.get(`[data-cy="add-user"]`).click() cy.get(`[data-cy="add-user"]`).click()
cy.get(".spectrum-Dialog-grid").within(() => { cy.get(".spectrum-Dialog-grid").within(() => {
cy.get(".spectrum-Picker-label").click() // Enter email
cy.get( cy.get(".spectrum-Textfield-input").clear().click().type(email)
".spectrum-Menu-item:nth-child(2) > .spectrum-Menu-itemLabel"
).click()
// Onboarding type selector // Select permission, if applicable
cy.get(".spectrum-Textfield-input") // Default is App User
.eq(0) if (permission != null) {
.first() cy.get(".spectrum-Picker-label").click()
.type(email, { force: true }) cy.get(".spectrum-Menu").within(() => {
cy.get(".spectrum-Button--cta").click({ force: true }) cy.get(".spectrum-Menu-item")
.contains(permission)
.click({ force: true })
})
}
// Add user and wait for modal to change
cy.get(".spectrum-Button").contains("Add user").click({ force: true })
cy.get(".spectrum-ActionButton").contains("Add email").should("not.exist")
}) })
// Onboarding modal
cy.get(".spectrum-Dialog-grid").within(() => {
cy.get(".onboarding-type").eq(1).click()
cy.get(".spectrum-Button").contains("Done").click({ force: true })
cy.get(".spectrum-Button").contains("Cancel").should("not.exist")
})
// Accounts created modal - Click Done button
cy.get(".spectrum-Button").contains("Done").click({ force: true })
}) })
Cypress.Commands.add("deleteUser", email => { Cypress.Commands.add("deleteUser", email => {
@ -74,18 +88,13 @@ Cypress.Commands.add("deleteUser", email => {
cy.contains("Users", { timeout: 2000 }).click() cy.contains("Users", { timeout: 2000 }).click()
cy.contains(email).click() cy.contains(email).click()
// Click Delete user button cy.get(".title").within(() => {
cy.get(".spectrum-Button") cy.get(".spectrum-Icon").click({ force: true })
.contains("Delete user") })
.click({ force: true }) cy.get(".spectrum-Menu").within(() => {
.then(() => { cy.get(".spectrum-Menu-item").contains("Delete").click({ force: true })
// Confirm deletion within modal })
cy.get(".spectrum-Dialog-grid", { timeout: 500 }).within(() => { cy.get(".spectrum-Dialog-grid").contains("Delete user").click({ force: true })
cy.get(".spectrum-Button")
.contains("Delete user")
.click({ force: true })
})
})
}) })
Cypress.Commands.add("updateUserInformation", (firstName, lastName) => { Cypress.Commands.add("updateUserInformation", (firstName, lastName) => {
@ -120,9 +129,27 @@ Cypress.Commands.add("updateUserInformation", (firstName, lastName) => {
.blur() .blur()
} }
cy.get("button").contains("Update information").click({ force: true }) cy.get("button").contains("Update information").click({ force: true })
cy.get(".spectrum-Dialog-grid").should("not.exist")
}) })
}) })
Cypress.Commands.add("setUserRole", (user, role) => {
cy.contains("Users").click()
cy.contains(user).click()
// Set Role
cy.wait(500)
cy.get(".spectrum-Form-itemField")
.eq(2)
.within(() => {
cy.get(".spectrum-Picker-label").click({ force: true })
})
cy.get(".spectrum-Menu").within(() => {
cy.get(".spectrum-Menu-itemLabel").contains(role).click({ force: true })
})
cy.get(".spectrum-Form-itemField").eq(2).should("contain", role)
})
// APPLICATIONS // APPLICATIONS
Cypress.Commands.add("createTestApp", () => { Cypress.Commands.add("createTestApp", () => {
const appName = "Cypress Tests" const appName = "Cypress Tests"

View File

@ -109,6 +109,8 @@ export const REGENERATE = ".regenerate"
export const SPECTRUM_DIALOG_CONTENT = ".spectrum-Dialog-content" export const SPECTRUM_DIALOG_CONTENT = ".spectrum-Dialog-content"
export const SPECTRUM_ICON = ".spectrum-Icon" export const SPECTRUM_ICON = ".spectrum-Icon"
export const SPECTRUM_HEADING = ".spectrum-Heading" export const SPECTRUM_HEADING = ".spectrum-Heading"
export const SPECTRUM_FORM_ITEMFIELD = ".spectrum-Form-itemField"
export const LIST_ITEMS = ".list-items"
//createView //createView
export const SPECTRUM_MENU_ITEM_LABEL = ".spectrum-Menu-itemLabel" export const SPECTRUM_MENU_ITEM_LABEL = ".spectrum-Menu-itemLabel"