add cypress guest-routes spec
This commit is contained in:
parent
910bc98197
commit
07f9746316
1 changed files with 41 additions and 0 deletions
41
frontend/blog_portal/cypress/e2e/guest_routes.cy.ts
Normal file
41
frontend/blog_portal/cypress/e2e/guest_routes.cy.ts
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
describe("guest route guards", function () {
|
||||
beforeEach(function () {
|
||||
cy.resetDb();
|
||||
cy.clearMail();
|
||||
});
|
||||
|
||||
it("redirects anonymous visitors away from /users/:displayName/posts/new", function () {
|
||||
cy.visit("/users/alice/posts/new");
|
||||
cy.location("pathname").should("eq", "/login");
|
||||
});
|
||||
|
||||
it("redirects authenticated visitors away from /login", function () {
|
||||
cy.seedConfirmedUser({
|
||||
email: "alice@example.com",
|
||||
displayName: "alice",
|
||||
password: "longenoughpassword",
|
||||
});
|
||||
cy.loginViaApi({
|
||||
email: "alice@example.com",
|
||||
password: "longenoughpassword",
|
||||
});
|
||||
|
||||
cy.visit("/login");
|
||||
cy.location("pathname").should("eq", "/");
|
||||
});
|
||||
|
||||
it("redirects authenticated visitors away from /signup", function () {
|
||||
cy.seedConfirmedUser({
|
||||
email: "alice@example.com",
|
||||
displayName: "alice",
|
||||
password: "longenoughpassword",
|
||||
});
|
||||
cy.loginViaApi({
|
||||
email: "alice@example.com",
|
||||
password: "longenoughpassword",
|
||||
});
|
||||
|
||||
cy.visit("/signup");
|
||||
cy.location("pathname").should("eq", "/");
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue