Skip to content

Commit fc05daa

Browse files
committed
✅ Test that verify if the jwt cookie was save
1 parent 1e4e09e commit fc05daa

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

cypress/integration/pages/Signup/index.test.js

+16-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import UserBuilder from "../../../libs/user.builder";
22

33
describe("Page Signup", function() {
4+
before(function() {
5+
Cypress.Cookies.debug(true);
6+
});
7+
48
it("Open page on Desktop", function() {
59
cy.visit("/auth/signup");
610
});
@@ -66,26 +70,32 @@ describe("Page Signup", function() {
6670

6771
it("Send the form with the fields name, email and password valid", function() {
6872
const { name, email, password } = UserBuilder.randomUserInfo();
69-
console.log(name);
7073

7174
cy.visit("/auth/signup");
7275
cy.get("input[name=name]").type(name);
7376
cy.get("input[name=email]").type(email);
7477
cy.get("input[name=password]").type(password);
7578
cy.contains("Enviar").click();
79+
cy.location("pathname").should("include", "dashboard");
7680
});
7781

78-
it("Send the form with all fields valid and verify if the JWT cookie is save", function() {
82+
it("Verify if the cookie jwt was create", function() {
7983
const { name, email, password } = UserBuilder.randomUserInfo();
80-
Cypress.Cookies.debug(true);
8184

85+
cy.clearCookies();
8286
cy.visit("/auth/signup");
8387
cy.get("input[name=name]").type(name);
8488
cy.get("input[name=email]").type(email);
8589
cy.get("input[name=password]").type(password);
8690
cy.contains("Enviar").click();
87-
cy.clearCookie("jjj");
88-
cy.setCookie("jjj", "thing");
89-
cy.getCookie("jjj").should("have.property", "value", "thing");
91+
cy.location("pathname").should("include", "dashboard");
92+
cy.contains("Dashboard").then(function() {
93+
cy.getCookie("jwt")
94+
.should("have.property", "value")
95+
.and(
96+
"match",
97+
/^[A-Za-z0-9-_=]+\.[A-Za-z0-9-_=]+\.?[A-Za-z0-9-_.+/=]*$/
98+
);
99+
});
90100
});
91101
});

0 commit comments

Comments
 (0)