2022-01-21 13:43:27 +01:00
|
|
|
import filterTests from "../support/filterTests"
|
2022-06-06 17:03:41 +02:00
|
|
|
const interact = require('../support/interact')
|
2021-11-15 16:25:58 +01:00
|
|
|
|
2022-02-23 14:14:28 +01:00
|
|
|
filterTests(["smoke", "all"], () => {
|
2022-02-17 15:06:17 +01:00
|
|
|
context("Create a User and Assign Roles", () => {
|
2022-01-21 13:43:27 +01:00
|
|
|
before(() => {
|
|
|
|
cy.login()
|
2022-05-17 14:32:29 +02:00
|
|
|
cy.deleteApp("Cypress Tests")
|
2022-05-17 13:40:06 +02:00
|
|
|
cy.createApp("Cypress Tests")
|
2021-11-15 16:25:58 +01:00
|
|
|
})
|
2022-01-21 13:43:27 +01:00
|
|
|
|
|
|
|
it("should create a user", () => {
|
2022-03-29 00:21:38 +02:00
|
|
|
cy.visit(`${Cypress.config().baseUrl}/builder`)
|
|
|
|
cy.wait(1000)
|
2022-01-21 13:43:27 +01:00
|
|
|
cy.createUser("bbuser@test.com")
|
2022-06-06 17:03:41 +02:00
|
|
|
cy.get(interact.SPECTRUM_TABLE).should("contain", "bbuser")
|
2022-01-21 13:43:27 +01:00
|
|
|
})
|
2022-02-23 14:14:28 +01:00
|
|
|
|
2022-01-21 13:43:27 +01:00
|
|
|
it("should confirm there is No Access for a New User", () => {
|
|
|
|
// Click into the user
|
|
|
|
cy.contains("bbuser").click()
|
|
|
|
// Get No Access table - Confirm it has apps in it
|
2022-06-08 19:08:45 +02:00
|
|
|
cy.get(interact.SPECTRUM_TABLE, { timeout: 500 }).eq(1).should("not.contain", "No rows found")
|
2022-01-21 13:43:27 +01:00
|
|
|
// Get Configure Roles table - Confirm it has no apps
|
2022-06-06 17:03:41 +02:00
|
|
|
cy.get(interact.SPECTRUM_TABLE).eq(0).contains("No rows found")
|
2022-01-21 13:43:27 +01:00
|
|
|
})
|
2022-02-23 14:14:28 +01:00
|
|
|
|
2022-03-29 19:32:36 +02:00
|
|
|
if (Cypress.env("TEST_ENV")) {
|
|
|
|
it("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")
|
|
|
|
.then(val => {
|
|
|
|
if (val.length < 3) {
|
|
|
|
for (let i = 1; i < 3; i++) {
|
|
|
|
const uuid = () => Cypress._.random(0, 1e6)
|
|
|
|
const name = uuid()
|
|
|
|
if(i < 1){
|
|
|
|
cy.createApp(name)
|
|
|
|
} else {
|
|
|
|
cy.visit(`${Cypress.config().baseUrl}/builder`)
|
2022-06-08 19:08:45 +02:00
|
|
|
cy.get(interact.CREATE_APP_BUTTON, { timeout: 1000 }).click({ force: true })
|
2022-03-29 19:32:36 +02:00
|
|
|
cy.createAppFromScratch(name)
|
|
|
|
}
|
2022-03-29 00:21:38 +02:00
|
|
|
}
|
2022-02-23 14:14:28 +01:00
|
|
|
}
|
2022-03-29 19:32:36 +02:00
|
|
|
})
|
|
|
|
// Navigate back to the user
|
|
|
|
cy.visit(`${Cypress.config().baseUrl}/builder`)
|
|
|
|
cy.wait(500)
|
2022-06-06 17:03:41 +02:00
|
|
|
cy.get(interact.SPECTRUM_SIDENAV).contains("Users").click()
|
2022-03-29 19:32:36 +02:00
|
|
|
cy.wait(500)
|
2022-06-06 17:03:41 +02:00
|
|
|
cy.get(interact.SPECTRUM_TABLE).contains("bbuser").click()
|
2022-03-29 19:32:36 +02:00
|
|
|
cy.wait(1000)
|
|
|
|
for (let i = 0; i < 3; i++) {
|
2022-06-06 17:03:41 +02:00
|
|
|
cy.get(interact.SPECTRUM_TABLE, { timeout: 3000})
|
2022-03-29 19:32:36 +02:00
|
|
|
.eq(1)
|
2022-06-06 17:03:41 +02:00
|
|
|
.find(interact.SPECTRUM_TABLE_ROW)
|
2022-03-29 19:32:36 +02:00
|
|
|
.eq(0)
|
2022-06-06 17:03:41 +02:00
|
|
|
.find(interact.SPECTRUM_TABLE_CELL)
|
2022-03-29 19:32:36 +02:00
|
|
|
.eq(0)
|
|
|
|
.click()
|
|
|
|
cy.wait(500)
|
2022-06-06 17:03:41 +02:00
|
|
|
cy.get(interact.SPECTRUM_DIALOG_GRID)
|
2022-03-29 19:32:36 +02:00
|
|
|
.contains("Choose an option")
|
|
|
|
.click()
|
|
|
|
.then(() => {
|
|
|
|
cy.wait(1000)
|
|
|
|
if (i == 0) {
|
2022-06-06 17:03:41 +02:00
|
|
|
cy.get(interact.SPECTRUM_MENU).contains("Admin").click({ force: true })
|
2022-03-29 19:32:36 +02:00
|
|
|
}
|
2022-05-05 12:22:04 +02:00
|
|
|
else if (i == 1) {
|
2022-06-06 17:03:41 +02:00
|
|
|
cy.get(interact.SPECTRUM_MENU).contains("Power").click({ force: true })
|
2022-03-29 19:32:36 +02:00
|
|
|
}
|
2022-05-05 12:22:04 +02:00
|
|
|
else if (i == 2) {
|
2022-06-06 17:03:41 +02:00
|
|
|
cy.get(interact.SPECTRUM_MENU).contains("Basic").click({ force: true })
|
2022-03-29 19:32:36 +02:00
|
|
|
}
|
|
|
|
cy.wait(1000)
|
2022-06-06 17:03:41 +02:00
|
|
|
cy.get(interact.SPECTRUM_BUTTON)
|
2022-03-29 19:32:36 +02:00
|
|
|
.contains("Update role")
|
|
|
|
.click({ force: true })
|
|
|
|
})
|
2022-05-17 13:40:06 +02:00
|
|
|
cy.reload()
|
2022-03-29 19:32:36 +02:00
|
|
|
}
|
|
|
|
// Confirm roles exist within Configure roles table
|
|
|
|
cy.wait(2000)
|
2022-06-06 17:03:41 +02:00
|
|
|
cy.get(interact.SPECTRUM_TABLE)
|
2022-02-23 14:14:28 +01:00
|
|
|
.eq(0)
|
2022-03-29 19:32:36 +02:00
|
|
|
.within(assginedRoles => {
|
|
|
|
expect(assginedRoles).to.contain("Admin")
|
|
|
|
expect(assginedRoles).to.contain("Power")
|
|
|
|
expect(assginedRoles).to.contain("Basic")
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
it("should unassign role types", () => {
|
|
|
|
// Set each app within Configure roles table to 'No Access'
|
2022-06-06 17:03:41 +02:00
|
|
|
cy.get(interact.SPECTRUM_TABLE)
|
2022-02-23 14:53:15 +01:00
|
|
|
.eq(0)
|
2022-06-06 17:03:41 +02:00
|
|
|
.find(interact.SPECTRUM_TABLE_ROW)
|
2022-03-29 19:32:36 +02:00
|
|
|
.its("length")
|
|
|
|
.then(len => {
|
|
|
|
for (let i = 0; i < len; i++) {
|
2022-06-06 17:03:41 +02:00
|
|
|
cy.get(interact.SPECTRUM_TABLE)
|
2022-03-29 19:32:36 +02:00
|
|
|
.eq(0)
|
2022-06-06 17:03:41 +02:00
|
|
|
.find(interact.SPECTRUM_TABLE_ROW)
|
2022-03-29 19:32:36 +02:00
|
|
|
.eq(0)
|
2022-06-06 17:03:41 +02:00
|
|
|
.find(interact.SPECTRUM_TABLE_CELL)
|
2022-03-29 19:32:36 +02:00
|
|
|
.eq(0)
|
|
|
|
.click()
|
|
|
|
.then(() => {
|
2022-06-06 17:03:41 +02:00
|
|
|
cy.get(interact.SPECTRUM_PICKER).eq(1).click({ force: true })
|
2022-03-29 19:32:36 +02:00
|
|
|
cy.wait(500)
|
2022-06-06 17:03:41 +02:00
|
|
|
cy.get(interact.SPECTRUM_POPOVER).contains("No Access").click()
|
2022-03-29 19:32:36 +02:00
|
|
|
})
|
2022-06-06 17:03:41 +02:00
|
|
|
cy.get(interact.SPECTRUM_BUTTON)
|
2022-03-29 19:32:36 +02:00
|
|
|
.contains("Update role")
|
|
|
|
.click({ force: true })
|
|
|
|
cy.wait(1000)
|
2022-02-23 14:14:28 +01:00
|
|
|
}
|
2022-01-21 13:43:27 +01:00
|
|
|
})
|
2022-03-29 19:32:36 +02:00
|
|
|
// Confirm Configure roles table no longer has any apps in it
|
2022-06-06 17:03:41 +02:00
|
|
|
cy.get(interact.SPECTRUM_TABLE).eq(0).contains("No rows found")
|
2022-03-29 19:32:36 +02:00
|
|
|
})
|
|
|
|
}
|
2022-02-23 14:14:28 +01:00
|
|
|
|
2022-01-21 13:43:27 +01:00
|
|
|
it("should enable Developer access", () => {
|
|
|
|
// Enable Developer access
|
2022-06-06 17:03:41 +02:00
|
|
|
cy.get(interact.FIELD)
|
2022-02-23 14:14:28 +01:00
|
|
|
.eq(4)
|
|
|
|
.within(() => {
|
2022-06-06 17:03:41 +02:00
|
|
|
cy.get(interact.SPECTRUM_SWITCH_INPUT).click({ force: true })
|
2022-02-23 14:14:28 +01:00
|
|
|
})
|
2022-01-21 13:43:27 +01:00
|
|
|
// No Access table should now be empty
|
2022-06-06 17:03:41 +02:00
|
|
|
cy.get(interact.CONTAINER)
|
2022-02-23 14:14:28 +01:00
|
|
|
.contains("No Access")
|
|
|
|
.parent()
|
|
|
|
.within(() => {
|
2022-06-06 17:03:41 +02:00
|
|
|
cy.get(interact.SPECTRUM_TABLE).contains("No rows found")
|
2022-02-23 14:14:28 +01:00
|
|
|
})
|
|
|
|
|
2022-01-21 13:43:27 +01:00
|
|
|
// Each app within Configure roles should have Admin access
|
2022-06-06 17:03:41 +02:00
|
|
|
cy.get(interact.SPECTRUM_TABLE)
|
2022-02-23 14:14:28 +01:00
|
|
|
.eq(0)
|
2022-06-06 17:03:41 +02:00
|
|
|
.find(interact.SPECTRUM_TABLE_ROW)
|
2022-02-23 14:14:28 +01:00
|
|
|
.its("length")
|
|
|
|
.then(len => {
|
|
|
|
for (let i = 0; i < len; i++) {
|
2022-06-06 17:03:41 +02:00
|
|
|
cy.get(interact.SPECTRUM_TABLE)
|
2022-02-23 14:14:28 +01:00
|
|
|
.eq(0)
|
2022-06-06 17:03:41 +02:00
|
|
|
.find(interact.SPECTRUM_TABLE_ROW)
|
2022-02-23 14:14:28 +01:00
|
|
|
.eq(i)
|
|
|
|
.contains("Admin")
|
|
|
|
cy.wait(500)
|
|
|
|
}
|
|
|
|
})
|
2021-11-15 16:25:58 +01:00
|
|
|
})
|
2022-02-23 14:14:28 +01:00
|
|
|
|
2022-01-21 13:43:27 +01:00
|
|
|
it("should disable Developer access", () => {
|
|
|
|
// Disable Developer access
|
2022-02-23 14:14:28 +01:00
|
|
|
cy.get(".field")
|
|
|
|
.eq(4)
|
|
|
|
.within(() => {
|
|
|
|
cy.get(".spectrum-Switch-input").click({ force: true })
|
|
|
|
})
|
2022-01-21 13:43:27 +01:00
|
|
|
// Configure roles table should now be empty
|
2022-02-23 14:14:28 +01:00
|
|
|
cy.get(".container")
|
|
|
|
.contains("Configure roles")
|
|
|
|
.parent()
|
|
|
|
.within(() => {
|
2022-06-06 17:03:41 +02:00
|
|
|
cy.get(interact.SPECTRUM_TABLE).contains("No rows found")
|
2022-02-23 14:14:28 +01:00
|
|
|
})
|
2021-11-18 14:47:41 +01:00
|
|
|
})
|
2022-02-23 14:14:28 +01:00
|
|
|
|
2022-06-08 19:08:45 +02:00
|
|
|
it("Should edit user details", () => {
|
|
|
|
// Add First name
|
|
|
|
cy.get(".field").eq(2).within(() => {
|
|
|
|
cy.get(interact.SPECTRUM_TEXTFIELD_INPUT).type("bb")
|
|
|
|
})
|
|
|
|
// Add Last name
|
|
|
|
cy.get(".field").eq(3).within(() => {
|
|
|
|
cy.get(interact.SPECTRUM_TEXTFIELD_INPUT).type("test")
|
|
|
|
})
|
|
|
|
// Navigate away and back to the user
|
|
|
|
cy.contains("Apps").click()
|
|
|
|
cy.contains("Users").click()
|
|
|
|
cy.contains("bbuser").click()
|
|
|
|
|
|
|
|
// Confirm details have been saved
|
|
|
|
cy.get(".field").eq(2).within(() => {
|
|
|
|
cy.get(interact.SPECTRUM_TEXTFIELD_INPUT).should('have.value', "bb")
|
|
|
|
})
|
|
|
|
cy.get(".field").eq(3).within(() => {
|
|
|
|
cy.get(interact.SPECTRUM_TEXTFIELD_INPUT).should('have.value', "test")
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2022-01-21 13:43:27 +01:00
|
|
|
it("should delete a user", () => {
|
|
|
|
// Click Delete user button
|
2022-06-06 17:03:41 +02:00
|
|
|
cy.get(interact.SPECTRUM_BUTTON)
|
2022-02-23 14:14:28 +01:00
|
|
|
.contains("Delete user")
|
|
|
|
.click({ force: true })
|
|
|
|
.then(() => {
|
|
|
|
// Confirm deletion within modal
|
|
|
|
cy.wait(500)
|
2022-06-06 17:03:41 +02:00
|
|
|
cy.get(interact.SPECTRUM_DIALOG_GRID).within(() => {
|
|
|
|
cy.get(interact.SPECTRUM_BUTTON)
|
2022-02-23 14:14:28 +01:00
|
|
|
.contains("Delete user")
|
|
|
|
.click({ force: true })
|
|
|
|
cy.wait(4000)
|
|
|
|
})
|
2022-01-21 13:43:27 +01:00
|
|
|
})
|
2022-06-06 17:03:41 +02:00
|
|
|
cy.get(interact.SPECTRUM_TABLE).should("not.have.text", "bbuser")
|
2021-11-15 16:25:58 +01:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|