Skip to content

Commit

Permalink
Merge branch 'develop' into feature/CXSPA-8668
Browse files Browse the repository at this point in the history
  • Loading branch information
Pio-Bar authored Oct 21, 2024
2 parents f7a90d7 + 3403a03 commit 34dafca
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
GROUP_ID_4,
GROUP_ID_5,
GROUP_ID_7,
GROUP_ID_8,
PRODUCT_CODE,
mockRouterState,
productConfiguration,
Expand Down Expand Up @@ -1204,6 +1205,44 @@ describe('ConfiguratorGroupMenuComponent', () => {
)
).toBe(true);
});

it('should return `true` because a group with current group ID is part of the sub group hierarchy', () => {
expect(
component.containsSelectedGroup(
mockProductConfiguration.groups[3], // GROUP_ID_5 is parent of GROUP_ID_7 which in turn is parent of GROUP_ID_8
GROUP_ID_8
)
).toBe(true);
});
});

describe('getTabIndex', () => {
it('should return `0` because current group id matches group itself', () => {
expect(
component.getTabIndex(mockProductConfiguration.groups[0], GROUP_ID_1)
).toBe(0);
});

it("should return `-1` because current group id doesn't match group or its children", () => {
expect(
component.getTabIndex(mockProductConfiguration.groups[0], GROUP_ID_4)
).toBe(-1);
});

it('should return `0` because current group id matches a direct child group id', () => {
expect(
component.getTabIndex(mockProductConfiguration.groups[2], GROUP_ID_4)
).toBe(0);
});

it('should return `0` because current group id matches a in-direct child group id', () => {
expect(
component.getTabIndex(
mockProductConfiguration.groups[3], // GROUP_ID_5 is parent of GROUP_ID_7 which in turn is parent of GROUP_ID_8
GROUP_ID_8
)
).toBe(0);
});
});

describe('isGroupSelected', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ import {
ConfiguratorRouterExtractorService,
} from '@spartacus/product-configurator/common';
import {
BREAKPOINT,
BreakpointService,
DirectionMode,
DirectionService,
HamburgerMenuService,
ICON_TYPE,
BREAKPOINT,
BreakpointService,
} from '@spartacus/storefront';
import { Observable, of } from 'rxjs';
import { filter, map, switchMap, take } from 'rxjs/operators';
Expand Down Expand Up @@ -503,13 +503,11 @@ export class ConfiguratorGroupMenuComponent {
group: Configurator.Group,
currentGroupId?: string
): boolean {
let isCurrentGroupFound = false;
group.subGroups?.forEach((subGroup) => {
if (this.isGroupSelected(subGroup.id, currentGroupId)) {
isCurrentGroupFound = true;
}
});
return isCurrentGroupFound;
return !!group.subGroups?.find(
(subGroup) =>
this.isGroupSelected(subGroup.id, currentGroupId) ||
this.containsSelectedGroup(subGroup, currentGroupId)
);
}

/**
Expand All @@ -521,14 +519,10 @@ export class ConfiguratorGroupMenuComponent {
* @returns {number} - tab index
*/
getTabIndex(group: Configurator.Group, currentGroupId: string): number {
if (
!this.isGroupSelected(group.id, currentGroupId) &&
!this.containsSelectedGroup(group, currentGroupId)
) {
return -1;
} else {
return 0;
}
const isCurrentGroupPartOfGroupHierarchy =
this.isGroupSelected(group.id, currentGroupId) ||
this.containsSelectedGroup(group, currentGroupId);
return isCurrentGroupPartOfGroupHierarchy ? 0 : -1; // 0 -> add to tab chain, -1 -> remove from tab chain
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { assertAddressForm } from './address-book';
import { login } from './auth-forms';
import * as guestCheckout from './checkout-as-guest';
import * as checkout from './checkout-flow';
import { validateUpdateProfileForm } from './update-profile';
import { getSampleUser } from '../sample-data/checkout-flow';
import {
cartWithMultipleVariantProducts,
cartWithTotalVariantProduct,
multiDBaseProduct,
multiDProduct,
} from '../sample-data/multi-dimensional-flow';
import { getSampleUser } from '../sample-data/checkout-flow';
import { searchForProduct } from './product-search';
import { assertAddressForm } from './address-book';
import { addProductToCart } from './applied-promotions';
import { login } from './auth-forms';
import * as guestCheckout from './checkout-as-guest';
import * as checkout from './checkout-flow';
import { searchForProduct } from './product-search';
import { validateUpdateProfileForm } from './update-profile';

export function testCheckoutMultiDAsGuest() {
it('should perform checkout as guest, create an account and verify guest data', () => {
Expand Down Expand Up @@ -160,9 +160,19 @@ export function testCheckoutMultiDAsGuestAndVerifyCart() {
cy.findByText(/Sign in \/ Register/i).click();
cy.wait(`@${loginPage}`).its('response.statusCode').should('eq', 200);

cy.intercept(
'GET',
`${Cypress.env('OCC_PREFIX')}/${Cypress.env(
'BASE_SITE'
)}/users/current/carts?fields*`
).as('carts');

login(multiDUser.email, multiDUser.password);

cy.get('cx-login div.cx-login-greet').should('exist');

cy.wait('@carts').its('response.statusCode').should('eq', 200);

cy.get('cx-mini-cart .count').contains('1');

const cartPage = checkout.waitForPage('/cart', 'getCartPage');
Expand Down

0 comments on commit 34dafca

Please sign in to comment.