Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests for error pages #223

Merged
merged 4 commits into from
Mar 31, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions cypress/integration/errorPages.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
describe("catch error codes and display corresponding error page", function () {
const baseUrl = "http://localhost:" + Cypress.env("port") + "/"

it("should redirect to 401 page if no granted access", () => {
cy.visit(baseUrl + "home")
cy.contains(".MuiAlert-message", "401 Authorization Error")
})

it("should redirect to 403 page if response status code is 403 ", () => {
cy.intercept(
{
method: "GET",
url: "/folders",
},
{
statusCode: 403,
}
)
cy.visit(baseUrl)
cy.get('[alt="CSC Login"]').click()
cy.contains(".MuiAlert-message", "403 Forbidden Error")
})

it("should redirect to 404 page on unknown route", () => {
cy.visit(baseUrl)
cy.get('[alt="CSC Login"]').click()
cy.visit(baseUrl + "home/unknownroute")
cy.contains(".MuiAlert-message", "404 Not Found")
})

it("should redirect to 500 page if response status code is 500 ", () => {
cy.intercept(
{
method: "GET",
url: "/folders",
},
{
statusCode: 500,
}
)
cy.visit(baseUrl)
cy.get('[alt="CSC Login"]').click()
cy.contains(".MuiAlert-message", "500 Internal Server Error")
})
})