From 3264472fc374df0d9fac0a0a018a08ac7c53a705 Mon Sep 17 00:00:00 2001 From: Christoph Hinssen Date: Wed, 29 Sep 2021 13:28:51 +0200 Subject: [PATCH 1/7] GH-13807 Introduction of dedicated layout modules --- .../cpq/cpq-configurator-layout.module.ts | 54 +++++++++++++++++++ .../rulebased/root/cpq/index.ts | 1 + .../rulebased/root/variant/index.ts | 2 + ...-configurator-interactive-layout.module.ts | 50 +++++++++++++++++ ...ant-configurator-overview-layout.module.ts | 35 ++++++++++++ ...nfigurator-rulebased-cpq-feature.module.ts | 11 +++- ...t-configurator-rulebased-feature.module.ts | 8 ++- 7 files changed, 159 insertions(+), 2 deletions(-) create mode 100644 feature-libs/product-configurator/rulebased/root/cpq/cpq-configurator-layout.module.ts create mode 100644 feature-libs/product-configurator/rulebased/root/variant/variant-configurator-interactive-layout.module.ts create mode 100644 feature-libs/product-configurator/rulebased/root/variant/variant-configurator-overview-layout.module.ts diff --git a/feature-libs/product-configurator/rulebased/root/cpq/cpq-configurator-layout.module.ts b/feature-libs/product-configurator/rulebased/root/cpq/cpq-configurator-layout.module.ts new file mode 100644 index 00000000000..36a8be9265a --- /dev/null +++ b/feature-libs/product-configurator/rulebased/root/cpq/cpq-configurator-layout.module.ts @@ -0,0 +1,54 @@ +import { NgModule } from '@angular/core'; +import { CmsConfig, provideDefaultConfig } from '@spartacus/core'; + +/** + * Contains the layout configuration for the CPQ configurator pages. This configuration is + * optional as of version 4.2, and reduces the components that are rendered in the header section. + * It needs to be explicitly imported, otherwise the default configuration + * from VariantConfiguratorInteractiveModule is active + */ +@NgModule({ + providers: [ + provideDefaultConfig({ + layoutSlots: { + CpqConfigurationTemplate: { + header: { + md: { + slots: ['PreHeader', 'SiteLogo', 'MiniCart'], + }, + xs: { + slots: ['PreHeader', 'SiteLogo', 'MiniCart'], + }, + }, + + navigation: { + lg: { slots: [] }, + slots: ['CpqConfigMenu'], + }, + + lg: { + slots: [ + 'CpqConfigHeader', + 'CpqConfigBanner', + 'CpqConfigMenu', + 'CpqConfigContent', + 'CpqConfigOverviewBanner', + 'CpqConfigOverviewContent', + 'CpqConfigBottombar', + ], + }, + + slots: [ + 'CpqConfigHeader', + 'CpqConfigBanner', + 'CpqConfigContent', + 'CpqConfigOverviewBanner', + 'CpqConfigOverviewContent', + 'CpqConfigBottombar', + ], + }, + }, + }), + ], +}) +export class CpqConfiguratorLayoutModule {} diff --git a/feature-libs/product-configurator/rulebased/root/cpq/index.ts b/feature-libs/product-configurator/rulebased/root/cpq/index.ts index 1fda03488cf..e64f3e1bd0b 100644 --- a/feature-libs/product-configurator/rulebased/root/cpq/index.ts +++ b/feature-libs/product-configurator/rulebased/root/cpq/index.ts @@ -1,4 +1,5 @@ export * from './cpq-configurator-interactive.module'; export * from './cpq-configurator-overview.module'; export * from './cpq-configurator-root.module'; +export * from './cpq-configurator-layout.module'; export * from './interceptor/index'; diff --git a/feature-libs/product-configurator/rulebased/root/variant/index.ts b/feature-libs/product-configurator/rulebased/root/variant/index.ts index 36bb77f4758..9140c1f65e5 100644 --- a/feature-libs/product-configurator/rulebased/root/variant/index.ts +++ b/feature-libs/product-configurator/rulebased/root/variant/index.ts @@ -1,2 +1,4 @@ export * from './variant-configurator-interactive.module'; export * from './variant-configurator-overview.module'; +export * from './variant-configurator-interactive-layout.module'; +export * from './variant-configurator-overview-layout.module'; diff --git a/feature-libs/product-configurator/rulebased/root/variant/variant-configurator-interactive-layout.module.ts b/feature-libs/product-configurator/rulebased/root/variant/variant-configurator-interactive-layout.module.ts new file mode 100644 index 00000000000..4cec1c64276 --- /dev/null +++ b/feature-libs/product-configurator/rulebased/root/variant/variant-configurator-interactive-layout.module.ts @@ -0,0 +1,50 @@ +import { NgModule } from '@angular/core'; + +import { provideDefaultConfig } from '@spartacus/core'; +import { LayoutConfig } from '@spartacus/storefront'; + +/** + * Contains the layout configuration for the interactive configuration page. This configuration is + * optional as of version 4.2, and reduces the components that are rendered in the header section. + * It needs to be explicitly imported, otherwise the default configuration + * from VariantConfiguratorInteractiveModule is active + */ +@NgModule({ + providers: [ + provideDefaultConfig({ + layoutSlots: { + VariantConfigurationTemplate: { + header: { + md: { + slots: ['PreHeader', 'SiteLogo', 'MiniCart'], + }, + xs: { + slots: ['PreHeader', 'SiteLogo', 'MiniCart'], + }, + }, + + navigation: { + lg: { slots: [] }, + slots: ['VariantConfigMenu'], + }, + + lg: { + slots: [ + 'VariantConfigHeader', + 'VariantConfigMenu', + 'VariantConfigContent', + 'VariantConfigBottombar', + ], + }, + + slots: [ + 'VariantConfigHeader', + 'VariantConfigContent', + 'VariantConfigBottombar', + ], + }, + }, + }), + ], +}) +export class VariantConfiguratorInteractiveLayoutModule {} diff --git a/feature-libs/product-configurator/rulebased/root/variant/variant-configurator-overview-layout.module.ts b/feature-libs/product-configurator/rulebased/root/variant/variant-configurator-overview-layout.module.ts new file mode 100644 index 00000000000..4bd093d12b6 --- /dev/null +++ b/feature-libs/product-configurator/rulebased/root/variant/variant-configurator-overview-layout.module.ts @@ -0,0 +1,35 @@ +import { NgModule } from '@angular/core'; +import { provideDefaultConfig } from '@spartacus/core'; +import { LayoutConfig } from '@spartacus/storefront'; + +/** + * Contains the layout configuration for the overview configuration page. This configuration is + * optional as of version 4.2, and reduces the components that are rendered in the header section. + * It needs to be explicitly imported, otherwise the default configuration + * from VariantConfiguratorOverviewModule is active + */ +@NgModule({ + providers: [ + provideDefaultConfig({ + layoutSlots: { + VariantConfigurationOverviewTemplate: { + header: { + md: { + slots: ['SiteLogo', 'MiniCart'], + }, + xs: { + slots: ['SiteLogo', 'MiniCart'], + }, + }, + slots: [ + 'VariantConfigOverviewHeader', + 'VariantConfigOverviewBanner', + 'VariantConfigOverviewContent', + 'VariantConfigOverviewBottombar', + ], + }, + }, + }), + ], +}) +export class VariantConfiguratorOverviewLayoutModule {} diff --git a/projects/storefrontapp/src/app/spartacus/features/product-configurator-rulebased-cpq-feature.module.ts b/projects/storefrontapp/src/app/spartacus/features/product-configurator-rulebased-cpq-feature.module.ts index ed150247643..9ed55e3e5f2 100644 --- a/projects/storefrontapp/src/app/spartacus/features/product-configurator-rulebased-cpq-feature.module.ts +++ b/projects/storefrontapp/src/app/spartacus/features/product-configurator-rulebased-cpq-feature.module.ts @@ -6,9 +6,18 @@ import { PRODUCT_CONFIGURATOR_RULEBASED_FEATURE, RulebasedConfiguratorRootModule, } from '@spartacus/product-configurator/rulebased/root'; +import { VariantConfiguratorInteractiveLayoutModule } from '@spartacus/product-configurator/rulebased/root'; +import { VariantConfiguratorOverviewLayoutModule } from '@spartacus/product-configurator/rulebased/root'; +import { CpqConfiguratorLayoutModule } from '@spartacus/product-configurator/rulebased/root'; @NgModule({ - imports: [RulebasedConfiguratorRootModule, CpqConfiguratorRootModule], + imports: [ + RulebasedConfiguratorRootModule, + VariantConfiguratorInteractiveLayoutModule, + VariantConfiguratorOverviewLayoutModule, + CpqConfiguratorRootModule, + CpqConfiguratorLayoutModule, + ], providers: [ provideConfig({ featureModules: { diff --git a/projects/storefrontapp/src/app/spartacus/features/product-configurator-rulebased-feature.module.ts b/projects/storefrontapp/src/app/spartacus/features/product-configurator-rulebased-feature.module.ts index 50497ecbe64..e25c1a61f89 100644 --- a/projects/storefrontapp/src/app/spartacus/features/product-configurator-rulebased-feature.module.ts +++ b/projects/storefrontapp/src/app/spartacus/features/product-configurator-rulebased-feature.module.ts @@ -5,9 +5,15 @@ import { PRODUCT_CONFIGURATOR_RULEBASED_FEATURE, RulebasedConfiguratorRootModule, } from '@spartacus/product-configurator/rulebased/root'; +import { VariantConfiguratorInteractiveLayoutModule } from '@spartacus/product-configurator/rulebased/root'; +import { VariantConfiguratorOverviewLayoutModule } from '@spartacus/product-configurator/rulebased/root'; @NgModule({ - imports: [RulebasedConfiguratorRootModule], + imports: [ + RulebasedConfiguratorRootModule, + VariantConfiguratorInteractiveLayoutModule, + VariantConfiguratorOverviewLayoutModule, + ], providers: [ provideConfig({ featureModules: { From 61f9fcbce49dabc0e0b1a78867cad49877ddea08 Mon Sep 17 00:00:00 2001 From: Christoph Hinssen Date: Fri, 1 Oct 2021 11:15:14 +0200 Subject: [PATCH 2/7] GH-13807 LayoutConfig instead of CmsConfig when providing layout --- .../root/cpq/cpq-configurator-interactive.module.ts | 5 +++-- .../rulebased/root/cpq/cpq-configurator-layout.module.ts | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/feature-libs/product-configurator/rulebased/root/cpq/cpq-configurator-interactive.module.ts b/feature-libs/product-configurator/rulebased/root/cpq/cpq-configurator-interactive.module.ts index dc46749cee2..9b39b46290b 100644 --- a/feature-libs/product-configurator/rulebased/root/cpq/cpq-configurator-interactive.module.ts +++ b/feature-libs/product-configurator/rulebased/root/cpq/cpq-configurator-interactive.module.ts @@ -1,9 +1,10 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; -import { CmsConfig, provideDefaultConfig } from '@spartacus/core'; +import { provideDefaultConfig } from '@spartacus/core'; import { CmsPageGuard, HamburgerMenuModule, + LayoutConfig, PageLayoutComponent, } from '@spartacus/storefront'; import { defaultCpqInteractiveRoutingConfig } from './default-cpq-interactive-routing-config'; @@ -30,7 +31,7 @@ import { defaultCpqInteractiveRoutingConfig } from './default-cpq-interactive-ro ], providers: [ provideDefaultConfig(defaultCpqInteractiveRoutingConfig), - provideDefaultConfig({ + provideDefaultConfig({ layoutSlots: { CpqConfigurationTemplate: { header: { diff --git a/feature-libs/product-configurator/rulebased/root/cpq/cpq-configurator-layout.module.ts b/feature-libs/product-configurator/rulebased/root/cpq/cpq-configurator-layout.module.ts index 36a8be9265a..0f8d2af2ba2 100644 --- a/feature-libs/product-configurator/rulebased/root/cpq/cpq-configurator-layout.module.ts +++ b/feature-libs/product-configurator/rulebased/root/cpq/cpq-configurator-layout.module.ts @@ -1,5 +1,6 @@ import { NgModule } from '@angular/core'; -import { CmsConfig, provideDefaultConfig } from '@spartacus/core'; +import { provideDefaultConfig } from '@spartacus/core'; +import { LayoutConfig } from 'projects/storefrontlib/layout'; /** * Contains the layout configuration for the CPQ configurator pages. This configuration is @@ -9,7 +10,7 @@ import { CmsConfig, provideDefaultConfig } from '@spartacus/core'; */ @NgModule({ providers: [ - provideDefaultConfig({ + provideDefaultConfig({ layoutSlots: { CpqConfigurationTemplate: { header: { From c0eebfcf714636662596473738d47d48bf53cf79 Mon Sep 17 00:00:00 2001 From: Christoph Hinssen Date: Fri, 1 Oct 2021 15:58:07 +0200 Subject: [PATCH 3/7] GH-13807 Introduce layout handler --- .../cpq/cpq-configurator-layout.module.ts | 12 +++++- .../cpq-configurator-page-layout-handler.ts | 42 +++++++++++++++++++ 2 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 feature-libs/product-configurator/rulebased/root/cpq/cpq-configurator-page-layout-handler.ts diff --git a/feature-libs/product-configurator/rulebased/root/cpq/cpq-configurator-layout.module.ts b/feature-libs/product-configurator/rulebased/root/cpq/cpq-configurator-layout.module.ts index 0f8d2af2ba2..372c03109f1 100644 --- a/feature-libs/product-configurator/rulebased/root/cpq/cpq-configurator-layout.module.ts +++ b/feature-libs/product-configurator/rulebased/root/cpq/cpq-configurator-layout.module.ts @@ -1,6 +1,8 @@ import { NgModule } from '@angular/core'; import { provideDefaultConfig } from '@spartacus/core'; +import { PAGE_LAYOUT_HANDLER } from '@spartacus/storefront'; import { LayoutConfig } from 'projects/storefrontlib/layout'; +import { CpqConfiguratorPageLayouHandler } from './cpq-configurator-page-layout-handler'; /** * Contains the layout configuration for the CPQ configurator pages. This configuration is @@ -15,10 +17,10 @@ import { LayoutConfig } from 'projects/storefrontlib/layout'; CpqConfigurationTemplate: { header: { md: { - slots: ['PreHeader', 'SiteLogo', 'MiniCart'], + slots: ['SiteLogo', 'MiniCart'], }, xs: { - slots: ['PreHeader', 'SiteLogo', 'MiniCart'], + slots: ['SiteLogo', 'MiniCart'], }, }, @@ -50,6 +52,12 @@ import { LayoutConfig } from 'projects/storefrontlib/layout'; }, }, }), + + { + provide: PAGE_LAYOUT_HANDLER, + useExisting: CpqConfiguratorPageLayouHandler, + multi: true, + }, ], }) export class CpqConfiguratorLayoutModule {} diff --git a/feature-libs/product-configurator/rulebased/root/cpq/cpq-configurator-page-layout-handler.ts b/feature-libs/product-configurator/rulebased/root/cpq/cpq-configurator-page-layout-handler.ts new file mode 100644 index 00000000000..2b0badab36a --- /dev/null +++ b/feature-libs/product-configurator/rulebased/root/cpq/cpq-configurator-page-layout-handler.ts @@ -0,0 +1,42 @@ +import { Injectable } from '@angular/core'; +import { PageLayoutHandler } from '@spartacus/storefront'; +import { + ConfiguratorRouter, + ConfiguratorRouterExtractorService, +} from '@spartacus/product-configurator/common'; +import { Observable } from 'rxjs'; +import { map, take } from 'rxjs/operators'; +@Injectable({ + providedIn: 'root', +}) +export class CpqConfiguratorPageLayouHandler implements PageLayoutHandler { + constructor( + protected configuratorRouterExtractorService: ConfiguratorRouterExtractorService + ) {} + handle( + slots$: Observable, + pageTemplate?: string, + section?: string + ) { + if (pageTemplate === 'CpqConfigurationTemplate' && section === 'header') { + this.configuratorRouterExtractorService + .extractRouterData() + .pipe(take(1)) + .subscribe((routerData) => { + if ( + routerData.pageType === ConfiguratorRouter.PageType.CONFIGURATION + ) { + slots$ = slots$.pipe( + map((slots) => { + const extendedSlots = ['PreHeader']; + extendedSlots.push(...slots); + return extendedSlots; + }) + ); + } + }); + } + + return slots$; + } +} From a38a0ac6a039a22b007063d1bbf67e0148ec278a Mon Sep 17 00:00:00 2001 From: Christoph Hinssen Date: Mon, 4 Oct 2021 07:06:00 +0200 Subject: [PATCH 4/7] Start with test --- .../cpq/cpq-configurator-layout.module.ts | 4 +- ...q-configurator-page-layout-handler.spec.ts | 38 +++++++++++++++++++ .../cpq-configurator-page-layout-handler.ts | 2 +- 3 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 feature-libs/product-configurator/rulebased/root/cpq/cpq-configurator-page-layout-handler.spec.ts diff --git a/feature-libs/product-configurator/rulebased/root/cpq/cpq-configurator-layout.module.ts b/feature-libs/product-configurator/rulebased/root/cpq/cpq-configurator-layout.module.ts index 372c03109f1..ad5ad4ae215 100644 --- a/feature-libs/product-configurator/rulebased/root/cpq/cpq-configurator-layout.module.ts +++ b/feature-libs/product-configurator/rulebased/root/cpq/cpq-configurator-layout.module.ts @@ -2,7 +2,7 @@ import { NgModule } from '@angular/core'; import { provideDefaultConfig } from '@spartacus/core'; import { PAGE_LAYOUT_HANDLER } from '@spartacus/storefront'; import { LayoutConfig } from 'projects/storefrontlib/layout'; -import { CpqConfiguratorPageLayouHandler } from './cpq-configurator-page-layout-handler'; +import { CpqConfiguratorPageLayoutHandler } from './cpq-configurator-page-layout-handler'; /** * Contains the layout configuration for the CPQ configurator pages. This configuration is @@ -55,7 +55,7 @@ import { CpqConfiguratorPageLayouHandler } from './cpq-configurator-page-layout- { provide: PAGE_LAYOUT_HANDLER, - useExisting: CpqConfiguratorPageLayouHandler, + useExisting: CpqConfiguratorPageLayoutHandler, multi: true, }, ], diff --git a/feature-libs/product-configurator/rulebased/root/cpq/cpq-configurator-page-layout-handler.spec.ts b/feature-libs/product-configurator/rulebased/root/cpq/cpq-configurator-page-layout-handler.spec.ts new file mode 100644 index 00000000000..4515108c2da --- /dev/null +++ b/feature-libs/product-configurator/rulebased/root/cpq/cpq-configurator-page-layout-handler.spec.ts @@ -0,0 +1,38 @@ +import { Type } from '@angular/core'; +import { TestBed } from '@angular/core/testing'; +import { Observable, of } from 'rxjs'; + +import { CpqConfiguratorPageLayoutHandler } from './cpq-configurator-page-layout-handler'; + +describe('CpqConfiguratorPageLayoutHandler', () => { + let serviceUnderTest: CpqConfiguratorPageLayoutHandler; + let slots$: Observable = of(['a']); + let pageTemplate = 'a'; + let section = 'c'; + + beforeEach(() => { + TestBed.configureTestingModule({}); + + serviceUnderTest = TestBed.inject( + CpqConfiguratorPageLayoutHandler as Type + ); + }); + + it('should create service', () => { + expect(serviceUnderTest).toBeDefined(); + }); + + it('should call getCpqAccessData endpoint', () => { + serviceUnderTest.handle(slots$, pageTemplate, section); + // serviceUnderTest.getCpqAccessData().subscribe(); + // const mockReq = httpMock.expectOne((req) => { + // return req.method === 'GET' && req.url === '/getCpqAccessData'; + // }); + // expect(occEnpointsService.buildUrl).toHaveBeenCalledWith( + // 'getCpqAccessData' + // ); + // expect(mockReq.cancelled).toBeFalsy(); + // expect(mockReq.request.responseType).toEqual('json'); + // mockReq.flush(accessData); + }); +}); diff --git a/feature-libs/product-configurator/rulebased/root/cpq/cpq-configurator-page-layout-handler.ts b/feature-libs/product-configurator/rulebased/root/cpq/cpq-configurator-page-layout-handler.ts index 2b0badab36a..fff7c9a01d6 100644 --- a/feature-libs/product-configurator/rulebased/root/cpq/cpq-configurator-page-layout-handler.ts +++ b/feature-libs/product-configurator/rulebased/root/cpq/cpq-configurator-page-layout-handler.ts @@ -9,7 +9,7 @@ import { map, take } from 'rxjs/operators'; @Injectable({ providedIn: 'root', }) -export class CpqConfiguratorPageLayouHandler implements PageLayoutHandler { +export class CpqConfiguratorPageLayoutHandler implements PageLayoutHandler { constructor( protected configuratorRouterExtractorService: ConfiguratorRouterExtractorService ) {} From 88bbbc5ce64df1163ea898d18cd47013752c983c Mon Sep 17 00:00:00 2001 From: Christoph Hinssen Date: Mon, 4 Oct 2021 08:25:15 +0200 Subject: [PATCH 5/7] GH-13807 Add test --- ...q-configurator-page-layout-handler.spec.ts | 124 +++++++++++++++--- 1 file changed, 106 insertions(+), 18 deletions(-) diff --git a/feature-libs/product-configurator/rulebased/root/cpq/cpq-configurator-page-layout-handler.spec.ts b/feature-libs/product-configurator/rulebased/root/cpq/cpq-configurator-page-layout-handler.spec.ts index 4515108c2da..ee1de315f01 100644 --- a/feature-libs/product-configurator/rulebased/root/cpq/cpq-configurator-page-layout-handler.spec.ts +++ b/feature-libs/product-configurator/rulebased/root/cpq/cpq-configurator-page-layout-handler.spec.ts @@ -1,18 +1,56 @@ import { Type } from '@angular/core'; -import { TestBed } from '@angular/core/testing'; +import { TestBed, waitForAsync } from '@angular/core/testing'; +import { + ConfiguratorModelUtils, + ConfiguratorRouter, + ConfiguratorRouterExtractorService, +} from '@spartacus/product-configurator/common'; +import { cold } from 'jasmine-marbles'; import { Observable, of } from 'rxjs'; import { CpqConfiguratorPageLayoutHandler } from './cpq-configurator-page-layout-handler'; +const standardRouterData: ConfiguratorRouter.Data = { + owner: ConfiguratorModelUtils.createInitialOwner(), +}; +let routerData: ConfiguratorRouter.Data; +class MockRouterExtractorService { + extractRouterData(): Observable { + return of(routerData); + } +} +const headerSlots = ['SiteLogo', 'MiniCart']; +const headerSlotsIncludingPreHeader = ['PreHeader', 'SiteLogo', 'MiniCart']; +const contentSlots = [ + 'CpqConfigHeader', + 'CpqConfigBanner', + 'CpqConfigMenu', + 'CpqConfigContent', + 'CpqConfigOverviewBanner', + 'CpqConfigOverviewContent', + 'CpqConfigBottombar', +]; +const pageTemplateCpq = 'CpqConfigurationTemplate'; +const pageTemplateOther = 'OtherTemplate'; +const sectionHeader = 'header'; +const sectionContent = 'content'; + describe('CpqConfiguratorPageLayoutHandler', () => { let serviceUnderTest: CpqConfiguratorPageLayoutHandler; - let slots$: Observable = of(['a']); - let pageTemplate = 'a'; - let section = 'c'; + beforeEach( + waitForAsync(() => { + TestBed.configureTestingModule({ + providers: [ + { + provide: ConfiguratorRouterExtractorService, + useClass: MockRouterExtractorService, + }, + ], + }).compileComponents(); + }) + ); beforeEach(() => { - TestBed.configureTestingModule({}); - serviceUnderTest = TestBed.inject( CpqConfiguratorPageLayoutHandler as Type ); @@ -22,17 +60,67 @@ describe('CpqConfiguratorPageLayoutHandler', () => { expect(serviceUnderTest).toBeDefined(); }); - it('should call getCpqAccessData endpoint', () => { - serviceUnderTest.handle(slots$, pageTemplate, section); - // serviceUnderTest.getCpqAccessData().subscribe(); - // const mockReq = httpMock.expectOne((req) => { - // return req.method === 'GET' && req.url === '/getCpqAccessData'; - // }); - // expect(occEnpointsService.buildUrl).toHaveBeenCalledWith( - // 'getCpqAccessData' - // ); - // expect(mockReq.cancelled).toBeFalsy(); - // expect(mockReq.request.responseType).toEqual('json'); - // mockReq.flush(accessData); + it('should not touch slots for section different than header', () => { + let slots$ = cold('-a', { + a: contentSlots, + }); + const handledSlots$ = serviceUnderTest.handle( + slots$, + pageTemplateCpq, + sectionContent + ); + expect(handledSlots$).toBeObservable(slots$); + }); + + it('should change slots for header section in cpq template in case we are on configuration page', () => { + routerData = { + ...standardRouterData, + pageType: ConfiguratorRouter.PageType.CONFIGURATION, + }; + let slots$ = cold('-a-a', { + a: headerSlots, + }); + const handledSlots$ = serviceUnderTest.handle( + slots$, + pageTemplateCpq, + sectionHeader + ); + expect(handledSlots$).toBeObservable( + cold('-a-a', { + a: headerSlotsIncludingPreHeader, + }) + ); + }); + + it('should not change slots for header section in cpq template in case we are on overview page', () => { + routerData = { + ...standardRouterData, + pageType: ConfiguratorRouter.PageType.OVERVIEW, + }; + let slots$ = cold('-aaa', { + a: headerSlots, + }); + const handledSlots$ = serviceUnderTest.handle( + slots$, + pageTemplateCpq, + sectionHeader + ); + expect(handledSlots$).toBeObservable(slots$); + }); + + it('should not change slots for header section in other template', () => { + routerData = { + ...standardRouterData, + pageType: ConfiguratorRouter.PageType.CONFIGURATION, + }; + let slots$ = cold('-a-a', { + a: headerSlots, + }); + const handledSlots$ = serviceUnderTest.handle( + slots$, + pageTemplateOther, + sectionHeader + ); + expect(handledSlots$).toBeObservable(slots$); }); }); From 686ea08fafb5561a697a7eaa4d30d07ddb1105f5 Mon Sep 17 00:00:00 2001 From: Christoph Hinssen Date: Mon, 4 Oct 2021 08:56:50 +0200 Subject: [PATCH 6/7] GH-13807 fix wrong import --- .../rulebased/root/cpq/cpq-configurator-layout.module.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/feature-libs/product-configurator/rulebased/root/cpq/cpq-configurator-layout.module.ts b/feature-libs/product-configurator/rulebased/root/cpq/cpq-configurator-layout.module.ts index ad5ad4ae215..b6da93d7183 100644 --- a/feature-libs/product-configurator/rulebased/root/cpq/cpq-configurator-layout.module.ts +++ b/feature-libs/product-configurator/rulebased/root/cpq/cpq-configurator-layout.module.ts @@ -1,7 +1,6 @@ import { NgModule } from '@angular/core'; import { provideDefaultConfig } from '@spartacus/core'; -import { PAGE_LAYOUT_HANDLER } from '@spartacus/storefront'; -import { LayoutConfig } from 'projects/storefrontlib/layout'; +import { LayoutConfig, PAGE_LAYOUT_HANDLER } from '@spartacus/storefront'; import { CpqConfiguratorPageLayoutHandler } from './cpq-configurator-page-layout-handler'; /** From 88141d82d5a73657bf9616f5629023e4448ad7d8 Mon Sep 17 00:00:00 2001 From: Christoph Hinssen Date: Tue, 5 Oct 2021 06:45:11 +0200 Subject: [PATCH 7/7] GH-13807 review feedback --- .../cpq-configurator-page-layout-handler.spec.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/feature-libs/product-configurator/rulebased/root/cpq/cpq-configurator-page-layout-handler.spec.ts b/feature-libs/product-configurator/rulebased/root/cpq/cpq-configurator-page-layout-handler.spec.ts index ee1de315f01..d091ca1e562 100644 --- a/feature-libs/product-configurator/rulebased/root/cpq/cpq-configurator-page-layout-handler.spec.ts +++ b/feature-libs/product-configurator/rulebased/root/cpq/cpq-configurator-page-layout-handler.spec.ts @@ -36,7 +36,7 @@ const sectionHeader = 'header'; const sectionContent = 'content'; describe('CpqConfiguratorPageLayoutHandler', () => { - let serviceUnderTest: CpqConfiguratorPageLayoutHandler; + let classUnderTest: CpqConfiguratorPageLayoutHandler; beforeEach( waitForAsync(() => { @@ -51,20 +51,20 @@ describe('CpqConfiguratorPageLayoutHandler', () => { }) ); beforeEach(() => { - serviceUnderTest = TestBed.inject( + classUnderTest = TestBed.inject( CpqConfiguratorPageLayoutHandler as Type ); }); it('should create service', () => { - expect(serviceUnderTest).toBeDefined(); + expect(classUnderTest).toBeDefined(); }); it('should not touch slots for section different than header', () => { let slots$ = cold('-a', { a: contentSlots, }); - const handledSlots$ = serviceUnderTest.handle( + const handledSlots$ = classUnderTest.handle( slots$, pageTemplateCpq, sectionContent @@ -80,7 +80,7 @@ describe('CpqConfiguratorPageLayoutHandler', () => { let slots$ = cold('-a-a', { a: headerSlots, }); - const handledSlots$ = serviceUnderTest.handle( + const handledSlots$ = classUnderTest.handle( slots$, pageTemplateCpq, sectionHeader @@ -100,7 +100,7 @@ describe('CpqConfiguratorPageLayoutHandler', () => { let slots$ = cold('-aaa', { a: headerSlots, }); - const handledSlots$ = serviceUnderTest.handle( + const handledSlots$ = classUnderTest.handle( slots$, pageTemplateCpq, sectionHeader @@ -116,7 +116,7 @@ describe('CpqConfiguratorPageLayoutHandler', () => { let slots$ = cold('-a-a', { a: headerSlots, }); - const handledSlots$ = serviceUnderTest.handle( + const handledSlots$ = classUnderTest.handle( slots$, pageTemplateOther, sectionHeader