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+
18describe ( 'Load' , ( ) => {
9+ beforeEach ( ( ) => cy . visit ( '/' ) ) ;
210 it ( 'should navigate to index page' , ( ) => {
3- cy . visit ( '/' ) ;
411 cy . get ( 'h4' ) . contains ( 'Kvitteringsskjema' ) ;
512 } ) ;
613} ) ;
714
815describe ( 'Form' , ( ) => {
16+ beforeEach ( ( ) => cy . visit ( '/' ) ) ;
917 it ( 'should be able to fill in basic fields' , ( ) => {
1018 cy . get ( '#name' ) . type ( 'John Doe' ) ;
1119 cy . get ( '#mailFrom' ) . type ( '[email protected] ' ) ; 12- cy . get ( '#mailTo' ) . type ( 'Webkom' ) ;
20+ selectItem ( '#mailTo' , 'Webkom' ) ;
1321 cy . get ( '#accountNumber' ) . type ( '1234 56 78903' ) ;
1422 cy . get ( '#amount' ) . type ( '1000' ) ;
1523 cy . get ( '#date' ) . type ( '1970-01-01' ) ;
@@ -19,6 +27,7 @@ describe('Form', () => {
1927} ) ;
2028
2129describe ( 'Uploads' , ( ) => {
30+ beforeEach ( ( ) => cy . visit ( '/' ) ) ;
2231 it ( 'should be able to upload signature' , ( ) => {
2332 cy . get ( '#signature' ) . attachFile ( 'abakus.png' ) ;
2433 } ) ;
@@ -40,6 +49,7 @@ describe('Uploads', () => {
4049} ) ;
4150
4251describe ( 'Signature drawing' , ( ) => {
52+ beforeEach ( ( ) => cy . visit ( '/' ) ) ;
4353 it ( 'should be possible to draw the signature' , ( ) => {
4454 cy . get ( '#signButton' ) . click ( ) ;
4555 cy . get ( 'h3' ) . contains ( 'Signer i feltet under' ) ;
@@ -49,8 +59,8 @@ describe('Signature drawing', () => {
4959} ) ;
5060
5161describe ( 'Submit' , ( ) => {
62+ beforeEach ( ( ) => cy . visit ( '/' ) ) ;
5263 it ( 'should be possible to submit' , ( ) => {
53- cy . visit ( '/' ) ;
5464 // Set up a catch for the POST request
5565 cy . intercept (
5666 {
@@ -63,7 +73,7 @@ describe('Submit', () => {
6373 // Fill in values
6474 cy . get ( '#name' ) . type ( 'John Doe' ) ;
6575 cy . get ( '#mailFrom' ) . type ( '[email protected] ' ) ; 66- cy . get ( '#mailTo' ) . type ( 'Webkom' ) ;
76+ selectItem ( '#mailTo' , 'Webkom' ) ;
6777 cy . get ( '#accountNumber' ) . type ( '1234 56 78903' ) ;
6878 cy . get ( '#amount' ) . type ( '1000' ) ;
6979 cy . get ( '#date' ) . type ( '1970-01-01' ) ;
0 commit comments