Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: CXSPA-6552: Remove obsolete deprecated flavor of CPQ communication #19898

Merged
merged 8 commits into from
Jan 22, 2025
Original file line number Diff line number Diff line change
Expand Up @@ -225,22 +225,6 @@ describe('ConfigureCartEntryComponent', () => {
});
});

describe('getOwnerType', () => {
it('should find correct default owner type', () => {
component.cartEntry.orderCode = undefined;
expect(component.getOwnerType()).toBe(
CommonConfigurator.OwnerType.CART_ENTRY
);
});

it('should find correct owner type for entry belonging to order', () => {
component.cartEntry.orderCode = orderCode;
expect(component.getOwnerType()).toBe(
CommonConfigurator.OwnerType.ORDER_ENTRY
);
});
});

describe('retrieveOwnerTypeFromAbstractOrderType', () => {
it('should find correct owner type in case entry knows order', () => {
component.readOnly = true;
Expand Down Expand Up @@ -333,25 +317,6 @@ describe('ConfigureCartEntryComponent', () => {
});
});

describe('getEntityKey', () => {
it('should find correct entity key for cart entry', () => {
component.cartEntry = { entryNumber: 0 };
expect(component.getEntityKey()).toBe('0');
});

it('should throw error if entry number not present in entry', () => {
component.cartEntry = {};
expect(() => component.getEntityKey()).toThrowError();
});

it('should find correct entity key for order entry', () => {
component.cartEntry = { entryNumber: 0, orderCode: orderCode };

component.readOnly = true;
expect(component.getEntityKey()).toBe(orderCode + '+0');
});
});

describe('getDisplayOnly', () => {
it('should derive result from component if available', () => {
component.readOnly = true;
Expand Down Expand Up @@ -491,65 +456,62 @@ describe('ConfigureCartEntryComponent', () => {
});
});

describe('getQueryParams', () => {
it('should set "forceReload" parameter', () => {
expect(component.getQueryParams().forceReload).toBe(true);
});
it('should not set "resolveIssues" parameter in case no issues exist', () => {
component.readOnly = false;
component.msgBanner = false;
component.cartEntry = {
entryNumber: 0,
product: { configuratorType: configuratorType },
statusSummaryList: [],
};
expect(component.getQueryParams().resolveIssues).toBe(false);
describe('queryParam$', () => {
it('should contain "navigateToCheckout" parameter in case the navigation to the cart is relevant', (done) => {
mockRouterState.state.semanticRoute = 'checkoutReviewOrder';
component.queryParams$
.pipe(take(1), delay(0))
.subscribe((queryParams) => {
expect(queryParams.navigateToCheckout).toBe(true);
done();
});
});
it('should set "resolveIssues" parameter in case issues exist', () => {
component.readOnly = false;
component.msgBanner = true;

it('should contain "productCode" parameter in case product code is relevant', (done) => {
component.cartEntry = {
entryNumber: 0,
product: { configuratorType: configuratorType },
statusSummaryList: [
{ status: OrderEntryStatus.Error, numberOfIssues: 3 },
],
product: { configuratorType: configuratorType, code: productCode },
};
expect(component.getQueryParams().resolveIssues).toBe(true);
fixture.detectChanges();
component.queryParams$
.pipe(take(1), delay(0))
.subscribe((queryParams) => {
expect(queryParams.productCode).toBe(productCode);
done();
});
});
it('should not set "resolveIssues" parameter in case issues exist but component is not rendered in the context of the resolve issues banner', () => {

it('should not contain "resolveIssues" parameter in case no issues exist', (done) => {
component.readOnly = false;
component.msgBanner = false;
component.cartEntry = {
entryNumber: 0,
product: { configuratorType: configuratorType },
statusSummaryList: [
{ status: OrderEntryStatus.Error, numberOfIssues: 3 },
],
product: { configuratorType: configuratorType, code: productCode },
};
expect(component.getQueryParams().resolveIssues).toBe(false);
});

it('should set "navigateToCheckout" parameter in case the navigation to the cart is relevant', (done) => {
mockRouterState.state.semanticRoute = 'checkoutReviewOrder';
fixture.detectChanges();
component.queryParams$
.pipe(take(1), delay(0))
.subscribe((queryParams) => {
expect(queryParams.navigateToCheckout).toBe(true);
expect(queryParams.resolveIssues).toBe(false);
done();
});
});

it('should set "productCode" parameter in case product code is relevant', (done) => {
it('should contain "resolveIssues" parameter in case issues exist', (done) => {
component.readOnly = false;
component.msgBanner = true;
component.cartEntry = {
entryNumber: 0,
product: { configuratorType: configuratorType, code: productCode },
statusSummaryList: [
{ status: OrderEntryStatus.Error, numberOfIssues: 3 },
],
};
fixture.detectChanges();
component.queryParams$
.pipe(take(1), delay(0))
.subscribe((queryParams) => {
expect(queryParams.productCode).toBe(productCode);
expect(queryParams.resolveIssues).toBe(true);
done();
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
Input,
inject,
} from '@angular/core';
import { Params } from '@angular/router';
import {
AbstractOrderKey,
AbstractOrderType,
Expand Down Expand Up @@ -70,18 +69,6 @@ export class ConfigureCartEntryComponent {
return this.commonConfigUtilsService.hasIssues(this.cartEntry);
}

/**
* @deprecated Use retrieveOwnerTypeFromAbstractOrderType instead
* Verifies whether the cart entry has an order code and returns a corresponding owner type.
*
* @returns - an owner type
*/
getOwnerType(): CommonConfigurator.OwnerType {
return this.cartEntry.orderCode !== undefined
? CommonConfigurator.OwnerType.ORDER_ENTRY
: CommonConfigurator.OwnerType.CART_ENTRY;
}

/**
* Retrieves owner for an abstract order type
*
Expand All @@ -106,27 +93,6 @@ export class ConfigureCartEntryComponent {
}
}

/**
* @deprecated Use retrieveEntityKey instead
* Verifies whether the cart entry has an order code, retrieves a composed owner ID
* and concatenates a corresponding entry number.
*
* @returns - an entry key
*/
getEntityKey(): string {
const entryNumber = this.cartEntry.entryNumber;
if (entryNumber === undefined) {
throw new Error('No entryNumber present in entry');
}

return this.cartEntry.orderCode
? this.commonConfigUtilsService.getComposedOwnerId(
this.cartEntry.orderCode,
entryNumber
)
: entryNumber.toString();
}

/**
* Verifies whether the cart entry has an order code, retrieves a composed owner ID
* and concatenates a corresponding entry number.
Expand Down Expand Up @@ -191,22 +157,6 @@ export class ConfigureCartEntryComponent {
return !this.getDisplayOnly() && this.msgBanner ? errorMsgId : undefined;
}

/**
* @deprecated since 2211.24 use instead queryParams$
*
* Compiles query parameters for the router link.
* 'resolveIssues' is only set if the component is
* rendered in the context of the message banner, and if issues exist at all
*
* @returns Query parameters
*/
getQueryParams(): Params {
return {
forceReload: true,
resolveIssues: this.msgBanner && this.hasIssues(),
};
}

protected isInCheckout(): Observable<boolean> {
return this.routingService.getRouterState().pipe(
map((routerState) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ describe('ConfigAttributeHeaderComponent', () => {

const testConfiguratorUISettings: ConfiguratorUISettingsConfig = {
productConfigurator: {
enableNavigationToConflict: false,
descriptions: {
attributeDescriptionLength: 100,
valueDescriptionLength: 70,
Expand Down Expand Up @@ -690,27 +689,16 @@ describe('ConfigAttributeHeaderComponent', () => {
});

describe('Get conflict message key', () => {
it("should return 'configurator.conflict.conflictDetected' conflict message key", () => {
it("should return 'configurator.conflict.viewConflictDetails' conflict message key for attribute groups", () => {
component.groupType = Configurator.GroupType.ATTRIBUTE_GROUP;
(configuratorUISettingsConfig.productConfigurator ??=
{}).enableNavigationToConflict = false;
fixture.detectChanges();
expect(component.getConflictMessageKey()).toEqual(
'configurator.conflict.conflictDetected'
);
});

it("should return 'configurator.conflict.viewConflictDetails' conflict message key", () => {
component.groupType = Configurator.GroupType.ATTRIBUTE_GROUP;
(configuratorUISettingsConfig.productConfigurator ??=
{}).enableNavigationToConflict = true;
fixture.detectChanges();
expect(component.getConflictMessageKey()).toEqual(
'configurator.conflict.viewConflictDetails'
);
});

it("should return 'configurator.conflict.viewConfigurationDetails' conflict message key", () => {
it("should return 'configurator.conflict.viewConfigurationDetails' conflict message key for conflict groups", () => {
component.groupType = Configurator.GroupType.CONFLICT_GROUP;
fixture.detectChanges();
expect(component.getConflictMessageKey()).toEqual(
Expand Down Expand Up @@ -1076,32 +1064,11 @@ describe('ConfigAttributeHeaderComponent', () => {
});

describe('isNavigationToConflictEnabled', () => {
it('should return false if productConfigurator setting is not provided', () => {
configuratorUISettingsConfig.productConfigurator = undefined;
expect(component.isNavigationToConflictEnabled()).toBeFalsy();
});

it('should return false if enableNavigationToConflict setting is not provided', () => {
(configuratorUISettingsConfig.productConfigurator ??=
{}).enableNavigationToConflict = undefined;
expect(component.isNavigationToConflictEnabled()).toBeFalsy();
});

it('should return true if enableNavigationToConflict setting is true', () => {
(configuratorUISettingsConfig.productConfigurator ??=
{}).enableNavigationToConflict = true;
it('should return true if isNavigationToGroupEnabled is true', () => {
expect(component.isNavigationToConflictEnabled()).toBe(true);
});

it('should return false if enableNavigationToConflict setting is false', () => {
(configuratorUISettingsConfig.productConfigurator ??=
{}).enableNavigationToConflict = false;
expect(component.isNavigationToConflictEnabled()).toBe(false);
});

it('should return false if enableNavigationToConflict setting is true and isNavigationToGroupEnabled is false', () => {
(configuratorUISettingsConfig.productConfigurator ??=
{}).enableNavigationToConflict = true;
it('should return false if isNavigationToGroupEnabled is false', () => {
component.isNavigationToGroupEnabled = false;
fixture.detectChanges();
expect(component.isNavigationToConflictEnabled()).toBe(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ export class ConfiguratorAttributeHeaderComponent
this.scrollToAttribute(this.attribute.name);
} else {
this.logError(
'Attribute was not found in any conflict group. Note that for this navigation, commerce 22.05 or later is required. Consider to disable setting "enableNavigationToConflict"'
'Attribute was not found in any conflict group. Note that for this navigation, commerce 22.05 or later is required.'
);
}
});
Expand Down Expand Up @@ -293,12 +293,7 @@ export class ConfiguratorAttributeHeaderComponent
* @returns {boolean} true only if navigation to conflict groups is enabled.
*/
isNavigationToConflictEnabled(): boolean {
return (
(this.isNavigationToGroupEnabled &&
this.configuratorUISettingsConfig.productConfigurator
?.enableNavigationToConflict) ??
false
);
return this.isNavigationToGroupEnabled;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export interface ProductConfiguratorUISettingsConfig {
date?: number;
};
addRetractOption?: boolean;
enableNavigationToConflict?: boolean;
descriptions?: {
attributeDescriptionLength?: number;
valueDescriptionLength?: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export const defaultConfiguratorUISettingsConfig: ConfiguratorUISettingsConfig =
date: 1500,
},
addRetractOption: false,
enableNavigationToConflict: true,
descriptions: {
attributeDescriptionLength: 100,
valueDescriptionLength: 70,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,20 +190,6 @@ describe('ConfigTabBarComponent', () => {
expect(htmlElem.querySelectorAll('a').length).toEqual(0);
});

it('should tell from semantic route that we are on OV page', () => {
mockRouterState.state.semanticRoute = CONFIG_OVERVIEW_ROUTE;
component.isOverviewPage$
.subscribe((isOv) => expect(isOv).toBe(true))
.unsubscribe();
});

it('should tell from semantic route that we are on config page', () => {
mockRouterState.state.semanticRoute = CONFIGURATOR_ROUTE;
component.isOverviewPage$
.subscribe((isOv) => expect(isOv).toBe(false))
.unsubscribe();
});

it('should return proper page type from route', () => {
mockRouterState.state.semanticRoute = CONFIG_OVERVIEW_ROUTE;
component.pageType$
Expand Down Expand Up @@ -378,18 +364,6 @@ describe('ConfigTabBarComponent', () => {
});
});

describe('getTabIndexOverviewTab', () => {
it('should return tabindex 0 if on overview page', () => {
mockRouterState.state.semanticRoute = CONFIG_OVERVIEW_ROUTE;
expect(component.getTabIndexOverviewTab()).toBe(0);
});

it('should return tabindex -1 if on configuration page', () => {
mockRouterState.state.semanticRoute = CONFIGURATOR_ROUTE;
expect(component.getTabIndexOverviewTab()).toBe(-1);
});
});

describe('getTabIndexForOverviewTab', () => {
it('should return tabindex 0 if on overview page', () => {
expect(
Expand All @@ -408,18 +382,6 @@ describe('ConfigTabBarComponent', () => {
});
});

describe('getTabIndexConfigTab', () => {
it('should return tabindex -1 if on overview page', () => {
mockRouterState.state.semanticRoute = CONFIG_OVERVIEW_ROUTE;
expect(component.getTabIndexConfigTab()).toBe(-1);
});

it('should return tabindex 0 if on configuration page', () => {
mockRouterState.state.semanticRoute = CONFIGURATOR_ROUTE;
expect(component.getTabIndexConfigTab()).toBe(0);
});
});

describe('getTabIndeForConfigTab', () => {
it('should return tabindex -1 if on overview page', () => {
expect(
Expand Down
Loading
Loading