Merge pull request #5162 from Budibase/cypress-testing

Moving assign/unassign user role type tests to test env only
This commit is contained in:
Mitch-Budibase 2022-03-30 12:38:38 +01:00 committed by GitHub
commit f67f2ce29b
1 changed files with 95 additions and 93 deletions

View File

@ -26,102 +26,104 @@ filterTests(["smoke", "all"], () => {
cy.get(".spectrum-Table").eq(0).contains("No rows found") cy.get(".spectrum-Table").eq(0).contains("No rows found")
}) })
it("should assign role types", () => { if (Cypress.env("TEST_ENV")) {
// 3 apps minimum required - to assign an app to each role type it("should assign role types", () => {
cy.request(`${Cypress.config().baseUrl}/api/applications?status=all`) // 3 apps minimum required - to assign an app to each role type
.its("body") cy.request(`${Cypress.config().baseUrl}/api/applications?status=all`)
.then(val => { .its("body")
if (val.length < 3) { .then(val => {
for (let i = 1; i < 3; i++) { if (val.length < 3) {
const uuid = () => Cypress._.random(0, 1e6) for (let i = 1; i < 3; i++) {
const name = uuid() const uuid = () => Cypress._.random(0, 1e6)
if(i < 1){ const name = uuid()
cy.createApp(name) if(i < 1){
} else { cy.createApp(name)
cy.visit(`${Cypress.config().baseUrl}/builder`) } else {
cy.wait(500) cy.visit(`${Cypress.config().baseUrl}/builder`)
cy.get(`[data-cy="create-app-btn"]`).click({ force: true }) cy.wait(500)
cy.createAppFromScratch(name) cy.get(`[data-cy="create-app-btn"]`).click({ force: true })
cy.createAppFromScratch(name)
}
} }
} }
}
})
// Navigate back to the user
cy.visit(`${Cypress.config().baseUrl}/builder`)
cy.wait(500)
cy.get(".spectrum-SideNav").contains("Users").click()
cy.wait(500)
cy.get(".spectrum-Table").contains("bbuser").click()
cy.wait(1000)
for (let i = 0; i < 3; i++) {
cy.get(".spectrum-Table")
.eq(1)
.find(".spectrum-Table-row")
.eq(0)
.find(".spectrum-Table-cell")
.eq(0)
.click()
cy.wait(500)
cy.get(".spectrum-Dialog-grid")
.contains("Choose an option")
.click()
.then(() => {
cy.wait(1000)
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(1000)
cy.get(".spectrum-Button")
.contains("Update role")
.click({ force: true })
}) })
} // Navigate back to the user
// Confirm roles exist within Configure roles table cy.visit(`${Cypress.config().baseUrl}/builder`)
cy.wait(2000) cy.wait(500)
cy.get(".spectrum-Table") cy.get(".spectrum-SideNav").contains("Users").click()
.eq(0) cy.wait(500)
.within(assginedRoles => { cy.get(".spectrum-Table").contains("bbuser").click()
expect(assginedRoles).to.contain("Admin") cy.wait(1000)
expect(assginedRoles).to.contain("Power") for (let i = 0; i < 3; i++) {
expect(assginedRoles).to.contain("Basic") cy.get(".spectrum-Table")
}) .eq(1)
}) .find(".spectrum-Table-row")
.eq(0)
it("should unassign role types", () => { .find(".spectrum-Table-cell")
// Set each app within Configure roles table to 'No Access' .eq(0)
cy.get(".spectrum-Table") .click()
.eq(0) cy.wait(500)
.find(".spectrum-Table-row") cy.get(".spectrum-Dialog-grid")
.its("length") .contains("Choose an option")
.then(len => { .click()
for (let i = 0; i < len; i++) { .then(() => {
cy.get(".spectrum-Table") cy.wait(1000)
.eq(0) if (i == 0) {
.find(".spectrum-Table-row") cy.get(".spectrum-Popover").contains("Admin").click()
.eq(0) }
.find(".spectrum-Table-cell") if (i == 1) {
.eq(0) cy.get(".spectrum-Popover").contains("Power").click()
.click() }
.then(() => { if (i == 2) {
cy.get(".spectrum-Picker").eq(1).click({ force: true }) cy.get(".spectrum-Popover").contains("Basic").click()
cy.wait(500) }
cy.get(".spectrum-Popover").contains("No Access").click() cy.wait(1000)
}) cy.get(".spectrum-Button")
cy.get(".spectrum-Button") .contains("Update role")
.contains("Update role") .click({ force: true })
.click({ force: true }) })
cy.wait(1000) }
} // Confirm roles exist within Configure roles table
}) cy.wait(2000)
// Confirm Configure roles table no longer has any apps in it cy.get(".spectrum-Table")
cy.get(".spectrum-Table").eq(0).contains("No rows found") .eq(0)
}) .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'
cy.get(".spectrum-Table")
.eq(0)
.find(".spectrum-Table-row")
.its("length")
.then(len => {
for (let i = 0; i < len; i++) {
cy.get(".spectrum-Table")
.eq(0)
.find(".spectrum-Table-row")
.eq(0)
.find(".spectrum-Table-cell")
.eq(0)
.click()
.then(() => {
cy.get(".spectrum-Picker").eq(1).click({ force: true })
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").eq(0).contains("No rows found")
})
}
it("should enable Developer access", () => { it("should enable Developer access", () => {
// Enable Developer access // Enable Developer access