Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into feature/GH-12125
Browse files Browse the repository at this point in the history
  • Loading branch information
znikola committed Apr 29, 2021
2 parents 9299426 + fa539cf commit e31d593
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 98 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import {
CheckoutModule,
CmsConfig,
I18nModule,
NotAuthGuard,
Expand All @@ -13,14 +12,7 @@ import { PageSlotModule } from '@spartacus/storefront';
import { LoginRegisterComponent } from './login-register.component';

@NgModule({
imports: [
CommonModule,
RouterModule,
UrlModule,
PageSlotModule,
I18nModule,
CheckoutModule,
],
imports: [CommonModule, RouterModule, UrlModule, PageSlotModule, I18nModule],
providers: [
provideDefaultConfig(<CmsConfig>{
cmsComponents: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,7 @@ export function checkProductTitleDisplayed(): void {
*/
export function checkShowMoreLinkAtProductTitleDisplayed(): void {
checkUpdatingMessageNotDisplayed();
//Temporarily deactivate this check
//TODO #12138
//cy.get('button:contains("show more")').should('be.visible');
cy.get('button:contains("show more")').should('be.visible');
}

/**
Expand Down Expand Up @@ -1317,6 +1315,7 @@ export function checkoutB2B(): void {
.contains('Continue')
.click()
.then(() => {
cy.wait('@deliveryMode');
cy.location('pathname').should('contain', '/checkout/delivery-mode');
cy.get('.cx-checkout-title').should('contain', 'Shipping Method');
cy.get('cx-delivery-mode').should('be.visible');
Expand Down Expand Up @@ -1540,3 +1539,20 @@ export function checkAmountOfBundleItems(
toggleBundleItems('show');
});
}

/**
* Verifies the amount of cart entries.
*
* @param {number} expectedCount - Expected amount of cart entries
*/
export function verifyCartCount(expectedCount: number) {
cy.log('expectedCount =' + expectedCount);
cy.get('cx-mini-cart .count').contains(expectedCount);
}

/**
* Define alias for deliveryMode API call.
*/
export function defineDeliveryModeAlias() {
cy.intercept('PUT', '**/deliverymode*').as('deliveryMode');
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as cart from '../../../helpers/cart';
import * as configuration from '../../../helpers/product-configuration';
import * as configurationOverview from '../../../helpers/product-configuration-overview';
import * as productSearch from '../../../helpers/product-search';
Expand Down Expand Up @@ -420,100 +419,113 @@ context('CPQ Configuration', () => {

describe('Configuration Process', () => {
it('should be able to add a configuration directly to the cart, navigate from the cart back to the configuration and update it, checkout and order', () => {
configuration.defineDeliveryModeAlias();
configuration.goToPDPage(POWERTOOLS, PROD_CODE_CAM);
configuration.clickOnAddToCartBtnOnPD();
configuration.clickOnViewCartBtnOnPD();

type ovBundleInfo = {
name: string;
price?: string;
quantity?: string;
};
const ovBundleInfos: ovBundleInfo[] = [
{
name: 'SanDisk Extreme Pro 128GB SDXC',
price: '$100.00',
quantity: '1',
},
{
name: 'Canon RF 24-105mm f4L IS USM',
price: '$1,500.00',
quantity: '1',
},
{
name: 'LowePro Streetline SL 140',
price: '$110.00',
quantity: '1',
},
];
configuration.checkAmountOfBundleItems(0, 3);

ovBundleInfos.forEach((line, bundleItemIndex) => {
configuration.checkBundleItemName(0, bundleItemIndex, line.name);
configuration.checkBundleItemPrice(0, bundleItemIndex, line.price);
configuration.checkBundleItemQuantity(
0,
bundleItemIndex,
line.quantity
cy.get('cx-mini-cart .count').then((elem) => {
const numberOfCartItems = Number(elem.text());
cy.log('numberOfCartItems = ' + numberOfCartItems);
editConfigurationFromCartEntry(numberOfCartItems);
// Checkout
configuration.clickOnProceedToCheckoutBtnInCart();
configuration.checkoutB2B();
// Order historyorderHistory();
configuration.selectOrderByOrderNumberAlias(POWERTOOLS);
configurationOverview.checkGroupHeaderDisplayed(GRP_CAM_MAIN, 0);
configurationOverview.checkAttrDisplayed(
'Camera Body',
'Canon EOS 80D',
0
);
});
});
});

//We assume the last product in the cart is the one we added
configuration.clickOnEditConfigurationLink(
configuration.getNumberOfCartItems() - 1
function editConfigurationFromCartEntry(numberOfCartItems: number) {
//We assume the last product in the cart is the one we added
const cartEntryIndex: number = numberOfCartItems - 1;
type ovBundleInfo = {
name: string;
price?: string;
quantity?: string;
};
const ovBundleInfos: ovBundleInfo[] = [
{
name: 'SanDisk Extreme Pro 128GB SDXC',
price: '$100.00',
quantity: '1',
},
{
name: 'Canon RF 24-105mm f4L IS USM',
price: '$1,500.00',
quantity: '1',
},
{
name: 'LowePro Streetline SL 140',
price: '$110.00',
quantity: '1',
},
];
configuration.checkAmountOfBundleItems(
cartEntryIndex,
ovBundleInfos.length
);

ovBundleInfos.forEach((line, bundleItemIndex) => {
configuration.checkBundleItemName(
cartEntryIndex,
bundleItemIndex,
line.name
);

configuration.checkAttributeDisplayed(ATTR_CAM_BODY, RADGRP_PROD);
configuration.selectAttribute(
ATTR_CAM_BODY,
RADGRP_PROD,
VAL_CAM_BODY_D850
configuration.checkBundleItemPrice(
cartEntryIndex,
bundleItemIndex,
line.price
);
configuration.checkValueSelected(
RADGRP_PROD,
ATTR_CAM_BODY,
VAL_CAM_BODY_D850
);
configuration.selectAttribute(
ATTR_CAM_BODY,
RADGRP_PROD,
VAL_CAM_BODY_EOS80D
);
configuration.checkValueSelected(
RADGRP_PROD,
ATTR_CAM_BODY,
VAL_CAM_BODY_EOS80D
);
configuration.selectAttribute(ATTR_CAM_LEN, CHKBOX_PROD, VAL_CAM_LEN_SI);
configuration.checkValueSelected(
CHKBOX_PROD,
ATTR_CAM_LEN,
VAL_CAM_LEN_SI
);
configuration.clickAddToCartBtn();

configurationOverview.checkConfigOverviewPageDisplayed();
configurationOverview.checkGroupHeaderDisplayed(GRP_CAM_MAIN, 0);
configurationOverview.checkAttrDisplayed(
'Camera Body',
'Canon EOS 80D',
0
);

configurationOverview.checkGroupHeaderDisplayed(GRP_CAM_ACC, 1);
configurationOverview.clickContinueToCartBtnOnOP();

cart.verifyCartNotEmpty();

configuration.clickOnProceedToCheckoutBtnInCart();
configuration.checkoutB2B();
configuration.selectOrderByOrderNumberAlias(POWERTOOLS);
configurationOverview.checkGroupHeaderDisplayed(GRP_CAM_MAIN, 0);
configurationOverview.checkAttrDisplayed(
'Camera Body',
'Canon EOS 80D',
0
configuration.checkBundleItemQuantity(
cartEntryIndex,
bundleItemIndex,
line.quantity
);
});
});

configuration.clickOnEditConfigurationLink(cartEntryIndex);

configuration.checkAttributeDisplayed(ATTR_CAM_BODY, RADGRP_PROD);
configuration.selectAttribute(
ATTR_CAM_BODY,
RADGRP_PROD,
VAL_CAM_BODY_D850
);
configuration.checkValueSelected(
RADGRP_PROD,
ATTR_CAM_BODY,
VAL_CAM_BODY_D850
);
configuration.selectAttribute(
ATTR_CAM_BODY,
RADGRP_PROD,
VAL_CAM_BODY_EOS80D
);
configuration.checkValueSelected(
RADGRP_PROD,
ATTR_CAM_BODY,
VAL_CAM_BODY_EOS80D
);
configuration.selectAttribute(ATTR_CAM_LEN, CHKBOX_PROD, VAL_CAM_LEN_SI);
configuration.checkValueSelected(CHKBOX_PROD, ATTR_CAM_LEN, VAL_CAM_LEN_SI);
configuration.clickAddToCartBtn();

configurationOverview.checkConfigOverviewPageDisplayed();
configurationOverview.checkGroupHeaderDisplayed(GRP_CAM_MAIN, 0);
configurationOverview.checkAttrDisplayed('Camera Body', 'Canon EOS 80D', 0);

configurationOverview.checkGroupHeaderDisplayed(GRP_CAM_ACC, 1);
configurationOverview.clickContinueToCartBtnOnOP();

configuration.checkAmountOfBundleItems(cartEntryIndex, 4);
configuration.verifyCartCount(numberOfCartItems);
}
});

0 comments on commit e31d593

Please sign in to comment.