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