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

Feature/gh 8835 move connectors adapters #8862

Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { ChangeDetectionStrategy, Type } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import {
Configurator,
GenericConfigurator,
GlobalMessageService,
I18nTestingModule,
RouterState,
RoutingService,
} from '@spartacus/core';
import { ConfigurationRouter } from '@spartacus/storefront';
import { Observable, of } from 'rxjs';
import { ConfiguratorCartService } from '../../core/facade/configurator-cart.service';
import { ConfiguratorCommonsService } from '../../core/facade/configurator-commons.service';
import { ConfiguratorGroupsService } from '../../core/facade/configurator-groups.service';
import * as ConfigurationTestData from '../../shared/testing/configurator-test-data';
import { Configurator } from './../../core/model/configurator.model';
import { ConfiguratorRouter } from './../service/configurator-router-data';
import { ConfiguratorAddToCartButtonComponent } from './configurator-add-to-cart-button.component';

const CART_ENTRY_KEY = '1';
Expand All @@ -30,9 +30,9 @@ const navParamsOverview: any = {

const attributes = {};

const mockRouterData: ConfigurationRouter.Data = {
const mockRouterData: ConfiguratorRouter.Data = {
configuratorType: configuratorType,
pageType: ConfigurationRouter.PageType.CONFIGURATION,
pageType: ConfiguratorRouter.PageType.CONFIGURATION,
isOwnerCartEntry: false,
owner: mockProductConfiguration.owner,
};
Expand Down Expand Up @@ -86,7 +86,7 @@ function setRouterTestDataCartBoundAndConfigPage() {
mockRouterData.isOwnerCartEntry = true;
mockRouterData.owner.type = GenericConfigurator.OwnerType.CART_ENTRY;
mockRouterData.owner.id = CART_ENTRY_KEY;
mockRouterData.pageType = ConfigurationRouter.PageType.CONFIGURATION;
mockRouterData.pageType = ConfiguratorRouter.PageType.CONFIGURATION;
}

function setRouterTestDataProductBoundAndConfigPage() {
Expand All @@ -98,13 +98,13 @@ function setRouterTestDataProductBoundAndConfigPage() {
mockRouterData.isOwnerCartEntry = false;
mockRouterData.owner.type = GenericConfigurator.OwnerType.PRODUCT;
mockRouterData.owner.id = ConfigurationTestData.PRODUCT_CODE;
mockRouterData.pageType = ConfigurationRouter.PageType.CONFIGURATION;
mockRouterData.pageType = ConfiguratorRouter.PageType.CONFIGURATION;
}

function performAddToCartOnOverview() {
setRouterTestDataProductBoundAndConfigPage();
mockRouterState.state.semanticRoute = ROUTE_OVERVIEW;
mockRouterData.pageType = ConfigurationRouter.PageType.OVERVIEW;
mockRouterData.pageType = ConfiguratorRouter.PageType.OVERVIEW;
initialize();
component.onAddToCart(mockProductConfiguration, mockRouterData);
}
Expand All @@ -123,7 +123,7 @@ function ensureCartBound() {
function ensureCartBoundAndOnOverview() {
setRouterTestDataCartBoundAndConfigPage();
mockRouterState.state.semanticRoute = ROUTE_OVERVIEW;
mockRouterData.pageType = ConfigurationRouter.PageType.OVERVIEW;
mockRouterData.pageType = ConfiguratorRouter.PageType.OVERVIEW;
initialize();
}

Expand Down Expand Up @@ -240,7 +240,7 @@ describe('ConfigAddToCartButtonComponent', () => {

describe('onAddToCart', () => {
it('should navigate to OV in case configuration is cart bound and we are on product config page', () => {
mockRouterData.pageType = ConfigurationRouter.PageType.CONFIGURATION;
mockRouterData.pageType = ConfiguratorRouter.PageType.CONFIGURATION;
performUpdateCart();
expect(routingService.go).toHaveBeenCalledWith(
navParamsOverview,
Expand All @@ -265,7 +265,7 @@ describe('ConfigAddToCartButtonComponent', () => {

it('should not remove configuration and display no message in case continue to cart is triggered on config page', () => {
mockProductConfiguration.isCartEntryUpdateRequired = false;
mockRouterData.pageType = ConfigurationRouter.PageType.CONFIGURATION;
mockRouterData.pageType = ConfiguratorRouter.PageType.CONFIGURATION;
performUpdateCart();
expect(
configuratorCommonsService.removeConfiguration
Expand Down Expand Up @@ -302,7 +302,7 @@ describe('ConfigAddToCartButtonComponent', () => {
});

it('should navigate to cart in case configuration has not yet been added and process was triggered from overview', () => {
mockRouterData.pageType = ConfigurationRouter.PageType.OVERVIEW;
mockRouterData.pageType = ConfiguratorRouter.PageType.OVERVIEW;
performAddToCartOnOverview();
expect(routingService.go).toHaveBeenCalledWith('cart');
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
import { ChangeDetectionStrategy, Component } from '@angular/core';
import {
Configurator,
GenericConfigurator,
GlobalMessageService,
GlobalMessageType,
RoutingService,
} from '@spartacus/core';
import {
ConfigurationRouter,
ConfiguratorRouterExtractorService,
} from '@spartacus/storefront';
import { Observable } from 'rxjs';
import { filter, map, switchMap, take } from 'rxjs/operators';
import { ConfiguratorCartService } from '../../core/facade/configurator-cart.service';
import { ConfiguratorCommonsService } from '../../core/facade/configurator-commons.service';
import { ConfiguratorGroupsService } from '../../core/facade/configurator-groups.service';
import { Configurator } from './../../core/model/configurator.model';
import { ConfiguratorRouter } from './../service/configurator-router-data';
import { ConfiguratorRouterExtractorService } from './../service/configurator-router-extractor.service';

@Component({
selector: 'cx-config-add-to-cart-button',
Expand All @@ -23,7 +21,7 @@ import { ConfiguratorGroupsService } from '../../core/facade/configurator-groups
})
export class ConfiguratorAddToCartButtonComponent {
container$: Observable<{
routerData: ConfigurationRouter.Data;
routerData: ConfiguratorRouter.Data;
configuration: Configurator.Configuration;
hasPendingChanges: boolean;
}> = this.configRouterExtractorService.extractRouterData().pipe(
Expand Down Expand Up @@ -112,12 +110,12 @@ export class ConfiguratorAddToCartButtonComponent {
/**
* Decides on the resource key for the button. Depending on the business process (owner of the configuration) and the
* need for a cart update, the text will differ
* @param {ConfigurationRouter.Data} routerData - Reflects the current router state
* @param {ConfiguratorRouter.Data} routerData - Reflects the current router state
* @param {Configurator.Configuration} configuration - Configuration
* @returns {string} The resource key that controls the button description
*/
getButtonResourceKey(
routerData: ConfigurationRouter.Data,
routerData: ConfiguratorRouter.Data,
configuration: Configurator.Configuration
): string {
if (
Expand All @@ -139,16 +137,16 @@ export class ConfiguratorAddToCartButtonComponent {
* Triggers action and navigation, both depending on the context. Might result in an addToCart, updateCartEntry,
* just a cart navigation or a browser back navigation
* @param {Configurator.Configuration} configuration - Configuration
* @param {ConfigurationRouter.Data} routerData - Reflects the current router state
* @param {ConfiguratorRouter.Data} routerData - Reflects the current router state

*/
onAddToCart(
configuration: Configurator.Configuration,
routerData: ConfigurationRouter.Data
routerData: ConfiguratorRouter.Data
): void {
const pageType = routerData.pageType;
const configuratorType = routerData.configuratorType;
const isOverview = pageType === ConfigurationRouter.PageType.OVERVIEW;
const isOverview = pageType === ConfiguratorRouter.PageType.OVERVIEW;
const isOwnerCartEntry =
routerData.owner.type === GenericConfigurator.OwnerType.CART_ENTRY;
const owner = configuration.owner;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import { ChangeDetectionStrategy } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import {
Configurator,
GenericConfigurator,
I18nTestingModule,
} from '@spartacus/core';
import { GenericConfigurator, I18nTestingModule } from '@spartacus/core';
import {
IconLoaderService,
IconModule,
Expand All @@ -13,6 +9,7 @@ import {
import { Observable, of } from 'rxjs';
import { ConfiguratorComponentTestUtilsService } from '../../../shared/testing/configurator-component-test-utils.service';
import { ConfiguratorStorefrontUtilsService } from '../../service/configurator-storefront-utils.service';
import { Configurator } from './../../../core/model/configurator.model';
import { ConfiguratorAttributeFooterComponent } from './configurator-attribute-footer.component';

export class MockIconFontLoaderService {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import {
Input,
OnInit,
} from '@angular/core';
import { Configurator, GenericConfigurator } from '@spartacus/core';
import { GenericConfigurator } from '@spartacus/core';
import { ICON_TYPE } from '@spartacus/storefront';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { ConfiguratorStorefrontUtilsService } from '../../service/configurator-storefront-utils.service';
import { Configurator } from './../../../core/model/configurator.model';

@Component({
selector: 'cx-config-attribute-footer',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import { ChangeDetectionStrategy } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import {
Configurator,
GenericConfigurator,
I18nTestingModule,
} from '@spartacus/core';
import { GenericConfigurator, I18nTestingModule } from '@spartacus/core';
import {
IconLoaderService,
IconModule,
Expand All @@ -13,6 +9,7 @@ import {
import { Observable, of } from 'rxjs';
import { ConfiguratorComponentTestUtilsService } from '../../../shared/testing/configurator-component-test-utils.service';
import { ConfiguratorStorefrontUtilsService } from '../../service/configurator-storefront-utils.service';
import { Configurator } from './../../../core/model/configurator.model';
import { ConfiguratorAttributeHeaderComponent } from './configurator-attribute-header.component';

export class MockIconFontLoaderService {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import {
Input,
OnInit,
} from '@angular/core';
import { Configurator, GenericConfigurator } from '@spartacus/core';
import { GenericConfigurator } from '@spartacus/core';
import { ICON_TYPE } from '@spartacus/storefront';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { ConfiguratorStorefrontUtilsService } from '../../service/configurator-storefront-utils.service';
import { ConfiguratorUIKeyGenerator } from '../../service/configurator-ui-key-generator';
import { Configurator } from './../../../core/model/configurator.model';

@Component({
selector: 'cx-config-attribute-header',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ReactiveFormsModule } from '@angular/forms';
import { By } from '@angular/platform-browser';
import { NgSelectModule } from '@ng-select/ng-select';
import { Configurator } from 'projects/core/src/model/configurator.model';
import { ConfiguratorGroupsService } from '../../../../core/facade/configurator-groups.service';
import { ConfiguratorStorefrontUtilsService } from '../../../service/configurator-storefront-utils.service';
import { ConfiguratorUIKeyGenerator } from '../../../service/configurator-ui-key-generator';
import { Configurator } from './../../../../core/model/configurator.model';
import { ConfiguratorAttributeCheckBoxListComponent } from './configurator-attribute-checkbox-list.component';

class MockGroupService {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import {
Output,
} from '@angular/core';
import { FormControl } from '@angular/forms';
import { Configurator } from '@spartacus/core';
import { ConfigFormUpdateEvent } from '../../../form/configurator-form.event';
import { ConfiguratorStorefrontUtilsService } from '../../../service/configurator-storefront-utils.service';
import { ConfiguratorUIKeyGenerator } from '../../../service/configurator-ui-key-generator';
import { Configurator } from './../../../../core/model/configurator.model';
@Component({
selector: 'cx-config-attribute-checkbox-list',
templateUrl: './configurator-attribute-checkbox-list.component.html',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ReactiveFormsModule } from '@angular/forms';
import { By } from '@angular/platform-browser';
import { NgSelectModule } from '@ng-select/ng-select';
import { Configurator } from 'projects/core/src/model/configurator.model';
import { ConfiguratorUIKeyGenerator } from '../../../service/configurator-ui-key-generator';
import { Configurator } from './../../../../core/model/configurator.model';
import { ConfiguratorAttributeCheckBoxComponent } from './configurator-attribute-checkbox.component';

describe('ConfigAttributeCheckBoxComponent', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import {
Output,
} from '@angular/core';
import { FormControl } from '@angular/forms';
import { Configurator } from '@spartacus/core';
import { ConfigFormUpdateEvent } from '../../../form/configurator-form.event';
import { ConfiguratorUIKeyGenerator } from '../../../service/configurator-ui-key-generator';
import { Configurator } from './../../../../core/model/configurator.model';

@Component({
selector: 'cx-config-attribute-checkbox',
templateUrl: './configurator-attribute-checkbox.component.html',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { ChangeDetectionStrategy } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ReactiveFormsModule } from '@angular/forms';
import { NgSelectModule } from '@ng-select/ng-select';
import { Configurator } from '@spartacus/core';
import { ConfiguratorUIKeyGenerator } from '../../../service/configurator-ui-key-generator';
import { Configurator } from './../../../../core/model/configurator.model';
import { ConfiguratorAttributeDropDownComponent } from './configurator-attribute-drop-down.component';

describe('ConfigAttributeDropDownComponent', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import {
Output,
} from '@angular/core';
import { FormControl } from '@angular/forms';
import { Configurator } from '@spartacus/core';
import { ConfigFormUpdateEvent } from '../../../form/configurator-form.event';
import { ConfiguratorUIKeyGenerator } from '../../../service/configurator-ui-key-generator';
import { Configurator } from './../../../../core/model/configurator.model';
@Component({
selector: 'cx-config-attribute-drop-down',
templateUrl: './configurator-attribute-drop-down.component.html',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import { ChangeDetectionStrategy } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ReactiveFormsModule } from '@angular/forms';
import { By } from '@angular/platform-browser';
import { Configurator, GenericConfigurator } from '@spartacus/core';
import { GenericConfigurator } from '@spartacus/core';
import { ConfiguratorUIKeyGenerator } from '../../../service/configurator-ui-key-generator';
import { Configurator } from './../../../../core/model/configurator.model';
import { ConfiguratorAttributeInputFieldComponent } from './configurator-attribute-input-field.component';

describe('ConfigAttributeInputFieldComponent', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import {
Output,
} from '@angular/core';
import { FormControl } from '@angular/forms';
import { Configurator, GenericConfigurator } from '@spartacus/core';
import { GenericConfigurator } from '@spartacus/core';
import { ConfigFormUpdateEvent } from '../../../form/configurator-form.event';
import { ConfiguratorUIKeyGenerator } from '../../../service/configurator-ui-key-generator';
import { Configurator } from './../../../../core/model/configurator.model';

@Component({
selector: 'cx-config-attribute-input-field',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ReactiveFormsModule } from '@angular/forms';
import { By } from '@angular/platform-browser';
import { NgSelectModule } from '@ng-select/ng-select';
import { Configurator } from '@spartacus/core';
import { ConfiguratorGroupsService } from '../../../../core/facade/configurator-groups.service';
import { ConfiguratorStorefrontUtilsService } from '../../../service/configurator-storefront-utils.service';
import { ConfiguratorUIKeyGenerator } from '../../../service/configurator-ui-key-generator';
import { Configurator } from './../../../../core/model/configurator.model';
import { ConfiguratorAttributeMultiSelectionImageComponent } from './configurator-attribute-multi-selection-image.component';
class MockGroupService {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import {
Output,
} from '@angular/core';
import { FormControl } from '@angular/forms';
import { Configurator } from '@spartacus/core';
import { ConfigFormUpdateEvent } from '../../../form/configurator-form.event';
import { ConfiguratorStorefrontUtilsService } from '../../../service/configurator-storefront-utils.service';
import { ConfiguratorUIKeyGenerator } from '../../../service/configurator-ui-key-generator';
import { Configurator } from './../../../../core/model/configurator.model';
@Component({
selector: 'cx-config-attribute-multi-selection-image',
templateUrl: './configurator-attribute-multi-selection-image.component.html',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { ChangeDetectionStrategy, Pipe, PipeTransform } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ReactiveFormsModule } from '@angular/forms';
import { Configurator, LanguageService } from '@spartacus/core';
import { LanguageService } from '@spartacus/core';
import { of } from 'rxjs';
import { ConfiguratorUIKeyGenerator } from '../../../service/configurator-ui-key-generator';
import { Configurator } from './../../../../core/model/configurator.model';
import { ConfiguratorAttributeNumericInputFieldComponent } from './configurator-attribute-numeric-input-field.component';

@Pipe({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import {
Output,
} from '@angular/core';
import { FormControl } from '@angular/forms';
import { Configurator } from '@spartacus/core';
import { ConfigFormUpdateEvent } from '../../../form/configurator-form.event';
import { ConfiguratorUIKeyGenerator } from '../../../service/configurator-ui-key-generator';
import { Configurator } from './../../../../core/model/configurator.model';
import { ConfiguratorAttributeNumericInputFieldService } from './configurator-attribute-numeric-input-field.component.service';

@Component({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { ChangeDetectionStrategy } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ReactiveFormsModule } from '@angular/forms';
import { Configurator } from '@spartacus/core';
import { ConfiguratorUIKeyGenerator } from '../../../service/configurator-ui-key-generator';
import { Configurator } from './../../../../core/model/configurator.model';
import { ConfiguratorAttributeRadioButtonComponent } from './configurator-attribute-radio-button.component';

describe('ConfigAttributeRadioButtonComponent', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import {
Output,
} from '@angular/core';
import { FormControl } from '@angular/forms';
import { Configurator } from '@spartacus/core';
import { ConfigFormUpdateEvent } from '../../../form/configurator-form.event';
import { ConfiguratorUIKeyGenerator } from '../../../service/configurator-ui-key-generator';
import { Configurator } from './../../../../core/model/configurator.model';
@Component({
selector: 'cx-config-attribute-radio-button',
templateUrl: './configurator-attribute-radio-button.component.html',
Expand Down
Loading