diff --git a/projects/storefrontapp-e2e-cypress/cypress/e2e/regression/quote/quote-configurator.e2e-flaky.cy.ts b/projects/storefrontapp-e2e-cypress/cypress/e2e/regression/quote/quote-configurator.e2e-flaky.cy.ts new file mode 100644 index 00000000000..9b748fff572 --- /dev/null +++ b/projects/storefrontapp-e2e-cypress/cypress/e2e/regression/quote/quote-configurator.e2e-flaky.cy.ts @@ -0,0 +1,70 @@ +/* + * SPDX-FileCopyrightText: 2023 SAP Spartacus team + * + * SPDX-License-Identifier: Apache-2.0 + */ + +import * as quote from '../../../helpers/quote'; +import * as cart from '../../../helpers/cart'; +import * as configurationCart from '../../../helpers/product-configurator-cart'; +import * as configuratorOverview from '../../../helpers/product-configurator-overview'; + +const POWERTOOLS = 'powertools-spa'; +const testProductConfigurable = 'CONF_BANDSAW_ML'; +const testProductConfigurableWithIssues = 'CONF_SCREWDRIVER_S'; +const testProductConfigurableTextfield = '2116282'; +const EMAIL = 'gi.sun@pronto-hw.com'; +const PASSWORD = '12341234'; +const USER = 'Gi Sun'; + +context('Quote<->Configurator integration', () => { + beforeEach(() => { + cy.visit('/'); + quote.login(EMAIL, PASSWORD, USER); + }); + + describe('Request quote process with VC configurable product', () => { + it('should not allow to request quote if configuration has issues', () => { + quote.addProductToCartForQuotePreparation( + POWERTOOLS, + testProductConfigurableWithIssues, + '1' + ); + quote.clickOnRequestQuoteInCart(); + + //we are still in cart, for now just check that + //TODO check for messages once https://jira.tools.sap/browse/CXSPA-4079 is done + cy.get('cx-cart-details').should('exist'); + + //remove conflicting entry + cart.removeCartItem({ name: testProductConfigurableWithIssues }); + }); + + it('should support creation of a draft quote including VC configurable product', () => { + quote.requestQuote(POWERTOOLS, testProductConfigurable, '1'); + + //check: quote is in status draft + quote.checkQuoteInDraftState(false, testProductConfigurable); + + //check: we can navigate to the VC overview page + configurationCart.clickOnDisplayConfigurationLink(0); + cy.get('cx-configurator-overview-sidebar').should('be.visible'); + + //check: back navigation is possible + configuratorOverview.clickContinueToCartBtnOnOPAndExpectQuote(); + }); + }); + + describe('Request quote process with textfield configurable product', () => { + it('should support creation of a draft quote including textfield configurable product', () => { + quote.requestQuote(POWERTOOLS, testProductConfigurableTextfield, '1'); + + //check: quote is in status draft + quote.checkQuoteInDraftState(false, testProductConfigurableTextfield); + + //check: we can navigate to the textfield configurator form + configurationCart.clickOnDisplayConfigurationLink(0); + cy.get('cx-configurator-textfield-form').should('be.visible'); + }); + }); +}); diff --git a/projects/storefrontapp-e2e-cypress/cypress/helpers/product-configurator-cart.ts b/projects/storefrontapp-e2e-cypress/cypress/helpers/product-configurator-cart.ts index 5f06f54188a..a63ded2d726 100644 --- a/projects/storefrontapp-e2e-cypress/cypress/helpers/product-configurator-cart.ts +++ b/projects/storefrontapp-e2e-cypress/cypress/helpers/product-configurator-cart.ts @@ -12,11 +12,7 @@ const cartItemQuantityStepperSelector = '.cx-value cx-item-counter'; * @param {number} cartItemIndex - Index of cart item */ export function clickOnEditConfigurationLink(cartItemIndex: number): void { - cy.get('cx-cart-item-list .cx-item-list-row') - .eq(cartItemIndex) - .find('cx-configure-cart-entry') - .as('aElement'); - + locateCartConfiguratorElement(cartItemIndex); cy.get('@aElement') .find('a:contains("Edit")') .click({ @@ -27,6 +23,30 @@ export function clickOnEditConfigurationLink(cartItemIndex: number): void { }); } +/** + * Clicks on the 'Display Configuration' link in cart/order or quote for a certain item. + * + * @param {number} cartItemIndex - Index of cart item + */ +export function clickOnDisplayConfigurationLink(cartItemIndex: number): void { + locateCartConfiguratorElement(cartItemIndex); + cy.get('@aElement') + .find('a:contains("Display")') + .click({ + force: true, + }) + .then(() => { + cy.location('pathname').should('contain', '/entityKey/'); + }); +} + +function locateCartConfiguratorElement(cartItemIndex: number): void { + cy.get('cx-cart-item-list .cx-item-list-row') + .eq(cartItemIndex) + .find('cx-configure-cart-entry') + .as('aElement'); +} + /** * Clicks on the 'Remove' link in cart for a certain cart item to remove a cart item. * diff --git a/projects/storefrontapp-e2e-cypress/cypress/helpers/product-configurator-overview.ts b/projects/storefrontapp-e2e-cypress/cypress/helpers/product-configurator-overview.ts index ec680c91fb7..59358fdc5ed 100644 --- a/projects/storefrontapp-e2e-cypress/cypress/helpers/product-configurator-overview.ts +++ b/projects/storefrontapp-e2e-cypress/cypress/helpers/product-configurator-overview.ts @@ -36,6 +36,17 @@ export function clickContinueToCartBtnOnOP(): void { }); } +/** + * Clicks on 'Close' on the product overview page and expects the quote details page to appear + */ +export function clickContinueToCartBtnOnOPAndExpectQuote(): void { + cy.get(continueToCartButtonSelector) + .click() + .then(() => { + cy.get('cx-quote-details-overview').should('be.visible'); + }); +} + /** * Waits for the notification banner to display the correct number of issues * diff --git a/projects/storefrontapp-e2e-cypress/cypress/helpers/quote.ts b/projects/storefrontapp-e2e-cypress/cypress/helpers/quote.ts index aa186fc2f40..16a12ad0782 100644 --- a/projects/storefrontapp-e2e-cypress/cypress/helpers/quote.ts +++ b/projects/storefrontapp-e2e-cypress/cypress/helpers/quote.ts @@ -18,9 +18,9 @@ export function setQtyOnPD(quantity: string): void { } /** - * Clicks on 'Request Quote' on the cart page. + * Clicks on 'Request Quote' on the cart page and checks for quote page */ -export function clickOnRequestQuoteInCart(): void { +export function clickOnRequestQuoteInCartAndExpectQuotePage(): void { cy.get('cx-quote-request-button button') .click() .then(() => { @@ -32,6 +32,13 @@ export function clickOnRequestQuoteInCart(): void { }); } +/** + * Clicks on 'Request Quote' on the cart page. + */ +export function clickOnRequestQuoteInCart(): void { + cy.get('cx-quote-request-button button').click(); +} + export function login(email: string, password: string, name: string): void { // Click on the 'Sign in / Register' link // & wait until the login-form is displayed @@ -52,12 +59,20 @@ export function requestQuote( shopName, productName: string, quantity: string +): void { + this.addProductToCartForQuotePreparation(shopName, productName, quantity); + this.clickOnRequestQuoteInCartAndExpectQuotePage(); +} + +export function addProductToCartForQuotePreparation( + shopName, + productName: string, + quantity: string ): void { common.goToPDPage(shopName, productName); this.setQtyOnPD(quantity); common.clickOnAddToCartBtnOnPD(); common.clickOnViewCartBtnOnPD(); - this.clickOnRequestQuoteInCart(); } export function submitQuote(): void {