Skip to content

Commit

Permalink
CXSPA-3836 first e2e test for configurator integration (#17636)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristophHi authored Jul 19, 2023
1 parent ca2b9ef commit 1ed5e63
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* SPDX-FileCopyrightText: 2023 SAP Spartacus team <[email protected]>
*
* 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 = '[email protected]';
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');
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
21 changes: 18 additions & 3 deletions projects/storefrontapp-e2e-cypress/cypress/helpers/quote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand All @@ -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
Expand All @@ -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 {
Expand Down

0 comments on commit 1ed5e63

Please sign in to comment.