CreateScreen Tests
Updated the current createScreen test file: - Reworked a test related to access levels - Tests for screens of all access levels and deleting all screens (and starting new screen journey) - Added commands to delete screen and delete all screens
This commit is contained in:
parent
43b2f43b28
commit
c9448296de
|
@ -1,4 +1,5 @@
|
||||||
import filterTests from "../support/filterTests"
|
import filterTests from "../support/filterTests"
|
||||||
|
const interact = require('../support/interact')
|
||||||
|
|
||||||
filterTests(["smoke", "all"], () => {
|
filterTests(["smoke", "all"], () => {
|
||||||
context("Screen Tests", () => {
|
context("Screen Tests", () => {
|
||||||
|
@ -10,32 +11,44 @@ filterTests(["smoke", "all"], () => {
|
||||||
|
|
||||||
it("Should successfully create a screen", () => {
|
it("Should successfully create a screen", () => {
|
||||||
cy.createScreen("test")
|
cy.createScreen("test")
|
||||||
cy.get(".nav-items-container").within(() => {
|
cy.get(interact.BODY).within(() => {
|
||||||
cy.contains("/test").should("exist")
|
cy.contains("/test").should("exist")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it("Should update the url", () => {
|
it("Should update the url", () => {
|
||||||
cy.createScreen("test with spaces")
|
cy.createScreen("test with spaces")
|
||||||
cy.get(".nav-items-container").within(() => {
|
cy.get(interact.BODY).within(() => {
|
||||||
cy.contains("/test-with-spaces").should("exist")
|
cy.contains("/test-with-spaces").should("exist")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it("Should create a blank screen with the selected access level", () => {
|
it("should delete all screens then create first screen via button", () => {
|
||||||
cy.createScreen("admin only", "Admin")
|
cy.deleteAllScreens()
|
||||||
|
|
||||||
cy.get(".nav-items-container").within(() => {
|
cy.contains("Create first screen").click()
|
||||||
cy.contains("/admin-only").should("exist")
|
cy.get(interact.BODY, { timeout: 2000 }).should('contain', '/home')
|
||||||
})
|
})
|
||||||
|
|
||||||
cy.createScreen("open to all", "Public")
|
it("Should create and filter screens by access level", () => {
|
||||||
|
const accessLevels = ["Basic", "Admin", "Public", "Power"]
|
||||||
|
|
||||||
cy.get(".nav-items-container").within(() => {
|
for (const access of accessLevels){
|
||||||
cy.contains("/open-to-all").should("exist")
|
// Create screen with specified access level
|
||||||
//The access level should now be set to admin. Previous screens should be filtered.
|
cy.createScreen(access, access)
|
||||||
cy.get(".nav-item").contains("/test-screen").should("not.exist")
|
// Filter by access level and confirm screen visible
|
||||||
})
|
cy.filterScreensAccessLevel(access)
|
||||||
|
cy.get(interact.BODY).within(() => {
|
||||||
|
cy.get(interact.NAV_ITEM).should('contain', access.toLowerCase())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Filter by All screens - Confirm all screens visible
|
||||||
|
cy.filterScreensAccessLevel("All screens")
|
||||||
|
cy.get(interact.BODY).should('contain', accessLevels[0])
|
||||||
|
.and('contain', accessLevels[1])
|
||||||
|
.and('contain', accessLevels[2])
|
||||||
|
.and('contain', accessLevels[3])
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -638,6 +638,43 @@ Cypress.Commands.add("filterScreensAccessLevel", accessLevel => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Cypress.Commands.add("deleteScreen", screen => {
|
||||||
|
// Navigates to Design section and deletes specified screen
|
||||||
|
cy.contains("Design").click()
|
||||||
|
cy.get(".body").within(() => {
|
||||||
|
cy.contains(screen)
|
||||||
|
.siblings(".actions")
|
||||||
|
.within(() => {
|
||||||
|
cy.get(".spectrum-Icon").click({ force: true })
|
||||||
|
})
|
||||||
|
})
|
||||||
|
cy.get(".spectrum-Menu > .spectrum-Menu-item > .spectrum-Menu-itemLabel")
|
||||||
|
.contains("Delete")
|
||||||
|
.click()
|
||||||
|
|
||||||
|
cy.get(
|
||||||
|
".spectrum-Dialog-grid > .spectrum-ButtonGroup > .confirm-wrap > .spectrum-Button"
|
||||||
|
).click({ force: true })
|
||||||
|
cy.get(".spectrum-Dialog-grid", { timeout: 10000 }).should("not.exist")
|
||||||
|
})
|
||||||
|
|
||||||
|
Cypress.Commands.add("deleteAllScreens", () => {
|
||||||
|
// Deletes all screens
|
||||||
|
cy.get(".body")
|
||||||
|
.find(".nav-item")
|
||||||
|
.its("length")
|
||||||
|
.then(len => {
|
||||||
|
for (let i = 0; i < len; i++) {
|
||||||
|
cy.get(".body > .nav-item")
|
||||||
|
.eq(0)
|
||||||
|
.invoke("text")
|
||||||
|
.then(text => {
|
||||||
|
cy.deleteScreen(text.trim())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
// NAVIGATION
|
// NAVIGATION
|
||||||
Cypress.Commands.add("navigateToFrontend", () => {
|
Cypress.Commands.add("navigateToFrontend", () => {
|
||||||
// Clicks on Design tab and then the Home nav item
|
// Clicks on Design tab and then the Home nav item
|
||||||
|
|
Loading…
Reference in New Issue