import 'cypress-file-upload' ; Cypress . Commands . add ( 'dataCy' , ( value ) => { cy . get ( `[data-cy="${ value }"]` ) ; } ) ; Cypress . Commands . add ( 'selectValue' , ( target , value ) => { cy . dataCy ( target ) . parent ( ) . click ( ) ; cy . contains ( value ) . click ( ) ; } ) ; Cypress . Commands . add ( 'selectValueByIndex' , ( target , index ) => { cy . dataCy ( target ) . parent ( ) . click ( ) ; cy . get ( `li[data-value=${ index }]` ) . click ( ) ; } ) ; Cypress . Commands . add ( 'selectMultiple' , ( target , values ) => { values . forEach ( ( value ) => { cy . dataCy ( target ) . parent ( ) . click ( ) ; cy . contains ( value ) . click ( ) ; } ) ; } ) ; Cypress . Commands . add ( 'selectDate' , ( target , day ) => { cy . dataCy ( target ) . filter ( ':visible' ) . click ( ) ; cy . get ( '.MuiCalendarPicker-root' ) . within ( ( ) => { cy . contains ( 'button' , day ) . filter ( ':visible' ) . click ( ) ; } ) ; } ) ; Cypress . Commands . add ( 'inputRequired' , ( target , neighbor ) => { cy . dataCy ( target ) . then ( ( elem ) => { cy . clearInput ( target ) ; cy . dataCy ( neighbor ) . click ( ) ; const fieldName = elem . parent ( ) . parent ( ) . find ( 'label' ) . text ( ) . replace ( /\s[*]/ , '' ) ; cy . contains ( `${ fieldName } is a required field` ) ; } ) ; } ) ; Cypress . Commands . add ( 'clearInput' , ( target ) => { cy . dataCy ( target ) . clear ( ) ; } ) ; Cypress . Commands . add ( 'navigateMenu' , ( target ) => { cy . dataCy ( target ) . filter ( ':visible' ) . click ( ) ; } ) ; Cypress . Commands . add ( 'closeAllNotifications' , ( ) => { cy . get ( '.Toastify__toast' ) . click ( { multiple : true , force : true , waitForAnimations : true , } ) . should ( 'not.exist' ) ; } ) ; Cypress . Commands . add ( 'notification' , ( text ) => { cy . get ( '.Toastify__toast' ) . contains ( text ) ; cy . closeAllNotifications ( ) ; } ) ; Cypress . Commands . add ( 'attachDocument' , ( uploadDataCy ) => { cy . dataCy ( uploadDataCy ) . find ( 'input' ) . attachFile ( { filePath : 'testDocument.json' , mimeType : 'image/png' , encoding : 'binary' , } ) ; } ) ; Cypress . Commands . add ( 'attachMultipleDocuments' , ( uploadDataCy , count ) => { const files = new Array ( count ) . fill ( { filePath : 'testDocument.json' , mimeType : 'image/png' , encoding : 'binary' , } ) ; cy . dataCy ( uploadDataCy ) . find ( 'input' ) . attachFile ( files ) ; } ) ; Cypress . Commands . add ( 'inputHasValue' , ( inputCy , value ) => { cy . dataCy ( inputCy ) . should ( 'have.value' , value ) ; } ) ; Cypress . Commands . add ( 'nextStep' , ( ) => { cy . contains ( 'Next Step' ) . should ( 'not.be.disabled' ) . click ( ) ; } ) ; Cypress . Commands . add ( 'submitForm' , ( ) => { cy . contains ( 'Submit' ) . should ( 'not.be.disabled' ) . click ( ) ; } ) ;