import { performAddToCart , waitLoadingEnd } from '../../framework' ; import { BreadcrumbModule } from '../breadcrumb.module' ; import { HeaderModule } from '../header.module' ; export class WishlistsDetailsPage { readonly tag = 'ish-account-wishlist-detail-page' ; readonly header = new HeaderModule ( ) ; readonly breadcrumb = new BreadcrumbModule ( ) ; static navigateToOverviewPage ( ) { cy . get ( '[href="/account/wishlists"]' ) . first ( ) . click ( ) ; } get listItems ( ) { return cy . get ( 'ish-account-wishlist-detail-line-item' ) ; } get listItemLinks ( ) { return this . listItems . find ( '[data-testing-id="wishlist-product"] a[data-testing-id="product-name-link"]' ) ; } get wishlistTitle ( ) { return cy . get ( 'ish-account-wishlist-detail-page' ) . find ( 'h1' ) . invoke ( 'text' ) ; } get wishlistPreferredTextElement ( ) { return cy . get ( '[data-testing-id="preferred-wishlist-text"]' ) ; } getWishlistItemById ( id ) { return cy . get ( 'span' ) . contains ( id ) . closest ( 'ish-account-wishlist-detail-line-item' ) . parent ( ) ; } editWishlistDetails ( name , preferred ) { cy . get ( '[data-testing-id="wishlist-details-edit"]' ) . click ( ) ; cy . get ( 'ngb-modal-window' ) . find ( '[data-testing-id="title"]' ) . clear ( ) . type ( name ) ; cy . get ( '[data-testing-id="preferred"]' ) . uncheck ( ) ; if ( preferred ) { cy . get ( '[data-testing-id="preferred"]' ) . check ( ) ; } cy . get ( '[data-testing-id="wishlist-dialog-submit"]' ) . click ( ) ; waitLoadingEnd ( 2000 ) ; } deleteWishlist ( id ) { this . getWishlistItemById ( id ) . find ( '[data-testing-id="delete-wishlist"]' ) . click ( ) ; waitLoadingEnd ( 2000 ) ; } moveProductToWishlist ( productId , listName ) { this . getWishlistItemById ( productId ) . find ( '[data-testing-id="move-wishlist"]' ) . click ( ) ; cy . get ( `[data-testing-id="radio-${ listName }"]` ) . check ( ) ; cy . get ( 'ngb-modal-window' ) . find ( 'button[class="btn btn-primary"]' ) . click ( ) ; cy . get ( '[data-testing-id="wishlist-success-link"] a' ) . click ( ) ; waitLoadingEnd ( 2000 ) ; } addProductToBasket ( productId , quantity ) { this . getWishlistItemById ( productId ) . find ( '[data-testing-id="quantity"]' ) . clear ( ) . type ( quantity . toString ( ) ) ; return performAddToCart ( ( ) => this . getWishlistItemById ( productId ) . find ( '[data-testing-id="addToCartButton"]' ) ) ; } }