2022-01-21 13:43:27 +01:00
|
|
|
import filterTests from "../support/filterTests"
|
2021-11-15 16:25:58 +01:00
|
|
|
|
2022-01-21 13:43:27 +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()
|
2021-11-15 16:25:58 +01:00
|
|
|
})
|
2022-01-21 13:43:27 +01:00
|
|
|
|
|
|
|
it("should create a user", () => {
|
|
|
|
cy.createUser("bbuser@test.com")
|
|
|
|
cy.get(".spectrum-Table-body").should('contain', 'bbuser')
|
|
|
|
})
|
|
|
|
|
|
|
|
it("should confirm there is No Access for a New User", () => {
|
|
|
|
// Click into the user
|
|
|
|
cy.contains("bbuser").click()
|
2022-01-18 17:02:42 +01:00
|
|
|
cy.wait(500)
|
2022-01-21 13:43:27 +01:00
|
|
|
// Get No Access table - Confirm it has apps in it
|
|
|
|
cy.get(".spectrum-Table").eq(1).should('not.contain', 'No rows found')
|
|
|
|
// Get Configure Roles table - Confirm it has no apps
|
|
|
|
cy.get(".spectrum-Table").eq(0).contains('No rows found')
|
|
|
|
})
|
|
|
|
|
|
|
|
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()
|
|
|
|
cy.createApp(name)
|
|
|
|
}
|
2021-11-15 16:25:58 +01:00
|
|
|
}
|
2022-01-21 13:43:27 +01:00
|
|
|
})
|
|
|
|
// Navigate back to the user
|
|
|
|
cy.visit(`${Cypress.config().baseUrl}/builder`)
|
2022-02-18 18:59:33 +01:00
|
|
|
cy.wait(500)
|
2022-01-21 13:43:27 +01:00
|
|
|
cy.get(".spectrum-SideNav").contains("Users").click()
|
|
|
|
cy.wait(500)
|
2022-02-18 18:59:33 +01:00
|
|
|
cy.get(".spectrum-Table").contains("bbuser").click()
|
|
|
|
cy.wait(1000)
|
2022-01-21 13:43:27 +01:00
|
|
|
for (let i = 0; i < 3; i++) {
|
|
|
|
cy.get(".spectrum-Table-body").eq(1).find('tr').eq(0).click()
|
|
|
|
cy.wait(500)
|
|
|
|
cy.get(".spectrum-Dialog-grid").contains("Choose an option").click().then(() => {
|
|
|
|
cy.wait(500)
|
|
|
|
if (i == 0) {
|
|
|
|
cy.get(".spectrum-Popover").contains("Admin").click()
|
|
|
|
}
|
|
|
|
if (i == 1) {
|
|
|
|
cy.get(".spectrum-Popover").contains("Power").click()
|
|
|
|
}
|
|
|
|
if (i == 2) {
|
|
|
|
cy.get(".spectrum-Popover").contains("Basic").click()
|
|
|
|
}
|
|
|
|
cy.wait(500)
|
|
|
|
cy.get(".spectrum-Button").contains("Update role").click({ force: true })
|
|
|
|
})
|
2021-11-15 16:25:58 +01:00
|
|
|
}
|
2022-01-21 13:43:27 +01:00
|
|
|
// Confirm roles exist within Configure roles table
|
2021-11-15 16:25:58 +01:00
|
|
|
cy.wait(500)
|
2022-01-21 13:43:27 +01:00
|
|
|
cy.get(".spectrum-Table-body").eq(0).within((assginedRoles) => {
|
|
|
|
expect(assginedRoles).to.contain("Admin")
|
|
|
|
expect(assginedRoles).to.contain("Power")
|
|
|
|
expect(assginedRoles).to.contain("Basic")
|
2021-11-15 16:25:58 +01:00
|
|
|
})
|
|
|
|
})
|
2022-01-21 13:43:27 +01:00
|
|
|
|
|
|
|
it("should unassign role types", () => {
|
|
|
|
// Set each app within Configure roles table to 'No Access'
|
|
|
|
cy.get(".spectrum-Table-body").eq(0).find('tr').its('length').then((len) => {
|
|
|
|
for (let i = 0; i < len; i ++){
|
|
|
|
cy.get(".spectrum-Table-body").eq(0).find('tr').eq(0).click().then(() => {
|
2022-02-18 18:59:33 +01:00
|
|
|
cy.get(".spectrum-Picker").eq(1).click({ force: true })
|
2022-01-21 13:43:27 +01:00
|
|
|
cy.wait(500)
|
|
|
|
cy.get(".spectrum-Popover").contains("No Access").click()
|
|
|
|
})
|
|
|
|
cy.get(".spectrum-Button").contains("Update role").click({ force: true })
|
|
|
|
cy.wait(1000)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
// Confirm Configure roles table no longer has any apps in it
|
|
|
|
cy.get(".spectrum-Table-body").eq(0).contains('No rows found')
|
2021-11-15 16:25:58 +01:00
|
|
|
})
|
2022-01-21 13:43:27 +01:00
|
|
|
|
|
|
|
it("should enable Developer access", () => {
|
|
|
|
// Enable Developer access
|
|
|
|
cy.get(".field").eq(4).within(() => {
|
|
|
|
cy.get(".spectrum-Switch-input").click({ force: true })
|
|
|
|
})
|
|
|
|
// No Access table should now be empty
|
|
|
|
cy.get(".container").contains("No Access").parent().within(() => {
|
|
|
|
cy.get(".spectrum-Table").contains("No rows found")
|
|
|
|
})
|
|
|
|
|
|
|
|
// Each app within Configure roles should have Admin access
|
|
|
|
cy.get(".spectrum-Table-body").eq(0).find('tr').its('length').then((len) => {
|
|
|
|
for (let i = 0; i < len; i++) {
|
|
|
|
cy.get(".spectrum-Table-body").eq(0).find('tr').eq(i).contains("Admin")
|
|
|
|
cy.wait(500)
|
|
|
|
}
|
|
|
|
})
|
2021-11-15 16:25:58 +01:00
|
|
|
})
|
2022-01-21 13:43:27 +01:00
|
|
|
|
|
|
|
it("should disable Developer access", () => {
|
|
|
|
// Disable Developer access
|
|
|
|
cy.get(".field").eq(4).within(() => {
|
|
|
|
cy.get(".spectrum-Switch-input").click({ force: true })
|
|
|
|
})
|
|
|
|
// Configure roles table should now be empty
|
|
|
|
cy.get(".container").contains("Configure roles").parent().within(() => {
|
|
|
|
cy.get(".spectrum-Table").contains("No rows found")
|
|
|
|
})
|
2021-11-18 14:47:41 +01:00
|
|
|
})
|
2021-11-15 16:25:58 +01:00
|
|
|
|
2022-01-21 13:43:27 +01:00
|
|
|
it("should delete a user", () => {
|
|
|
|
// Click Delete user button
|
|
|
|
cy.get(".spectrum-Button").contains("Delete user").click({force: true}).then(() => {
|
|
|
|
// Confirm deletion within modal
|
2021-11-15 16:25:58 +01:00
|
|
|
cy.wait(500)
|
2022-01-21 13:43:27 +01:00
|
|
|
cy.get(".spectrum-Dialog-grid").within(() => {
|
|
|
|
cy.get(".spectrum-Button").contains("Delete user").click({force: true})
|
|
|
|
cy.wait(4000)
|
|
|
|
})
|
2021-11-15 16:25:58 +01:00
|
|
|
})
|
2022-01-21 13:43:27 +01:00
|
|
|
cy.get(".spectrum-Table-body").should("not.have.text", "bbuser")
|
2021-11-15 16:25:58 +01:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|