1
+ const selectItem = ( selector , itemValue ) => {
2
+ cy . get ( selector ) . click ( ) ;
3
+ cy . get ( "div[data-slot='popover']" )
4
+ . find ( `span:contains(${ itemValue } )` )
5
+ . click ( ) ;
6
+ } ;
7
+
1
8
describe ( 'Load' , ( ) => {
9
+ beforeEach ( ( ) => cy . visit ( '/' ) ) ;
2
10
it ( 'should navigate to index page' , ( ) => {
3
- cy . visit ( '/' ) ;
4
11
cy . get ( 'h4' ) . contains ( 'Kvitteringsskjema' ) ;
5
12
} ) ;
6
13
} ) ;
7
14
8
15
describe ( 'Form' , ( ) => {
16
+ beforeEach ( ( ) => cy . visit ( '/' ) ) ;
9
17
it ( 'should be able to fill in basic fields' , ( ) => {
10
18
cy . get ( '#name' ) . type ( 'John Doe' ) ;
11
19
cy . get ( '#mailFrom' ) . type ( 'jon@doe.com' ) ;
12
- cy . get ( '#mailTo' ) . type ( 'Webkom' ) ;
20
+ selectItem ( '#mailTo' , 'Webkom' ) ;
13
21
cy . get ( '#accountNumber' ) . type ( '1234 56 78903' ) ;
14
22
cy . get ( '#amount' ) . type ( '1000' ) ;
15
23
cy . get ( '#date' ) . type ( '1970-01-01' ) ;
@@ -19,6 +27,7 @@ describe('Form', () => {
19
27
} ) ;
20
28
21
29
describe ( 'Uploads' , ( ) => {
30
+ beforeEach ( ( ) => cy . visit ( '/' ) ) ;
22
31
it ( 'should be able to upload signature' , ( ) => {
23
32
cy . get ( '#signature' ) . attachFile ( 'abakus.png' ) ;
24
33
} ) ;
@@ -40,6 +49,7 @@ describe('Uploads', () => {
40
49
} ) ;
41
50
42
51
describe ( 'Signature drawing' , ( ) => {
52
+ beforeEach ( ( ) => cy . visit ( '/' ) ) ;
43
53
it ( 'should be possible to draw the signature' , ( ) => {
44
54
cy . get ( '#signButton' ) . click ( ) ;
45
55
cy . get ( 'h3' ) . contains ( 'Signer i feltet under' ) ;
@@ -49,8 +59,8 @@ describe('Signature drawing', () => {
49
59
} ) ;
50
60
51
61
describe ( 'Submit' , ( ) => {
62
+ beforeEach ( ( ) => cy . visit ( '/' ) ) ;
52
63
it ( 'should be possible to submit' , ( ) => {
53
- cy . visit ( '/' ) ;
54
64
// Set up a catch for the POST request
55
65
cy . intercept (
56
66
{
@@ -63,7 +73,7 @@ describe('Submit', () => {
63
73
// Fill in values
64
74
cy . get ( '#name' ) . type ( 'John Doe' ) ;
65
75
cy . get ( '#mailFrom' ) . type ( 'jon@doe.com' ) ;
66
- cy . get ( '#mailTo' ) . type ( 'Webkom' ) ;
76
+ selectItem ( '#mailTo' , 'Webkom' ) ;
67
77
cy . get ( '#accountNumber' ) . type ( '1234 56 78903' ) ;
68
78
cy . get ( '#amount' ) . type ( '1000' ) ;
69
79
cy . get ( '#date' ) . type ( '1970-01-01' ) ;
0 commit comments