@@ -4,27 +4,33 @@ describe('Sign Up', () => {
4
4
beforeEach ( ( ) => {
5
5
if ( Cypress . env ( 'USE_MOCK' ) ) {
6
6
// While Mocking always return a successful status code
7
- cy . intercept ( 'POST' , '/api/auth/signup/coordinator ' , {
7
+ cy . intercept ( 'POST' , '/api/auth/signup' , {
8
8
statusCode : 200 ,
9
- } ) . as ( 'signUpCoordinator' ) ;
10
-
11
- cy . intercept ( 'POST' , '/api/auth/signup/host' , { statusCode : 200 } ) . as (
12
- 'signUpHost' ,
13
- ) ;
9
+ } ) . as ( 'signUp' ) ;
14
10
} else {
15
11
// cy.intercept without a request will not stub out the real API call
16
- cy . intercept ( 'POST' , '/api/auth/signup/coordinator' ) . as (
17
- 'signUpCoordinator' ,
18
- ) ;
19
- cy . intercept ( 'POST' , '/api/auth/signup/host' ) . as ( 'signUpHost' ) ;
12
+ cy . intercept ( 'POST' , '/api/auth/signup' ) . as ( 'signUp' ) ;
20
13
}
14
+
15
+ cy . intercept ( 'GET' , '/api/auth/session' , req => {
16
+ req . reply ( {
17
+ statusCode : 401 ,
18
+ } ) ;
19
+ } ) . as ( 'session' ) ;
20
+
21
+ cy . intercept ( 'GET' , '/api/auth/refresh' , req => {
22
+ req . reply ( {
23
+ statusCode : 401 ,
24
+ } ) ;
25
+ } ) . as ( 'refresh' ) ;
21
26
} ) ;
22
27
23
28
it ( 'user can sign up as a coordinator' , ( ) => {
24
29
const user = {
25
30
firstName : faker . person . firstName ( ) ,
26
31
lastName : faker . person . lastName ( ) ,
27
32
email : faker . internet . email ( ) ,
33
+ role : 'coordinator' ,
28
34
password : 'Test123!' ,
29
35
} ;
30
36
@@ -38,7 +44,7 @@ describe('Sign Up', () => {
38
44
. should ( 'be.enabled' )
39
45
. click ( ) ;
40
46
41
- cy . url ( ) . should ( 'include' , '/signup/coordinator ' ) ;
47
+ cy . url ( ) . should ( 'include' , '/signup' ) ;
42
48
43
49
cy . findByRole ( 'button' , { name : / s i g n u p / i} ) . should ( 'be.disabled' ) ;
44
50
@@ -50,9 +56,7 @@ describe('Sign Up', () => {
50
56
. should ( 'be.enabled' )
51
57
. click ( ) ;
52
58
53
- cy . wait ( '@signUpCoordinator' )
54
- . its ( 'request.body' )
55
- . should ( 'deep.equal' , user ) ;
59
+ cy . wait ( '@signUp' ) . its ( 'request.body' ) . should ( 'deep.equal' , user ) ;
56
60
57
61
cy . url ( ) . should ( 'include' , `signup/success?email=${ user . email } ` ) ;
58
62
} ) ;
@@ -62,6 +66,7 @@ describe('Sign Up', () => {
62
66
firstName : faker . person . firstName ( ) ,
63
67
lastName : faker . person . lastName ( ) ,
64
68
email : faker . internet . email ( ) ,
69
+ role : 'host' ,
65
70
password : 'Test123!' ,
66
71
} ;
67
72
@@ -75,7 +80,7 @@ describe('Sign Up', () => {
75
80
. should ( 'be.enabled' )
76
81
. click ( ) ;
77
82
78
- cy . url ( ) . should ( 'include' , '/signup/host ' ) ;
83
+ cy . url ( ) . should ( 'include' , '/signup' ) ;
79
84
80
85
cy . findByRole ( 'button' , { name : / s i g n u p / i} ) . should ( 'be.disabled' ) ;
81
86
@@ -87,7 +92,7 @@ describe('Sign Up', () => {
87
92
. should ( 'be.enabled' )
88
93
. click ( ) ;
89
94
90
- cy . wait ( '@signUpHost ' ) . its ( 'request.body' ) . should ( 'deep.equal' , user ) ;
95
+ cy . wait ( '@signUp ' ) . its ( 'request.body' ) . should ( 'deep.equal' , user ) ;
91
96
92
97
cy . url ( ) . should ( 'include' , `signup/success?email=${ user . email } ` ) ;
93
98
} ) ;
0 commit comments