1+ import UserBuilder from "../../../libs/user.builder" ;
2+
13describe ( "Page Signup" , function ( ) {
4+ before ( function ( ) {
5+ Cypress . Cookies . debug ( true ) ;
6+ } ) ;
7+
28 it ( "Open page on Desktop" , function ( ) {
39 cy . visit ( "/auth/signup" ) ;
410 } ) ;
@@ -26,7 +32,7 @@ describe("Page Signup", function() {
2632 cy . get ( "input[name=password]" ) ;
2733 } ) ;
2834
29- it ( "Send form without filling in the inputs" , function ( ) {
35+ it ( "Send the form without filling in the inputs" , function ( ) {
3036 cy . visit ( "/auth/signup" ) ;
3137 cy . contains ( "Enviar" ) . click ( ) ;
3238
@@ -35,32 +41,61 @@ describe("Page Signup", function() {
3541 cy . contains ( "Senha é obrigatória" ) ;
3642 } ) ;
3743
38- it ( "Send form with name invalid" , function ( ) {
44+ it ( "Send the form with name invalid that has only one char" , function ( ) {
45+ const { name } = UserBuilder . nameInvalid ( ) ;
46+
3947 cy . visit ( "/auth/signup" ) ;
40- cy . get ( "input[name=name]" ) . type ( "a" ) ;
48+ cy . get ( "input[name=name]" ) . type ( name ) ;
4149 cy . contains ( "Enviar" ) . click ( ) ;
4250 cy . contains ( "Nome tem que ter 2 ou mais caracteres" ) ;
4351 } ) ;
4452
45- it ( "Send form with email invalid" , function ( ) {
53+ it ( "Send the form with email invalid" , function ( ) {
54+ const { email } = UserBuilder . emailInvalid ( ) ;
55+
4656 cy . visit ( "/auth/signup" ) ;
47- cy . get ( "input[name=email]" ) . type ( "marco" ) ;
57+ cy . get ( "input[name=email]" ) . type ( email ) ;
4858 cy . contains ( "Enviar" ) . click ( ) ;
4959 cy . contains ( "Preencha com email válido" ) ;
5060 } ) ;
5161
52- it ( "Send form with password invalid" , function ( ) {
62+ it ( "Send the form with password invalid" , function ( ) {
63+ const { password } = UserBuilder . passwordInvalid ( ) ;
64+
5365 cy . visit ( "/auth/signup" ) ;
54- cy . get ( "input[name=password]" ) . type ( "1234567" ) ;
66+ cy . get ( "input[name=password]" ) . type ( password ) ;
5567 cy . contains ( "Enviar" ) . click ( ) ;
5668 cy . contains ( "Senha tem que ter 8 ou mais caracteres" ) ;
5769 } ) ;
5870
59- it ( "Send form with all fields valid" , function ( ) {
71+ it ( "Send the form with the fields name, email and password valid" , function ( ) {
72+ const { name, email, password } = UserBuilder . randomUserInfo ( ) ;
73+
74+ cy . visit ( "/auth/signup" ) ;
75+ cy . get ( "input[name=name]" ) . type ( name ) ;
76+ cy . get ( "input[name=email]" ) . type ( email ) ;
77+ cy . get ( "input[name=password]" ) . type ( password ) ;
78+ cy . contains ( "Enviar" ) . click ( ) ;
79+ cy . location ( "pathname" ) . should ( "include" , "dashboard" ) ;
80+ } ) ;
81+
82+ it ( "Verify if the cookie jwt was create" , function ( ) {
83+ const { name, email, password } = UserBuilder . randomUserInfo ( ) ;
84+
85+ cy . clearCookies ( ) ;
6086 cy . visit ( "/auth/signup" ) ;
61- cy . get ( "input[name=name]" ) . type ( "Henri" ) ;
62- cy . get ( "input[name=email]" ) . type ( "marco.bruno.br@gmail.com" ) ;
63- cy . get ( "input[name=password]" ) . type ( "q1w2e3r4" ) ;
87+ cy . get ( "input[name=name]" ) . type ( name ) ;
88+ cy . get ( "input[name=email]" ) . type ( email ) ;
89+ cy . get ( "input[name=password]" ) . type ( password ) ;
6490 cy . contains ( "Enviar" ) . click ( ) ;
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 - Z a - z 0 - 9 - _ = ] + \. [ A - Z a - z 0 - 9 - _ = ] + \. ? [ A - Z a - z 0 - 9 - _ .+ / = ] * $ /
98+ ) ;
99+ } ) ;
65100 } ) ;
66101} ) ;
0 commit comments