Skip to content

Commit

Permalink
fix: suppress shopping cart info message if the user adds the same pr…
Browse files Browse the repository at this point in the history
…oduct again (#1356)
  • Loading branch information
DilaraGueler authored and SGrueber committed Feb 13, 2023
1 parent 558a869 commit c05df22
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
3 changes: 1 addition & 2 deletions e2e/cypress/e2e/pages/checkout/cart.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ export class CartPage {
.clear()
.wait(1000)
.type(num.toString())
.wait(1000)
.blur(),
.wait(1000),
get: () =>
cy
.get(this.tag)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ describe('Basket Handling', () => {
page.addProductToCart().its('response.statusCode').should('equal', 200);
waitLoadingEnd(1000);
page.header.miniCart.total.should('contain', _.product.price * 4);
page.header.miniCart.goToCart();
});
at(CartPage, page => {
page.lineItem(0).quantity.get().should('equal', 4);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ describe('Order Template Shopping Experience Functionality', () => {
OrderTemplatesDetailsPage.navigateToOverviewPage();
at(OrderTemplatesOverviewPage, page => {
page.addOrderTemplateToCart(accountOrderTemplate);
page.header.miniCart.goToCart();
});
at(CartPage, page => {
page.addBasketToOrderTemplate();
Expand Down
10 changes: 8 additions & 2 deletions src/app/core/models/basket-info/basket-info.mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@ import { BasketInfo } from './basket-info.model';

export class BasketInfoMapper {
static fromInfo(payload: { infos: BasketInfo[]; itemId?: string }): BasketInfo[] {
// minor infos, that should not be displayed at the moment
/**
* Minor infos or causes, that should not be displayed at the moment.
* Remove "basket.line_item.add_item_added_to_existing_line_item.info" from the causes array, to redirect the user to the cart after adding the same product to the cart.
*/
const minorInfos = ['basket.line_item.deletion.info'];
const minorCauses = ['basket.line_item.add_item_added_to_existing_line_item.info'];

const { itemId } = payload;
const infos = payload?.infos?.filter(info => !minorInfos.includes(info.code));
const infos = payload?.infos
?.filter(info => !minorInfos.includes(info.code))
?.filter(info => !info.causes.find(cause => minorCauses.includes(cause.code)));

return itemId
? infos?.map(info => ({
Expand Down

0 comments on commit c05df22

Please sign in to comment.