File tree Expand file tree Collapse file tree 9 files changed +23047
-1460
lines changed Expand file tree Collapse file tree 9 files changed +23047
-1460
lines changed Original file line number Diff line number Diff line change @@ -148,6 +148,18 @@ exit
148
148
make consume
149
149
```
150
150
151
+ ## Cypress
152
+
153
+ We have added cypress for front-end testing, for now it is in webapp directory.
154
+ It is recommended to remove it went deploy in production for security reasons:
155
+
156
+ ### Open cypress for testing
157
+ In the main directory
158
+ ```
159
+ cd src/webapp
160
+ ./node_modules/.bin/cypress open
161
+ ```
162
+
151
163
## What's next?
152
164
153
165
### Configuring Git
Original file line number Diff line number Diff line change
1
+ const { defineConfig } = require ( "cypress" ) ;
2
+
3
+ module . exports = defineConfig ( {
4
+ e2e : {
5
+ setupNodeEvents ( on , config ) {
6
+ // implement node event listeners here
7
+ } ,
8
+ baseUrl : 'http://symfony-boilerplate.localhost' ,
9
+ } ,
10
+ } ) ;
Original file line number Diff line number Diff line change
1
+ describe ( 'Create new user' , ( ) => {
2
+ it ( 'login as admin and create new user' , ( ) => {
3
+ // go to login page
4
+ cy . visit ( '/login' )
5
+ cy . get ( '#input-email' ) . type ( 'admin@admin.com' )
6
+ cy . get ( '#input-password' ) . type ( 'admin' )
7
+ cy . get ( 'button[type=submit]' ) . click ( )
8
+
9
+ // we should be redirected to /dashboard
10
+ cy . url ( )
11
+ . should ( 'include' , '/dashboard' )
12
+ . then ( ( ) => {
13
+ // click on users menu
14
+ cy . get ( '.pt-3 > .nav > :nth-child(6) > .nav-item > .nav-link' )
15
+ . should ( 'have.attr' , 'href' , '/dashboard/admin/users' )
16
+ . click ( )
17
+ . then ( ( ) => {
18
+ // click on create button
19
+ cy . get ( '.m-auto > .btn-primary' )
20
+ . should ( 'have.attr' , 'href' , '/dashboard/admin/users/create' )
21
+ . click ( )
22
+
23
+ // field all required fields
24
+ cy . get ( '#input-first-name' ) . type ( 'new-user' )
25
+ cy . get ( '#input-last-name' ) . type ( 'test' )
26
+ cy . get ( '#input-email' ) . type ( 'newuser@test.com' )
27
+ cy . get ( '#input-locale' ) . select ( 'FR' )
28
+ cy . get ( '#input-role' ) . select ( 'USER' )
29
+ cy . get ( 'form > .btn' )
30
+ . click ( ) // submit the form
31
+ . then ( ( ) => {
32
+ cy . url ( ) . should ( 'match' , / ( \/ d a s h b o a r d \/ a d m i n \/ u s e r s \/ ) / )
33
+ } )
34
+ } )
35
+ } )
36
+ } )
37
+ } )
Original file line number Diff line number Diff line change
1
+ describe ( 'login process' , ( ) => {
2
+
3
+ it ( 'login as simple user' , ( ) => {
4
+ // go to login page
5
+ cy . visit ( '/login' )
6
+ cy . get ( '#input-email' ) . type ( 'user@user.com' )
7
+ cy . get ( '#input-password' ) . type ( 'user' )
8
+ cy . get ( 'button[type=submit]' ) . click ( )
9
+
10
+ // we should be redirected to /dashboard
11
+ cy . url ( ) . should ( 'include' , '/dashboard' )
12
+ } )
13
+
14
+
15
+ it ( 'login as admin' , ( ) => {
16
+ // go to login page
17
+ cy . visit ( '/login' )
18
+ cy . get ( '#input-email' ) . type ( 'admin@admin.com' )
19
+ cy . get ( '#input-password' ) . type ( 'admin' )
20
+ cy . get ( 'button[type=submit]' ) . click ( )
21
+
22
+ // we should be redirected to /dashboard
23
+ cy . url ( ) . should ( 'include' , '/dashboard' )
24
+ } )
25
+ } )
Original file line number Diff line number Diff line change
1
+ describe ( 'Log out process' , ( ) => {
2
+ it ( 'Log out' , ( ) => {
3
+ // go to login page
4
+ cy . visit ( '/login' )
5
+ cy . get ( '#input-email' ) . type ( 'admin@admin.com' )
6
+ cy . get ( '#input-password' ) . type ( 'admin' )
7
+ cy . get ( 'button[type=submit]' ) . click ( )
8
+
9
+ // we should be redirected to /dashboard
10
+ cy . url ( )
11
+ . should ( 'include' , '/dashboard' )
12
+ . then ( ( ) => {
13
+ // dropdown user menu
14
+ cy . get ( 'li.nav-item.b-nav-dropdown a[role=button]' )
15
+ . first ( )
16
+ . click ( )
17
+ . then ( ( ) => {
18
+ // click on log out button
19
+ cy . get ( ':nth-child(2) > .dropdown-item' ) . click ( )
20
+ } )
21
+ } )
22
+ } )
23
+ } )
Original file line number Diff line number Diff line change
1
+ describe ( 'Submit ' , ( ) => {
2
+ it ( 'login as simple user' , ( ) => {
3
+ // go to login page
4
+ cy . visit ( '/reset-password' )
5
+ cy . get ( '#input-email' ) . type ( 'user@user.com' )
6
+ cy . get ( 'button[type=submit]' ) . click ( )
7
+
8
+ // check form the message of email sent
9
+ cy . get ( 'h5' ) . contains ( 'user@user.com' )
10
+ cy . get ( '.card-body .text-center p' ) . should ( 'have.length' , 2 )
11
+ } )
12
+ } )
You can’t perform that action at this time.
0 commit comments