export class AddToWishlistModule { constructor ( private contextSelector = 'ish-product-listing' ) { } addProductToWishlistFromPage ( title = '' , modal = false ) { if ( modal ) { cy . get ( `[data-testing-id="radio-${ title }"]` ) . click ( ) ; cy . get ( '.modal-footer button.btn-primary' ) . click ( ) ; } this . closeAddProductToWishlistModal ( 'link' ) ; } addProductToWishlistFromList ( product , title , modal = true ) { if ( modal ) { cy . get ( this . contextSelector ) . find ( `ish-product-item div[data-testing-sku="${ product }"] button.add-to-wishlist` ) . click ( ) ; cy . get ( `[data-testing-id="radio-${ title }"]` ) . click ( ) ; cy . get ( '.modal-footer button.btn-primary' ) . click ( ) ; this . closeAddProductToWishlistModal ( 'link' ) ; } else { cy . get ( this . contextSelector ) . find ( `ish-product-item div[data-testing-sku="${ product }"] button.add-to-wishlist` ) . click ( ) ; this . closeAddProductToWishlistModal ( 'link' ) ; } } private closeAddProductToWishlistModal ( mode ) { cy . wait ( 500 ) ; mode === 'link' ? cy . get ( '[data-testing-id="wishlist-success-link"] a' ) . click ( ) : cy . get ( '.modal-header button' ) . click ( ) ; } }