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
b83316a237
commit
f396e33018
|
@ -1,4 +1,5 @@
|
|||
import filterTests from "../support/filterTests"
|
||||
const interact = require('../support/interact')
|
||||
|
||||
filterTests(["smoke", "all"], () => {
|
||||
context("Screen Tests", () => {
|
||||
|
@ -10,32 +11,44 @@ filterTests(["smoke", "all"], () => {
|
|||
|
||||
it("Should successfully create a screen", () => {
|
||||
cy.createScreen("test")
|
||||
cy.get(".nav-items-container").within(() => {
|
||||
cy.get(interact.BODY).within(() => {
|
||||
cy.contains("/test").should("exist")
|
||||
})
|
||||
})
|
||||
|
||||
it("Should update the url", () => {
|
||||
cy.createScreen("test with spaces")
|
||||
cy.get(".nav-items-container").within(() => {
|
||||
cy.get(interact.BODY).within(() => {
|
||||
cy.contains("/test-with-spaces").should("exist")
|
||||
})
|
||||
})
|
||||
|
||||
it("Should create a blank screen with the selected access level", () => {
|
||||
cy.createScreen("admin only", "Admin")
|
||||
it("should delete all screens then create first screen via button", () => {
|
||||
cy.deleteAllScreens()
|
||||
|
||||
cy.contains("Create first screen").click()
|
||||
cy.get(interact.BODY, { timeout: 2000 }).should('contain', '/home')
|
||||
})
|
||||
|
||||
cy.get(".nav-items-container").within(() => {
|
||||
cy.contains("/admin-only").should("exist")
|
||||
})
|
||||
it("Should create and filter screens by access level", () => {
|
||||
const accessLevels = ["Basic", "Admin", "Public", "Power"]
|
||||
|
||||
cy.createScreen("open to all", "Public")
|
||||
for (const access of accessLevels){
|
||||
// Create screen with specified access level
|
||||
cy.createScreen(access, access)
|
||||
// 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())
|
||||
})
|
||||
}
|
||||
|
||||
cy.get(".nav-items-container").within(() => {
|
||||
cy.contains("/open-to-all").should("exist")
|
||||
//The access level should now be set to admin. Previous screens should be filtered.
|
||||
cy.get(".nav-item").contains("/test-screen").should("not.exist")
|
||||
})
|
||||
// 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
|
||||
Cypress.Commands.add("navigateToFrontend", () => {
|
||||
// Clicks on Design tab and then the Home nav item
|
||||
|
|
Loading…
Reference in New Issue