@@ -8,7 +8,7 @@ describe('Login', () => {
88 } )
99
1010 cy . visitAsGuest ( )
11- cy . findByLabelText ( 'Email' ) . type ( 'admin @trytalo.com' )
11+ cy . findByLabelText ( 'Email' ) . type ( 'dev @trytalo.com' )
1212 cy . findByLabelText ( 'Password' ) . type ( 'password' )
1313 cy . findByText ( 'Login' ) . click ( )
1414
@@ -24,10 +24,41 @@ describe('Login', () => {
2424 } )
2525
2626 cy . visitAsGuest ( )
27- cy . findByLabelText ( 'Email' ) . type ( 'admin @trytalo.com' )
27+ cy . findByLabelText ( 'Email' ) . type ( 'dev @trytalo.com' )
2828 cy . findByLabelText ( 'Password' ) . type ( 'passwor' )
2929 cy . findByText ( 'Login' ) . click ( )
3030
3131 cy . findByText ( 'Incorrect email address or password' ) . should ( 'exist' )
3232 } )
33+
34+ it ( 'should redirect to the intended route after logging in' , ( ) => {
35+ cy . intercept ( 'POST' , 'http://talo.api/public/users/login' , {
36+ statusCode : 200 ,
37+ fixture : 'responses/auth/dev'
38+ } )
39+
40+ cy . visitAsGuest ( '/account' )
41+ cy . findByLabelText ( 'Email' ) . type ( 'dev@trytalo.com' )
42+ cy . findByLabelText ( 'Password' ) . type ( 'password' )
43+ cy . findByText ( 'Login' ) . click ( )
44+
45+ cy . findByText ( 'Dev' ) . should ( 'exist' )
46+ cy . findByText ( 'dev@trytalo.com' ) . should ( 'exist' )
47+ cy . location ( 'pathname' ) . should ( 'eq' , '/account' )
48+ } )
49+
50+ it ( 'should redirect to the dashboard after logging in if the intended route does not exist' , ( ) => {
51+ cy . intercept ( 'POST' , 'http://talo.api/public/users/login' , {
52+ statusCode : 200 ,
53+ fixture : 'responses/auth/dev'
54+ } )
55+
56+ cy . visitAsGuest ( '/does-not-exist' )
57+ cy . findByLabelText ( 'Email' ) . type ( 'dev@trytalo.com' )
58+ cy . findByLabelText ( 'Password' ) . type ( 'password' )
59+ cy . findByText ( 'Login' ) . click ( )
60+
61+ cy . findByText ( 'Superstatic dashboard' ) . should ( 'exist' )
62+ cy . location ( 'pathname' ) . should ( 'eq' , '/' )
63+ } )
3364} )
0 commit comments