import { performAddToCart , waitLoadingEnd } from '../../framework' ; import { BreadcrumbModule } from '../breadcrumb.module' ; import { HeaderModule } from '../header.module' ; export class OrderTemplatesDetailsPage { readonly tag = 'ish-account-order-template-detail-page' ; readonly header = new HeaderModule ( ) ; readonly breadcrumb = new BreadcrumbModule ( ) ; static navigateToOverviewPage ( ) { cy . get ( '[href="/account/order-templates"]' ) . first ( ) . click ( ) ; } get listItem ( ) { return cy . get ( 'ish-account-order-template-detail-line-item' ) ; } get listItemLink ( ) { return cy . get ( 'ish-account-order-template-detail-line-item' ) . find ( '[data-testing-id="order-template-product"] a[data-testing-id="product-name-link"]' ) ; } get OrderTemplateTitle ( ) { return cy . get ( 'ish-account-order-template-detail-page' ) . find ( 'h1' ) . invoke ( 'text' ) ; } getOrderTemplateItemById ( id ) { return cy . get ( 'span' ) . contains ( id ) . closest ( 'ish-account-order-template-detail-line-item' ) . parent ( ) ; } toggleCheckbox ( id ) { this . getOrderTemplateItemById ( id ) . find ( '[data-testing-id="productCheckbox"]' ) . click ( ) ; } getOrderTemplateCartButton ( ) { return cy . get ( 'ish-product-add-to-basket' ) ; } deleteOrderTemplate ( id ) { waitLoadingEnd ( ) ; this . getOrderTemplateItemById ( id ) . find ( '[data-testing-id="delete-order-template"]' ) . click ( ) ; } moveProductToOrderTemplate ( productId , listName ) { this . getOrderTemplateItemById ( productId ) . find ( '[data-testing-id="move-order-template"]' ) . 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="order-template-success-link"] a' ) . click ( ) ; } addOrderTemplateToBasket ( productId ? , quantity ? ) { if ( productId && quantity ) { this . getOrderTemplateItemById ( productId ) . find ( '[data-testing-id="quantity"]' ) . clear ( ) . type ( quantity . toString ( ) ) ; } return performAddToCart ( ( ) => this . getOrderTemplateCartButton ( ) . find ( '[data-testing-id="addToCartButton"]' ) ) ; } }