export class AddToOrderTemplateModule { constructor ( private contextSelector = 'ish-product-listing' ) { } addNewOrderTemplate ( name ) { cy . wait ( 500 ) ; cy . get ( '.modal-body input' ) . type ( name ) ; cy . get ( '.modal-footer button.btn-primary' ) . click ( ) ; } addProductToOrderTemplateFromPage ( title = '' , modal = false ) { if ( modal ) { cy . get ( `[data-testing-id="radio-${ title }"]` ) . click ( ) ; cy . get ( '.modal-footer button.btn-primary' ) . click ( ) ; } this . closeAddProductToOrderTemplateModal ( 'link' ) ; } addProductToOrderTemplateFromList ( product , title , modal = true ) { if ( modal ) { cy . get ( this . contextSelector ) . find ( `ish-product-item div[data-testing-sku="${ product }"] ish-product-add-to-order-template button` ) . click ( ) ; if ( title ) { cy . get ( `[data-testing-id="radio-${ title }"]` ) . click ( ) ; } cy . get ( '.modal-footer button.btn-primary' ) . click ( ) ; this . closeAddProductToOrderTemplateModal ( 'link' ) ; } else { cy . get ( this . contextSelector ) . find ( `ish-product-item div[data-testing-sku="${ product }"] ish-product-add-to-order-template button` ) . click ( ) ; this . closeAddProductToOrderTemplateModal ( 'link' ) ; } } private closeAddProductToOrderTemplateModal ( mode ) { cy . wait ( 500 ) ; mode === 'link' ? cy . get ( '[data-testing-id="order-template-success-link"] a' ) . click ( ) : cy . get ( '.modal-header button' ) . click ( ) ; } }