diff --git a/projects/storefrontapp-e2e-cypress/cypress/e2e/regression/product_configurator/product-configurator-textfield.e2e.cy.ts b/projects/storefrontapp-e2e-cypress/cypress/e2e/regression/product_configurator/product-configurator-textfield.e2e.cy.ts index 0ed2ba23464..4283eaf496b 100644 --- a/projects/storefrontapp-e2e-cypress/cypress/e2e/regression/product_configurator/product-configurator-textfield.e2e.cy.ts +++ b/projects/storefrontapp-e2e-cypress/cypress/e2e/regression/product_configurator/product-configurator-textfield.e2e.cy.ts @@ -7,6 +7,7 @@ import * as cart from '../../../helpers/cart'; import * as configuration from '../../../helpers/product-configurator'; import * as textfieldConfiguration from '../../../helpers/textfield-configuration'; +import * as common from '../../../helpers/common'; const electronicsShop = 'electronics-spa'; const testProduct = '1934793'; @@ -46,8 +47,8 @@ context('Textfield Configuration', () => { electronicsShop, testProduct ); - textfieldConfiguration.clickOnAddToCartBtnOnPD(); - textfieldConfiguration.clickOnViewCartBtnOnPD(); + common.clickOnAddToCartBtnOnPD(); + common.clickOnViewCartBtnOnPD(); cart.verifyCartNotEmpty(); textfieldConfiguration.clickOnEditConfigurationLink(0); }); diff --git a/projects/storefrontapp-e2e-cypress/cypress/e2e/regression/product_configurator/product-configurator-vc-cart.e2e-flaky.cy.ts b/projects/storefrontapp-e2e-cypress/cypress/e2e/regression/product_configurator/product-configurator-vc-cart.e2e-flaky.cy.ts index 5361db0d602..3ae7b31c767 100644 --- a/projects/storefrontapp-e2e-cypress/cypress/e2e/regression/product_configurator/product-configurator-vc-cart.e2e-flaky.cy.ts +++ b/projects/storefrontapp-e2e-cypress/cypress/e2e/regression/product_configurator/product-configurator-vc-cart.e2e-flaky.cy.ts @@ -12,6 +12,7 @@ import * as configurationCartVc from '../../../helpers/product-configurator-cart import * as configurationOverview from '../../../helpers/product-configurator-overview'; import * as configurationOverviewVc from '../../../helpers/product-configurator-overview-vc'; import * as configurationVc from '../../../helpers/product-configurator-vc'; +import * as common from '../../../helpers/common'; const electronicsShop = 'electronics-spa'; const testProductMultiLevel = 'CONF_HOME_THEATER_ML'; @@ -98,8 +99,8 @@ context('Product Configuration', () => { it('should be able to navigate from the cart after adding product directly to the cart', () => { clickAllowAllFromBanner(); configuration.searchForProduct(testProductMultiLevel); - configuration.clickOnAddToCartBtnOnPD(); - configuration.clickOnViewCartBtnOnPD(); + common.clickOnAddToCartBtnOnPD(); + common.clickOnViewCartBtnOnPD(); cart.verifyCartNotEmpty(); configurationCart.clickOnEditConfigurationLink(0); }); diff --git a/projects/storefrontapp-e2e-cypress/cypress/e2e/regression/product_configurator/product-configurator-vc-interactive.e2e.cy.ts b/projects/storefrontapp-e2e-cypress/cypress/e2e/regression/product_configurator/product-configurator-vc-interactive.e2e.cy.ts index ae4e2e9618f..825e716f8ca 100644 --- a/projects/storefrontapp-e2e-cypress/cypress/e2e/regression/product_configurator/product-configurator-vc-interactive.e2e.cy.ts +++ b/projects/storefrontapp-e2e-cypress/cypress/e2e/regression/product_configurator/product-configurator-vc-interactive.e2e.cy.ts @@ -8,6 +8,7 @@ import * as configuration from '../../../helpers/product-configurator'; import { clickAllowAllFromBanner } from '../../../helpers/anonymous-consents'; import * as configurationOverviewVc from '../../../helpers/product-configurator-overview-vc'; import * as configurationVc from '../../../helpers/product-configurator-vc'; +import * as common from '../../../helpers/common'; const electronicsShop = 'electronics-spa'; const testProduct = 'CONF_CAMERA_SL'; @@ -96,7 +97,7 @@ context('Product Configuration', () => { it('should be able to navigate from the product details page', () => { clickAllowAllFromBanner(); - configurationVc.goToPDPage(electronicsShop, testProduct); + common.goToPDPage(electronicsShop, testProduct); configurationVc.clickOnConfigureBtnInCatalog(testProduct); }); diff --git a/projects/storefrontapp-e2e-cypress/cypress/e2e/vendor/cpq/cpq-configuration.ccv2-e2e.cy.ts b/projects/storefrontapp-e2e-cypress/cypress/e2e/vendor/cpq/cpq-configuration.ccv2-e2e.cy.ts index 73072a13ccd..eaaa97ae98d 100644 --- a/projects/storefrontapp-e2e-cypress/cypress/e2e/vendor/cpq/cpq-configuration.ccv2-e2e.cy.ts +++ b/projects/storefrontapp-e2e-cypress/cypress/e2e/vendor/cpq/cpq-configuration.ccv2-e2e.cy.ts @@ -8,8 +8,7 @@ import * as configuration from '../../../helpers/product-configurator'; import * as configurationCpq from '../../../helpers/product-configurator-cpq'; import * as configurationOverview from '../../../helpers/product-configurator-overview'; import * as configurationOverviewCpq from '../../../helpers/product-configurator-overview-cpq'; -import * as configurationCart from '../../../helpers/product-configurator-cart'; -import * as configurationCartCpq from '../../../helpers/product-configurator-cart-cpq'; +import * as common from '../../../helpers/common'; import { clickAllowAllFromBanner } from '../../../helpers/anonymous-consents'; const POWERTOOLS = 'powertools-spa'; @@ -109,14 +108,14 @@ context('CPQ Configuration', () => { }); it('should be able to navigate from the product details page', () => { - configurationCpq.goToPDPage(POWERTOOLS, PROD_CODE_CAM); + common.goToPDPage(POWERTOOLS, PROD_CODE_CAM); configurationCpq.clickOnConfigureBtnInCatalog(); }); }); describe('Handling different UI type', () => { it('should support radio button attribute type', () => { - configurationCpq.goToPDPage(POWERTOOLS, PROD_CODE_COF); + common.goToPDPage(POWERTOOLS, PROD_CODE_COF); configurationCpq.clickOnConfigureBtnInCatalog(); configuration.checkAttributeDisplayed(ATTR_COF_CUPS, RADGRP); @@ -137,7 +136,7 @@ context('CPQ Configuration', () => { }); it('should support checkbox list attribute type', () => { - configurationCpq.goToPDPage(POWERTOOLS, PROD_CODE_COF); + common.goToPDPage(POWERTOOLS, PROD_CODE_COF); configurationCpq.clickOnConfigureBtnInCatalog(); configuration.checkAttributeDisplayed(ATTR_COF_MODE, CHKBOX); diff --git a/projects/storefrontapp-e2e-cypress/cypress/e2e/vendor/cpq/cpq-configuration.core-e2e.cy.ts b/projects/storefrontapp-e2e-cypress/cypress/e2e/vendor/cpq/cpq-configuration.core-e2e.cy.ts index 6c7348d5060..404da626436 100644 --- a/projects/storefrontapp-e2e-cypress/cypress/e2e/vendor/cpq/cpq-configuration.core-e2e.cy.ts +++ b/projects/storefrontapp-e2e-cypress/cypress/e2e/vendor/cpq/cpq-configuration.core-e2e.cy.ts @@ -10,6 +10,7 @@ import * as configurationOverview from '../../../helpers/product-configurator-ov import * as configurationOverviewCpq from '../../../helpers/product-configurator-overview-cpq'; import * as configurationCart from '../../../helpers/product-configurator-cart'; import * as configurationCartCpq from '../../../helpers/product-configurator-cart-cpq'; +import * as common from '../../../helpers/common'; import { clickAllowAllFromBanner } from '../../../helpers/anonymous-consents'; const POWERTOOLS = 'powertools-spa'; @@ -127,14 +128,14 @@ testConfig.forEach((config) => { }); it('should be able to navigate from the product details page', () => { - configurationCpq.goToPDPage(POWERTOOLS, PROD_CODE_CAM); + common.goToPDPage(POWERTOOLS, PROD_CODE_CAM); configurationCpq.clickOnConfigureBtnInCatalog(); }); }); describe('Handling different UI type', () => { it('should support radio button attribute type', () => { - configurationCpq.goToPDPage(POWERTOOLS, PROD_CODE_COF); + common.goToPDPage(POWERTOOLS, PROD_CODE_COF); configurationCpq.clickOnConfigureBtnInCatalog(); configuration.checkAttributeDisplayed(ATTR_COF_CUPS, RADGRP); @@ -165,7 +166,7 @@ testConfig.forEach((config) => { }); it('should support checkbox list attribute type', () => { - configurationCpq.goToPDPage(POWERTOOLS, PROD_CODE_COF); + common.goToPDPage(POWERTOOLS, PROD_CODE_COF); configurationCpq.clickOnConfigureBtnInCatalog(); configuration.checkAttributeDisplayed(ATTR_COF_MODE, CHKBOX); @@ -555,9 +556,9 @@ testConfig.forEach((config) => { describe('Configuration Process', () => { it('should support configuration aspect in product search, cart, checkout and order history', () => { - configurationCpq.goToPDPage(POWERTOOLS, PROD_CODE_CAM); - configuration.clickOnAddToCartBtnOnPD(); - configuration.clickOnViewCartBtnOnPD(); + common.goToPDPage(POWERTOOLS, PROD_CODE_CAM); + common.clickOnAddToCartBtnOnPD(); + common.clickOnViewCartBtnOnPD(); cy.get('cx-mini-cart .count').then((elem) => { const numberOfCartItems = Number(elem.text()); diff --git a/projects/storefrontapp-e2e-cypress/cypress/helpers/common.ts b/projects/storefrontapp-e2e-cypress/cypress/helpers/common.ts new file mode 100644 index 00000000000..3b8b9edeeb5 --- /dev/null +++ b/projects/storefrontapp-e2e-cypress/cypress/helpers/common.ts @@ -0,0 +1,60 @@ +/* + * SPDX-FileCopyrightText: 2023 SAP Spartacus team + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/** + * Clicks on 'Add to cart' on the product details page. + */ +export function clickOnAddToCartBtnOnPD(): void { + cy.get('cx-add-to-cart button.btn-primary') + .contains('Add to cart') + .click() + .then(() => { + cy.get('cx-added-to-cart-dialog').should('be.visible'); + cy.get('div.cx-dialog-body').should('be.visible'); + cy.get('div.cx-dialog-buttons a.btn-primary') + .contains('view cart') + .should('be.visible'); + cy.get('div.cx-dialog-buttons a.btn-secondary') + .contains('proceed to checkout') + .should('be.visible'); + }); +} + +/** + * Clicks on 'View Cart' on the product details page. + */ +export function clickOnViewCartBtnOnPD(): void { + cy.get('div.cx-dialog-buttons a.btn-primary') + .contains('view cart') + .click() + .then(() => { + cy.location('pathname').should('contain', '/cart'); + cy.get('cx-cart-details').should('be.visible'); + }); +} + +/** + * Navigates to the product detail page. + * + * @param {string} shopName - shop name + * @param {string} productId - Product ID + */ +export function goToPDPage(shopName: string, productId: string): void { + const location = `${shopName}/en/USD/product/${productId}/${productId}`; + cy.visit(location).then(() => { + checkLoadingMsgNotDisplayed(); + cy.location('pathname').should('contain', location); + cy.get('.ProductDetailsPageTemplate').should('be.visible'); + }); +} + +/** + * Verifies whether the loading message is not displayed. + */ +export function checkLoadingMsgNotDisplayed(): void { + cy.log('Wait until the loading notification is not displayed anymore'); + cy.get('cx-storefront').should('not.contain.value', 'Loading'); +} diff --git a/projects/storefrontapp-e2e-cypress/cypress/helpers/product-configurator-cpq.ts b/projects/storefrontapp-e2e-cypress/cypress/helpers/product-configurator-cpq.ts index b4605a355e9..1729b670172 100644 --- a/projects/storefrontapp-e2e-cypress/cypress/helpers/product-configurator-cpq.ts +++ b/projects/storefrontapp-e2e-cypress/cypress/helpers/product-configurator-cpq.ts @@ -56,20 +56,6 @@ export function goToCPQConfigurationPage( }); } -/** - * Navigates to the product detail page. - * - * @param {string} shopName - shop name - * @param {string} productId - Product ID - */ -export function goToPDPage(shopName: string, productId: string): void { - const location = `${shopName}/en/USD/product/${productId}/${productId}`; - cy.visit(location).then(() => { - cy.location('pathname').should('contain', location); - cy.get('.ProductDetailsPageTemplate').should('be.visible'); - }); -} - /** * Clicks on 'Add to Cart' button in catalog list. */ diff --git a/projects/storefrontapp-e2e-cypress/cypress/helpers/product-configurator-vc.ts b/projects/storefrontapp-e2e-cypress/cypress/helpers/product-configurator-vc.ts index 7f7b51e7ee0..d9401d8d128 100644 --- a/projects/storefrontapp-e2e-cypress/cypress/helpers/product-configurator-vc.ts +++ b/projects/storefrontapp-e2e-cypress/cypress/helpers/product-configurator-vc.ts @@ -5,6 +5,7 @@ */ import * as configuration from './product-configurator'; +import * as common from './common'; const addToCartButtonSelector = 'cx-configurator-add-to-cart-button button.cx-add-to-cart-btn'; @@ -93,21 +94,6 @@ export function registerCreateConfigurationRoute() { }).as(CREATE_CONFIG_ALIAS.substring(1)); // strip the '@' } -/** - * Navigates to the product detail page. - * - * @param {string} shopName - shop name - * @param {string} productId - Product ID - */ -export function goToPDPage(shopName: string, productId: string): void { - const location = `${shopName}/en/USD/product/${productId}/${productId}`; - cy.visit(location).then(() => { - checkLoadingMsgNotDisplayed(); - cy.location('pathname').should('contain', location); - cy.get('.ProductDetailsPageTemplate').should('be.visible'); - }); -} - /** * Navigates to the cart page. * @@ -121,14 +107,6 @@ export function goToCart(shopName: string) { }); } -/** - * Verifies whether the loading message is not displayed. - */ -export function checkLoadingMsgNotDisplayed(): void { - cy.log('Wait until the loading notification is not displayed anymore'); - cy.get('cx-storefront').should('not.contain.value', 'Loading'); -} - /** * Verifies whether the global message is not displayed on the top of the configuration. */ @@ -171,7 +149,7 @@ export function checkGhostAnimationNotDisplayed(): void { */ export function checkConfigPageDisplayed(): void { checkGhostAnimationNotDisplayed(); - checkLoadingMsgNotDisplayed(); + common.checkLoadingMsgNotDisplayed(); checkGlobalMessageNotDisplayed(); configuration.checkTabBarDisplayed(); configuration.checkGroupTitleDisplayed(); diff --git a/projects/storefrontapp-e2e-cypress/cypress/helpers/product-configurator.ts b/projects/storefrontapp-e2e-cypress/cypress/helpers/product-configurator.ts index 89e41540429..9cf8c81b78a 100644 --- a/projects/storefrontapp-e2e-cypress/cypress/helpers/product-configurator.ts +++ b/projects/storefrontapp-e2e-cypress/cypress/helpers/product-configurator.ts @@ -6,8 +6,8 @@ import * as login from './login'; import * as configurationCartVc from './product-configurator-cart-vc'; -//import * as configurationCart from './product-configurator-cart'; import * as productSearch from './product-search'; +import * as common from './common'; import { verifyGlobalMessageAfterRegistration } from './register'; const nextBtnSelector = @@ -487,38 +487,6 @@ export function checkHamburgerDisplayed(): void { ).should('be.visible'); } -/** - * Clicks on 'Add to cart' on the product details page. - */ -export function clickOnAddToCartBtnOnPD(): void { - cy.get('cx-add-to-cart button.btn-primary') - .contains('Add to cart') - .click() - .then(() => { - cy.get('cx-added-to-cart-dialog').should('be.visible'); - cy.get('div.cx-dialog-body').should('be.visible'); - cy.get('div.cx-dialog-buttons a.btn-primary') - .contains('view cart') - .should('be.visible'); - cy.get('div.cx-dialog-buttons a.btn-secondary') - .contains('proceed to checkout') - .should('be.visible'); - }); -} - -/** - * Clicks on 'View Cart' on the product details page. - */ -export function clickOnViewCartBtnOnPD(): void { - cy.get('div.cx-dialog-buttons a.btn-primary') - .contains('view cart') - .click() - .then(() => { - cy.location('pathname').should('contain', '/cart'); - cy.get('cx-cart-details').should('be.visible'); - }); -} - /** * Clicks on 'Proceed to Checkout' on the product details page. */ @@ -569,7 +537,7 @@ export function completeOrderProcess(productName: string): void { login.loginUser(); cy.wait(tokenAuthRequestAlias).its('response.statusCode').should('eq', 200); this.searchForProduct(productName); - this.clickOnAddToCartBtnOnPD(); + common.clickOnAddToCartBtnOnPD(); this.clickOnProceedToCheckoutBtnOnPD(); configurationCartVc.checkout(); //TODO: activate after 22.05 diff --git a/projects/storefrontapp-e2e-cypress/cypress/helpers/textfield-configuration.ts b/projects/storefrontapp-e2e-cypress/cypress/helpers/textfield-configuration.ts index 12fcbec1138..d692a8ddef2 100644 --- a/projects/storefrontapp-e2e-cypress/cypress/helpers/textfield-configuration.ts +++ b/projects/storefrontapp-e2e-cypress/cypress/helpers/textfield-configuration.ts @@ -144,42 +144,6 @@ export function clickAddToCartButton(shopName: string): void { }); } -/** - * Clicks 'Add to Cart' button on the product details page. - */ -export function clickOnAddToCartBtnOnPD(): void { - cy.log("Clicks 'Add to Cart' button on the product details page"); - cy.get('cx-add-to-cart button.btn-primary') - .contains('Add to cart') - .click() - .then(() => { - cy.get('cx-added-to-cart-dialog').should('be.visible'); - cy.get('div.cx-dialog-body').should('be.visible'); - cy.get('div.cx-dialog-buttons a.btn-primary') - .contains('view cart') - .should('be.visible'); - cy.get('div.cx-dialog-buttons a.btn-secondary') - .contains('proceed to checkout') - .should('be.visible'); - }); -} - -/** - * Clicks on 'View Cart' on the product details page. - */ -export function clickOnViewCartBtnOnPD(): void { - cy.log("Clicks on 'View Cart' on the product details page"); - cy.get('div.cx-dialog-buttons a.btn-primary') - .contains('view cart') - .click() - .then(() => { - cy.log("Verify whether 'Cart details section' is visible"); - cy.get('cx-cart-details').should('be.visible'); - cy.log("Verify whether 'cx-cart-details' is visible"); - cy.get('cx-cart-details').should('be.visible'); - }); -} - /** * Verifies whether the cart contains the product. *