Account Portal tests + Command file changes
Account portal tests - Visibility when accessing the portal with different permissions Commands - New command to logout when app grid is not present - Need matching data-cy commands for this
This commit is contained in:
parent
318eb22a06
commit
31c5ae08ad
3 changed files with 135 additions and 61 deletions
|
@ -1,59 +0,0 @@
|
||||||
import filterTests from "../../support/filterTests"
|
|
||||||
const interact = require('../../support/interact')
|
|
||||||
|
|
||||||
filterTests(["smoke", "all"], () => {
|
|
||||||
context("Account Portal", () => {
|
|
||||||
before(() => {
|
|
||||||
cy.login()
|
|
||||||
cy.deleteApp("Cypress Tests")
|
|
||||||
cy.createApp("Cypress Tests")
|
|
||||||
|
|
||||||
// Create new user
|
|
||||||
cy.visit(`${Cypress.config().baseUrl}/builder`, { timeout: 1000})
|
|
||||||
cy.createUser("bbuser@test.com")
|
|
||||||
cy.contains("bbuser").click()
|
|
||||||
|
|
||||||
// Reset password
|
|
||||||
cy.get(interact.REGENERATE, { timeout: 500 }).click({ force: true })
|
|
||||||
const newPwd = cy.get(interact.SPECTRUM_TEXTFIELD_INPUT).its('value')
|
|
||||||
cy.get(interact.SPECTRUM_BUTTON).contains("Reset password").click({ force: true })
|
|
||||||
|
|
||||||
// Login as new user and set password
|
|
||||||
cy.logOut()
|
|
||||||
cy.login("bbuser@test.com", newPwd)
|
|
||||||
for (let i = 0; i < 2; i++) {
|
|
||||||
cy.get(interact.SPECTRUM_TEXTFIELD_INPUT).eq(i).type("test")
|
|
||||||
}
|
|
||||||
cy.get(interact.SPECTRUM_BUTTON).contains("Reset your password").click({ force: true })
|
|
||||||
cy.logOut()
|
|
||||||
})
|
|
||||||
|
|
||||||
it("should verify Admin Portal", () => {
|
|
||||||
cy.login()
|
|
||||||
// Enable Development & Administration access
|
|
||||||
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')
|
|
||||||
})
|
|
||||||
}
|
|
||||||
// Login as new user
|
|
||||||
cy.logOut()
|
|
||||||
cy.login("bbuser@test.com", "test")
|
|
||||||
|
|
||||||
// Enter developer mode
|
|
||||||
cy.get(".user-dropdown .avatar > .icon", { timeout: 2000 }).click({ force: true })
|
|
||||||
cy.get(".spectrum-Popover[data-cy='user-menu']").within(() => {
|
|
||||||
cy.get(".spectrum-Menu-itemLabel").contains("Open developer mode").click({ force: true })
|
|
||||||
})
|
|
||||||
cy.get(".spectrum-SideNav")
|
|
||||||
.should('contain', 'Apps')
|
|
||||||
.and('contain', 'Users')
|
|
||||||
.and('contain', 'Auth')
|
|
||||||
.and('contain', 'Email')
|
|
||||||
.and('contain', 'Organisation')
|
|
||||||
.and('contain', 'Theming')
|
|
||||||
.and('contain', 'Update')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
|
@ -0,0 +1,123 @@
|
||||||
|
import filterTests from "../../support/filterTests"
|
||||||
|
const interact = require('../../support/interact')
|
||||||
|
|
||||||
|
filterTests(["smoke", "all"], () => {
|
||||||
|
context("Account Portals", () => {
|
||||||
|
|
||||||
|
const bbUserEmail = "bbuser@test.com"
|
||||||
|
|
||||||
|
before(() => {
|
||||||
|
cy.login()
|
||||||
|
cy.deleteApp("Cypress Tests")
|
||||||
|
cy.createApp("Cypress Tests")
|
||||||
|
|
||||||
|
// Create new user
|
||||||
|
cy.visit(`${Cypress.config().baseUrl}/builder`, { timeout: 1000})
|
||||||
|
cy.createUser(bbUserEmail)
|
||||||
|
cy.contains("bbuser").click()
|
||||||
|
cy.wait(500)
|
||||||
|
|
||||||
|
// Reset password
|
||||||
|
cy.get(".spectrum-ActionButton-label", { timeout: 2000 }).contains("Force password reset").click({ force: true })
|
||||||
|
|
||||||
|
cy.get(".spectrum-Dialog-grid")
|
||||||
|
.find(interact.SPECTRUM_TEXTFIELD_INPUT).invoke('val').as('pwd')
|
||||||
|
|
||||||
|
cy.get(interact.SPECTRUM_BUTTON).contains("Reset password").click({ force: true })
|
||||||
|
|
||||||
|
// Login as new user and set password
|
||||||
|
cy.logOut()
|
||||||
|
cy.get('@pwd').then((pwd) => {
|
||||||
|
cy.login(bbUserEmail, pwd)
|
||||||
|
})
|
||||||
|
|
||||||
|
for (let i = 0; i < 2; i++) {
|
||||||
|
cy.get(interact.SPECTRUM_TEXTFIELD_INPUT).eq(i).type("test")
|
||||||
|
}
|
||||||
|
cy.get(interact.SPECTRUM_BUTTON).contains("Reset your password").click({ force: true })
|
||||||
|
cy.logoutNoAppGrid()
|
||||||
|
})
|
||||||
|
|
||||||
|
it("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')
|
||||||
|
})
|
||||||
|
}
|
||||||
|
bbUserLogin()
|
||||||
|
|
||||||
|
// Verify available options for Admin portal
|
||||||
|
cy.get(".spectrum-SideNav")
|
||||||
|
.should('contain', 'Apps')
|
||||||
|
//.and('contain', 'Usage')
|
||||||
|
.and('contain', 'Users')
|
||||||
|
.and('contain', 'Auth')
|
||||||
|
.and('contain', 'Email')
|
||||||
|
.and('contain', 'Organisation')
|
||||||
|
.and('contain', 'Theming')
|
||||||
|
.and('contain', 'Update')
|
||||||
|
//.and('contain', 'Upgrade')
|
||||||
|
|
||||||
|
cy.logOut()
|
||||||
|
})
|
||||||
|
|
||||||
|
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 })
|
||||||
|
})
|
||||||
|
|
||||||
|
bbUserLogin()
|
||||||
|
|
||||||
|
// Verify available options for Admin portal
|
||||||
|
cy.get(interact.SPECTRUM_SIDENAV)
|
||||||
|
.should('contain', 'Apps')
|
||||||
|
//.and('contain', 'Usage')
|
||||||
|
.and('not.contain', 'Users')
|
||||||
|
.and('not.contain', 'Auth')
|
||||||
|
.and('not.contain', 'Email')
|
||||||
|
.and('not.contain', 'Organisation')
|
||||||
|
.and('contain', 'Theming')
|
||||||
|
.and('not.contain', 'Update')
|
||||||
|
.and('not.contain', 'Upgrade')
|
||||||
|
|
||||||
|
cy.logOut()
|
||||||
|
})
|
||||||
|
|
||||||
|
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 })
|
||||||
|
})
|
||||||
|
|
||||||
|
bbUserLogin()
|
||||||
|
|
||||||
|
// Verify Standard Portal
|
||||||
|
cy.get(interact.SPECTRUM_SIDENAV).should('not.exist') // No config sections
|
||||||
|
cy.get(interact.CREATE_APP_BUTTON).should('not.exist') // No create app button
|
||||||
|
cy.get(".app").should('not.exist') // No apps -> no roles assigned to user
|
||||||
|
cy.get(interact.CONTAINER).should('contain', bbUserEmail) // Message containing users email
|
||||||
|
})
|
||||||
|
|
||||||
|
const bbUserLogin = () => {
|
||||||
|
// Login as bbuser
|
||||||
|
cy.logOut()
|
||||||
|
cy.login(bbUserEmail, "test")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
|
@ -17,7 +17,7 @@ Cypress.Commands.add("login", (email, password) => {
|
||||||
if (url.includes("builder/auth/login") || url.includes("builder/admin")) {
|
if (url.includes("builder/auth/login") || url.includes("builder/admin")) {
|
||||||
// login
|
// login
|
||||||
cy.contains("Sign in to Budibase").then(() => {
|
cy.contains("Sign in to Budibase").then(() => {
|
||||||
if (email == null || password == null) {
|
if (email == null) {
|
||||||
cy.get("input").first().type("test@test.com")
|
cy.get("input").first().type("test@test.com")
|
||||||
cy.get('input[type="password"]').type("test")
|
cy.get('input[type="password"]').type("test")
|
||||||
} else {
|
} else {
|
||||||
|
@ -40,6 +40,16 @@ Cypress.Commands.add("logOut", () => {
|
||||||
cy.wait(2000)
|
cy.wait(2000)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Cypress.Commands.add("logoutNoAppGrid", () => {
|
||||||
|
// Logs user out when app grid is not present
|
||||||
|
cy.visit(`${Cypress.config().baseUrl}/builder`)
|
||||||
|
cy.get(".avatar > .icon").click({ force: true })
|
||||||
|
cy.get(".spectrum-Popover[data-cy='user-menu']").within(() => {
|
||||||
|
cy.get(".spectrum-Menu-item").contains("Log out").click({ force: true })
|
||||||
|
})
|
||||||
|
cy.wait(2000)
|
||||||
|
})
|
||||||
|
|
||||||
Cypress.Commands.add("createUser", email => {
|
Cypress.Commands.add("createUser", email => {
|
||||||
// quick hacky recorded way to create a user
|
// quick hacky recorded way to create a user
|
||||||
cy.contains("Users").click()
|
cy.contains("Users").click()
|
||||||
|
@ -123,7 +133,7 @@ Cypress.Commands.add("createApp", (name, addDefaultTable) => {
|
||||||
cy.get(".spectrum-ButtonGroup")
|
cy.get(".spectrum-ButtonGroup")
|
||||||
.contains("Create app")
|
.contains("Create app")
|
||||||
.click({ force: true })
|
.click({ force: true })
|
||||||
cy.wait(10000)
|
cy.wait(5000)
|
||||||
})
|
})
|
||||||
if (shouldCreateDefaultTable) {
|
if (shouldCreateDefaultTable) {
|
||||||
cy.createTable("Cypress Tests", true)
|
cy.createTable("Cypress Tests", true)
|
||||||
|
|
Loading…
Reference in a new issue