Merge pull request #6993 from Budibase/cypress-testing

Cypress: Test changes from User Updates
This commit is contained in:
Mitch-Budibase 2022-07-29 19:26:44 +01:00 committed by GitHub
commit 718af0393c
8 changed files with 127 additions and 118 deletions

View File

@ -19,9 +19,14 @@ filterTests(["smoke", "all"], () => {
cy.wait(500)
// 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')
cy.get(interact.SPECTRUM_BUTTON).contains("Reset password").click({ force: true })
@ -39,23 +44,14 @@ filterTests(["smoke", "all"], () => {
cy.logoutNoAppGrid()
})
it("should verify Admin Portal", () => {
xit("should verify Admin Portal", () => {
cy.login()
cy.contains("Users").click()
cy.contains("bbuser").click()
// 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')
})
}
// Configure user role
cy.setUserRole("bbuser", "Admin")
bbUserLogin()
// Verify available options for Admin portal
cy.get(".spectrum-SideNav")
cy.get(interact.SPECTRUM_SIDENAV)
.should('contain', 'Apps')
//.and('contain', 'Usage')
.and('contain', 'Users')
@ -72,13 +68,7 @@ filterTests(["smoke", "all"], () => {
it("should verify Development Portal", () => {
// Only Development access should be enabled
cy.login()
cy.contains("Users").click()
cy.contains("bbuser").click()
cy.wait(500)
cy.get(interact.FIELD).eq(5).within(() => {
cy.get(interact.SPECTRUM_SWITCH_INPUT).click({ force: true })
})
cy.setUserRole("bbuser", "Developer")
bbUserLogin()
// Verify available options for Admin portal
@ -99,13 +89,7 @@ filterTests(["smoke", "all"], () => {
it("should verify Standard Portal", () => {
// Development access should be disabled (Admin access is already disabled)
cy.login()
cy.contains("Users").click()
cy.contains("bbuser").click()
cy.wait(500)
cy.get(interact.FIELD).eq(4).within(() => {
cy.get(interact.SPECTRUM_SWITCH_INPUT).click({ force: true })
})
cy.setUserRole("bbuser", "App User")
bbUserLogin()
// Verify Standard Portal

View File

@ -15,25 +15,16 @@ filterTests(["smoke", "all"], () => {
cy.get(interact.SPECTRUM_TABLE).should("contain", "bbuser")
})
it("should confirm basic permission for a New User", () => {
// Basic permission = development & administraton disabled
it("should confirm App User role for a New User", () => {
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(".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")
cy.get(".spectrum-Form-itemField").eq(2).should('contain', 'App User')
// User should not have app access
cy.get(interact.LIST_ITEMS, { timeout: 500 }).should("contain", "No apps")
})
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
cy.request(`${Cypress.config().baseUrl}/api/applications?status=all`)
.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'
cy.get(interact.SPECTRUM_TABLE)
.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
cy.get(interact.FIELD)
.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
cy.get(interact.FIELD)
.eq(4)
@ -175,12 +166,12 @@ filterTests(["smoke", "all"], () => {
it("Should edit user details within user details page", () => {
// 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.get(interact.SPECTRUM_TEXTFIELD_INPUT, { timeout: 1000 }).wait(500).clear().click().type("bb")
})
// 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.get(interact.SPECTRUM_TEXTFIELD_INPUT, { timeout: 1000 }).click().wait(500).clear().type("test")
})
@ -189,16 +180,21 @@ filterTests(["smoke", "all"], () => {
cy.reload()
// 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.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")
})
})
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
cy.get(interact.SPECTRUM_DIALOG_GRID)

View File

@ -19,10 +19,10 @@ filterTests(["smoke", "all"], () => {
cy.contains("Users").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.FIELD).eq(3).within(() => {
cy.get(interact.FIELD).eq(1).within(() => {
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)
})
it("should duplicate a query", () => {
xit("should duplicate a query", () => {
/// Get query nav item - QueryName
cy.get(".nav-item")
.contains(queryName)
@ -199,15 +199,16 @@ filterTests(["all"], () => {
.within(() => {
cy.get("input").clear().type(queryRename)
})
// Save query
cy.get(".spectrum-Button").contains("Save Query").click({ force: true })
// Click on a nav item
cy.get(".nav-item").first().click()
// Confirm name change
cy.get(".nav-item").should("contain", queryRename)
})
it("should delete a query", () => {
// Get query nav item - QueryName
cy.get(".nav-item")
.contains(queryName)
.contains(queryRename)
.parent()
.within(() => {
cy.get(".spectrum-Icon").eq(1).click({ force: true })
@ -218,7 +219,7 @@ filterTests(["all"], () => {
.contains("Delete Query")
.click({ force: true })
// 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)
})
it("should duplicate a query", () => {
xit("should duplicate a query", () => {
// Locate previously created query
cy.get(".nav-item")
.contains(queryName)
@ -220,7 +220,8 @@ filterTests(["all"], () => {
it("should edit a query name", () => {
// Access query
cy.get(".hierarchy-items-container", { timeout: 2000 })
.contains(queryName + " (1)")
//.contains(queryName + " (1)")
.contains(queryName)
.click({ force: true })
// Rename query
@ -231,18 +232,16 @@ filterTests(["all"], () => {
cy.get("input").clear().type(queryRename)
})
// Run and Save query
cy.get(".spectrum-Button", { timeout: 2000 }).contains("Run Query").click({ force: true })
cy.wait(1000)
cy.get(".spectrum-Button", { timeout: 2000 }).contains("Save Query").click({ force: true })
cy.reload({ timeout: 5000 })
cy.get(".nav-item", { timeout: 2000 }).should("contain", queryRename)
// Click on a nav item and confirm name change
cy.get(".nav-item").first().click()
// Confirm name change
cy.get(".nav-item").should("contain", queryRename)
})
it("should delete a query", () => {
// Get query nav item - QueryName
cy.get(".nav-item")
.contains(queryName)
.contains(queryRename)
.parent()
.within(() => {
cy.get(".spectrum-Icon").eq(1).click({ force: true })
@ -254,7 +253,7 @@ filterTests(["all"], () => {
.click({ force: true })
// Confirm deletion
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 => {

View File

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

View File

@ -5,8 +5,9 @@ Cypress.on("uncaught:exception", () => {
// ACCOUNTS & USERS
Cypress.Commands.add("login", (email, password) => {
cy.visit(`${Cypress.config().baseUrl}/builder`, { timeout: 10000 })
cy.wait(2000)
cy.url().then(url => {
cy.url()
.should("include", "/builder/")
.then(url => {
if (url.includes("builder/admin")) {
// create admin user
cy.get("input").first().type("test@test.com")
@ -14,7 +15,7 @@ Cypress.Commands.add("login", (email, password) => {
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")) {
if (url.includes("builder/auth") || url.includes("builder/admin")) {
// login
cy.contains("Sign in to Budibase").then(() => {
if (email == null) {
@ -50,23 +51,36 @@ Cypress.Commands.add("logoutNoAppGrid", () => {
cy.wait(2000)
})
Cypress.Commands.add("createUser", email => {
// quick hacky recorded way to create a user
Cypress.Commands.add("createUser", (email, permission) => {
cy.contains("Users").click()
cy.get(`[data-cy="add-user"]`).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()
// Enter email
cy.get(".spectrum-Textfield-input").clear().click().type(email)
// Onboarding type selector
cy.get(".spectrum-Textfield-input")
.eq(0)
.first()
.type(email, { force: true })
cy.get(".spectrum-Button--cta").click({ force: true })
// Select permission, if applicable
// Default is App User
if (permission != null) {
cy.get(".spectrum-Picker-label").click()
cy.get(".spectrum-Menu").within(() => {
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 => {
@ -74,18 +88,13 @@ Cypress.Commands.add("deleteUser", email => {
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 })
cy.get(".title").within(() => {
cy.get(".spectrum-Icon").click({ force: true })
})
cy.get(".spectrum-Menu").within(() => {
cy.get(".spectrum-Menu-item").contains("Delete").click({ force: true })
})
cy.get(".spectrum-Dialog-grid").contains("Delete user").click({ force: true })
})
Cypress.Commands.add("updateUserInformation", (firstName, lastName) => {
@ -120,9 +129,27 @@ Cypress.Commands.add("updateUserInformation", (firstName, lastName) => {
.blur()
}
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
Cypress.Commands.add("createTestApp", () => {
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_ICON = ".spectrum-Icon"
export const SPECTRUM_HEADING = ".spectrum-Heading"
export const SPECTRUM_FORM_ITEMFIELD = ".spectrum-Form-itemField"
export const LIST_ITEMS = ".list-items"
//createView
export const SPECTRUM_MENU_ITEM_LABEL = ".spectrum-Menu-itemLabel"