@@ -29,7 +29,11 @@ describe("Sign Up tests", () => {
2929 cy . get ( locators . signup . REPEATED_PASSWORD ) . type ( testUser . password ) ;
3030 cy . checkRecaptcha ( ) ;
3131 cy . get ( locators . signup . BTN_SUBMIT ) . click ( ) ;
32- cy . contains ( "Campo obrigatório" ) . should ( "be.visible" ) ;
32+ cy . get ( locators . signup . ERROR_NAME ) . should ( "be.visible" ) ;
33+ cy . get ( locators . signup . ERROR_NAME ) . should (
34+ "contain" ,
35+ "Please, insert your name"
36+ ) ;
3337 } ) ;
3438
3539 it ( "Should show validation error when email is invalid" , ( ) => {
@@ -39,7 +43,8 @@ describe("Sign Up tests", () => {
3943 cy . get ( locators . signup . REPEATED_PASSWORD ) . type ( testUser . password ) ;
4044 cy . checkRecaptcha ( ) ;
4145 cy . get ( locators . signup . BTN_SUBMIT ) . click ( ) ;
42- cy . contains ( "E-mail inválido" ) . should ( "be.visible" ) ;
46+ cy . get ( locators . signup . ERROR_EMAIL ) . should ( "be.visible" ) ;
47+ cy . get ( locators . signup . ERROR_EMAIL ) . should ( "contain" , "Invalid e-mail" ) ;
4348 } ) ;
4449
4550 it ( "Should show validation error when passwords don't match" , ( ) => {
@@ -49,7 +54,11 @@ describe("Sign Up tests", () => {
4954 cy . get ( locators . signup . REPEATED_PASSWORD ) . type ( "DifferentPassword123!" ) ;
5055 cy . checkRecaptcha ( ) ;
5156 cy . get ( locators . signup . BTN_SUBMIT ) . click ( ) ;
52- cy . contains ( "senhas não são iguais" ) . should ( "be.visible" ) ;
57+ cy . get ( locators . signup . ERROR_REPEATED_PASSWORD ) . should ( "be.visible" ) ;
58+ cy . get ( locators . signup . ERROR_REPEATED_PASSWORD ) . should (
59+ "contain" ,
60+ "The two passwords that you entered do not match"
61+ ) ;
5362 } ) ;
5463
5564 it ( "Should show error when CAPTCHA is not completed" , ( ) => {
@@ -58,7 +67,7 @@ describe("Sign Up tests", () => {
5867 cy . get ( locators . signup . PASSWORD ) . type ( testUser . password ) ;
5968 cy . get ( locators . signup . REPEATED_PASSWORD ) . type ( testUser . password ) ;
6069 cy . get ( locators . signup . BTN_SUBMIT ) . click ( ) ;
61- cy . contains ( "Campo obrigatório " ) . should ( "be.visible" ) ;
70+ cy . contains ( "Field is required " ) . should ( "be.visible" ) ;
6271 } ) ;
6372
6473 it ( "Should successfully create account with valid data and CAPTCHA" , ( ) => {
@@ -67,21 +76,19 @@ describe("Sign Up tests", () => {
6776 cy . get ( locators . signup . PASSWORD ) . type ( testUser . password ) ;
6877 cy . get ( locators . signup . REPEATED_PASSWORD ) . type ( testUser . password ) ;
6978 cy . checkRecaptcha ( ) ;
70- cy . get ( locators . signup . BTN_SUBMIT ) . click ( ) ;
7179
72- // After successful registration, user should be redirected to home
73- cy . url ( ) . should ( "eq" , "http://localhost:3000/" ) ;
74- cy . contains ( "Cadastro realizado com sucesso" ) . should ( "be.visible" ) ;
75- } ) ;
80+ // Intercept the registration API call
81+ cy . intercept ( "POST" , "/api/user/register" ) . as ( "registerUser" ) ;
82+ cy . intercept ( "/api/.ory/sessions/whoami" ) . as ( "confirmLogin" ) ;
7683
77- it ( "Should show error when email already exists" , ( ) => {
78- cy . get ( locators . signup . NAME ) . type ( "Duplicate User" ) ;
79- cy . get ( locators . signup . EMAIL ) . type ( "existing@aletheiafact.org" ) ;
80- cy . get ( locators . signup . PASSWORD ) . type ( testUser . password ) ;
81- cy . get ( locators . signup . REPEATED_PASSWORD ) . type ( testUser . password ) ;
82- cy . checkRecaptcha ( ) ;
8384 cy . get ( locators . signup . BTN_SUBMIT ) . click ( ) ;
8485
85- cy . contains ( / u s u á r i o j á e x i s t e | j á c a d a s t r a d o / i) . should ( "be.visible" ) ;
86+ // Wait for registration to complete
87+ cy . wait ( "@registerUser" , { timeout : 30000 } ) ;
88+ cy . wait ( "@confirmLogin" , { timeout : 30000 } ) ;
89+
90+ // After successful registration, user should be redirected to home
91+ cy . url ( { timeout : 30000 } ) . should ( "eq" , "http://localhost:3000/" ) ;
92+ cy . contains ( "Sign-up successful" ) . should ( "be.visible" ) ;
8693 } ) ;
8794} ) ;
0 commit comments