@@ -15,57 +15,56 @@ describe("user sign up test with mailslurp plugin", function () {
15
15
} )
16
16
} ) ;
17
17
//</gen>
18
- //<gen>cypress_plugin_01
19
18
it ( "01 - can load the demo application" , function ( ) {
19
+ //<gen>cypress_plugin_01
20
20
// get wrapped email address and assert contains a mailslurp email address
21
21
expect ( this . emailAddress ) . to . contain ( "@mailslurp" ) ;
22
22
// visit the demo application
23
23
cy . visit ( "https://playground.mailslurp.com" )
24
24
cy . title ( ) . should ( 'contain' , 'React App' ) ;
25
+ //</gen>
26
+ //<gen>cypress_plugin_02
27
+ cy . then ( function ( ) {
28
+ // click sign up and fill out the form
29
+ cy . get ( "[data-test=sign-in-create-account-link]" ) . click ( )
30
+ // use the email address and a test password
31
+ cy . get ( "[name=email]" ) . type ( this . emailAddress ) . trigger ( 'change' ) ;
32
+ cy . get ( "[name=password]" ) . type ( 'test-password' ) . trigger ( 'change' ) ;
33
+ // click the submit button
34
+ cy . get ( "[data-test=sign-up-create-account-button]" ) . click ( ) ;
35
+ //</gen>
36
+ } )
37
+ //<gen>cypress_plugin_03
38
+ cy . then ( function ( ) {
39
+ // app will send user an email containing a code, use mailslurp to wait for the latest email
40
+ cy . mailslurp ( )
41
+ // use inbox id and a timeout of 30 seconds
42
+ . then ( mailslurp => mailslurp . waitForLatestEmail ( this . inboxId , 30000 , true ) )
43
+ // extract the confirmation code from the email body
44
+ . then ( email => / .* v e r i f i c a t i o n c o d e i s ( \d { 6 } ) .* / . exec ( email . body ! ! ) ! ! [ 1 ] )
45
+ // fill out the confirmation form and submit
46
+ . then ( code => {
47
+ cy . get ( "[name=code]" ) . type ( code ) . trigger ( 'change' ) ;
48
+ cy . get ( "[data-test=confirm-sign-up-confirm-button]" ) . click ( ) ;
49
+ } )
50
+ } )
51
+ //</gen>
52
+ //<gen>cypress_plugin_04
53
+ // fill out sign in form
54
+ cy . then ( function ( ) {
55
+ // use the email address and a test password
56
+ cy . get ( "[data-test=username-input]" ) . type ( this . emailAddress ) . trigger ( 'change' ) ;
57
+ cy . get ( "[data-test=sign-in-password-input]" ) . type ( 'test-password' ) . trigger ( 'change' ) ;
58
+ // click the submit button
59
+ cy . get ( "[data-test=sign-in-sign-in-button]" ) . click ( ) ;
60
+ } ) ;
61
+ //</gen>
62
+ //<gen>cypress_plugin_05
63
+ // can see authorized welcome screen
64
+ cy . then ( function ( ) {
65
+ // click sign up and fill out the form
66
+ cy . get ( "h1" ) . should ( "contain" , "Welcome" ) ;
67
+ } )
68
+ //</gen>
25
69
} ) ;
26
- //</gen>
27
- //<gen>cypress_plugin_02
28
- // use function instead of arrow syntax to access aliased values on this
29
- it ( "02 - can sign up using email address" , function ( ) {
30
- // click sign up and fill out the form
31
- cy . get ( "[data-test=sign-in-create-account-link]" ) . click ( )
32
- // use the email address and a test password
33
- cy . get ( "[name=email]" ) . type ( this . emailAddress ) . trigger ( 'change' ) ;
34
- cy . get ( "[name=password]" ) . type ( 'test-password' ) . trigger ( 'change' ) ;
35
- // click the submit button
36
- cy . get ( "[data-test=sign-up-create-account-button]" ) . click ( ) ;
37
- } ) ;
38
- //</gen>
39
- //<gen>cypress_plugin_03
40
- it ( "03 - can receive confirmation code by email" , function ( ) {
41
- // app will send user an email containing a code, use mailslurp to wait for the latest email
42
- cy . mailslurp ( )
43
- // use inbox id and a timeout of 30 seconds
44
- . then ( mailslurp => mailslurp . waitForLatestEmail ( this . inboxId , 30000 , true ) )
45
- // extract the confirmation code from the email body
46
- . then ( email => / .* v e r i f i c a t i o n c o d e i s ( \d { 6 } ) .* / . exec ( email . body ! ! ) ! ! [ 1 ] )
47
- // fill out the confirmation form and submit
48
- . then ( code => {
49
- cy . get ( "[name=code]" ) . type ( code ) . trigger ( 'change' ) ;
50
- cy . get ( "[data-test=confirm-sign-up-confirm-button]" ) . click ( ) ;
51
- } )
52
- } ) ;
53
- //</gen>
54
- //<gen>cypress_plugin_04
55
- // fill out sign in form
56
- it ( "04 - can sign in with confirmed account" , function ( ) {
57
- // use the email address and a test password
58
- cy . get ( "[data-test=username-input]" ) . type ( this . emailAddress ) . trigger ( 'change' ) ;
59
- cy . get ( "[data-test=sign-in-password-input]" ) . type ( 'test-password' ) . trigger ( 'change' ) ;
60
- // click the submit button
61
- cy . get ( "[data-test=sign-in-sign-in-button]" ) . click ( ) ;
62
- } ) ;
63
- //</gen>
64
- //<gen>cypress_plugin_05
65
- // can see authorized welcome screen
66
- it ( "05 - can see welcome screen" , function ( ) {
67
- // click sign up and fill out the form
68
- cy . get ( "h1" ) . should ( "contain" , "Welcome" ) ;
69
- } ) ;
70
- //</gen>
71
70
} ) ;
0 commit comments