From 3a7a6e4f9f84868650ad5195440d3ddc24dd2f15 Mon Sep 17 00:00:00 2001 From: Roman Chygryn <129765378+rmch91@users.noreply.github.com> Date: Tue, 10 Oct 2023 14:01:48 +0200 Subject: [PATCH] fix: add FeaturesConfigModule to CheckoutReviewSubmitModule (#17923) Add FeaturesConfigModule to CheckoutReviewSubmitModule to get rid of error. --- ...heckout-delivery-address.component.spec.ts | 2 + .../checkout-review-submit.component.spec.ts | 3 +- ...heckout-delivery-address.component.spec.ts | 7 +++- .../checkout-delivery-mode.component.spec.ts | 8 +++- .../checkout-delivery-mode.module.ts | 1 - .../checkout-payment-form.component.spec.ts | 2 + .../checkout-payment-method.component.spec.ts | 4 ++ .../checkout-place-order.component.spec.ts | 22 +++++++++-- .../checkout-review-submit.component.spec.ts | 3 +- .../checkout-review-submit.module.ts | 2 + ...checkout-review-shipping.component.spec.ts | 37 +++++++++++++++++-- .../checkout-place-order.component.spec.ts | 23 ++++++++++-- 12 files changed, 98 insertions(+), 16 deletions(-) diff --git a/feature-libs/checkout/b2b/components/checkout-delivery-address/checkout-delivery-address.component.spec.ts b/feature-libs/checkout/b2b/components/checkout-delivery-address/checkout-delivery-address.component.spec.ts index 0d63c0b9e60..3ab1a9adca9 100644 --- a/feature-libs/checkout/b2b/components/checkout-delivery-address/checkout-delivery-address.component.spec.ts +++ b/feature-libs/checkout/b2b/components/checkout-delivery-address/checkout-delivery-address.component.spec.ts @@ -143,6 +143,8 @@ class MockCardComponent { content: Card; @Input() fitToContainer: boolean; + @Input() + index: number; } describe('B2BCheckoutDeliveryAddressComponent', () => { diff --git a/feature-libs/checkout/b2b/components/checkout-review-submit/checkout-review-submit.component.spec.ts b/feature-libs/checkout/b2b/components/checkout-review-submit/checkout-review-submit.component.spec.ts index 9179d72fde1..5d7d7c6dd4e 100644 --- a/feature-libs/checkout/b2b/components/checkout-review-submit/checkout-review-submit.component.spec.ts +++ b/feature-libs/checkout/b2b/components/checkout-review-submit/checkout-review-submit.component.spec.ts @@ -30,7 +30,7 @@ import { QueryState, UserCostCenterService, } from '@spartacus/core'; -import { Card, PromotionsModule } from '@spartacus/storefront'; +import { Card, OutletModule, PromotionsModule } from '@spartacus/storefront'; import { IconTestingModule } from 'projects/storefrontlib/cms-components/misc/icon/testing/icon-testing.module'; import { BehaviorSubject, Observable, of } from 'rxjs'; import { B2BCheckoutReviewSubmitComponent } from './checkout-review-submit.component'; @@ -221,6 +221,7 @@ describe('B2BCheckoutReviewSubmitComponent', () => { PromotionsModule, RouterTestingModule, IconTestingModule, + OutletModule, ], declarations: [ B2BCheckoutReviewSubmitComponent, diff --git a/feature-libs/checkout/base/components/checkout-delivery-address/checkout-delivery-address.component.spec.ts b/feature-libs/checkout/base/components/checkout-delivery-address/checkout-delivery-address.component.spec.ts index e4219775fe4..1dad5745da6 100644 --- a/feature-libs/checkout/base/components/checkout-delivery-address/checkout-delivery-address.component.spec.ts +++ b/feature-libs/checkout/base/components/checkout-delivery-address/checkout-delivery-address.component.spec.ts @@ -9,11 +9,11 @@ import { } from '@spartacus/checkout/base/root'; import { Address, + FeaturesConfig, + FeaturesConfigModule, GlobalMessageService, I18nTestingModule, UserAddressService, - FeaturesConfig, - FeaturesConfigModule, } from '@spartacus/core'; import { Card } from '@spartacus/storefront'; import { EMPTY, of } from 'rxjs'; @@ -92,6 +92,7 @@ class MockAddressFormComponent { @Input() cancelBtnLabel: string; @Input() showTitleCode: boolean; @Input() setAsDefaultField: boolean; + @Input() addressData: Address; } @Component({ @@ -111,6 +112,8 @@ class MockCardComponent { content: Card; @Input() fitToContainer: boolean; + @Input() + index: number; } class MockCheckoutDeliveryModesFacade diff --git a/feature-libs/checkout/base/components/checkout-delivery-mode/checkout-delivery-mode.component.spec.ts b/feature-libs/checkout/base/components/checkout-delivery-mode/checkout-delivery-mode.component.spec.ts index 595d94d5356..19d552192b4 100644 --- a/feature-libs/checkout/base/components/checkout-delivery-mode/checkout-delivery-mode.component.spec.ts +++ b/feature-libs/checkout/base/components/checkout-delivery-mode/checkout-delivery-mode.component.spec.ts @@ -11,6 +11,7 @@ import { } from '@spartacus/cart/base/root'; import { CheckoutDeliveryModesFacade } from '@spartacus/checkout/base/root'; import { + FeaturesConfigModule, GlobalMessageService, GlobalMessageType, I18nTestingModule, @@ -118,7 +119,12 @@ describe('CheckoutDeliveryModeComponent', () => { beforeEach( waitForAsync(() => { TestBed.configureTestingModule({ - imports: [ReactiveFormsModule, I18nTestingModule, OutletModule], + imports: [ + ReactiveFormsModule, + I18nTestingModule, + OutletModule, + FeaturesConfigModule, + ], declarations: [CheckoutDeliveryModeComponent, MockSpinnerComponent], providers: [ { diff --git a/feature-libs/checkout/base/components/checkout-delivery-mode/checkout-delivery-mode.module.ts b/feature-libs/checkout/base/components/checkout-delivery-mode/checkout-delivery-mode.module.ts index 994f76717ed..7286faa09a5 100644 --- a/feature-libs/checkout/base/components/checkout-delivery-mode/checkout-delivery-mode.module.ts +++ b/feature-libs/checkout/base/components/checkout-delivery-mode/checkout-delivery-mode.module.ts @@ -31,7 +31,6 @@ import { CheckoutDeliveryModeComponent } from './checkout-delivery-mode.componen OutletModule, PageComponentModule, FeaturesConfigModule, - FeaturesConfigModule, ], providers: [ provideDefaultConfig({ diff --git a/feature-libs/checkout/base/components/checkout-payment-method/checkout-payment-form/checkout-payment-form.component.spec.ts b/feature-libs/checkout/base/components/checkout-payment-method/checkout-payment-form/checkout-payment-form.component.spec.ts index ee948cff11c..2e5cb096013 100644 --- a/feature-libs/checkout/base/components/checkout-payment-method/checkout-payment-form/checkout-payment-form.component.spec.ts +++ b/feature-libs/checkout/base/components/checkout-payment-method/checkout-payment-form/checkout-payment-form.component.spec.ts @@ -21,6 +21,7 @@ import { FormErrorsModule, ICON_TYPE, LaunchDialogService, + NgSelectA11yModule, } from '@spartacus/storefront'; import { EMPTY, Observable, of } from 'rxjs'; import { CheckoutPaymentFormComponent } from './checkout-payment-form.component'; @@ -180,6 +181,7 @@ describe('CheckoutPaymentFormComponent', () => { imports: [ ReactiveFormsModule, NgSelectModule, + NgSelectA11yModule, I18nTestingModule, FormErrorsModule, ], diff --git a/feature-libs/checkout/base/components/checkout-payment-method/checkout-payment-method.component.spec.ts b/feature-libs/checkout/base/components/checkout-payment-method/checkout-payment-method.component.spec.ts index 4c7007da1b4..f65db3396c1 100644 --- a/feature-libs/checkout/base/components/checkout-payment-method/checkout-payment-method.component.spec.ts +++ b/feature-libs/checkout/base/components/checkout-payment-method/checkout-payment-method.component.spec.ts @@ -150,6 +150,10 @@ class MockPaymentFormComponent { paymentMethodsCount: number; @Input() setAsDefaultField: boolean; + @Input() + loading: boolean; + @Input() + paymentDetails?: PaymentDetails; } @Component({ diff --git a/feature-libs/checkout/base/components/checkout-place-order/checkout-place-order.component.spec.ts b/feature-libs/checkout/base/components/checkout-place-order/checkout-place-order.component.spec.ts index dd84cb3e865..7d07f2b0c45 100644 --- a/feature-libs/checkout/base/components/checkout-place-order/checkout-place-order.component.spec.ts +++ b/feature-libs/checkout/base/components/checkout-place-order/checkout-place-order.component.spec.ts @@ -1,10 +1,18 @@ import { Pipe, PipeTransform } from '@angular/core'; import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; -import { UntypedFormGroup, ReactiveFormsModule } from '@angular/forms'; +import { ReactiveFormsModule, UntypedFormGroup } from '@angular/forms'; import { RouterTestingModule } from '@angular/router/testing'; -import { I18nTestingModule, RoutingService } from '@spartacus/core'; +import { + GlobalMessageService, + I18nTestingModule, + RoutingService, +} from '@spartacus/core'; import { OrderFacade } from '@spartacus/order/root'; -import { LaunchDialogService, LAUNCH_CALLER } from '@spartacus/storefront'; +import { + AtMessageModule, + LaunchDialogService, + LAUNCH_CALLER, +} from '@spartacus/storefront'; import { of } from 'rxjs'; import { CheckoutPlaceOrderComponent } from './checkout-place-order.component'; import createSpy = jasmine.createSpy; @@ -42,12 +50,18 @@ describe('CheckoutPlaceOrderComponent', () => { beforeEach( waitForAsync(() => { TestBed.configureTestingModule({ - imports: [ReactiveFormsModule, RouterTestingModule, I18nTestingModule], + imports: [ + ReactiveFormsModule, + RouterTestingModule, + I18nTestingModule, + AtMessageModule, + ], declarations: [MockUrlPipe, CheckoutPlaceOrderComponent], providers: [ { provide: OrderFacade, useClass: MockOrderFacade }, { provide: RoutingService, useClass: MockRoutingService }, { provide: LaunchDialogService, useClass: MockLaunchDialogService }, + { provide: GlobalMessageService, useValue: {} }, ], }).compileComponents(); }) diff --git a/feature-libs/checkout/base/components/checkout-review-submit/checkout-review-submit.component.spec.ts b/feature-libs/checkout/base/components/checkout-review-submit/checkout-review-submit.component.spec.ts index f9a1cd90b95..e9de27f3f0e 100644 --- a/feature-libs/checkout/base/components/checkout-review-submit/checkout-review-submit.component.spec.ts +++ b/feature-libs/checkout/base/components/checkout-review-submit/checkout-review-submit.component.spec.ts @@ -17,7 +17,7 @@ import { CheckoutStepType, } from '@spartacus/checkout/base/root'; import { Address, Country, I18nTestingModule } from '@spartacus/core'; -import { Card, PromotionsModule } from '@spartacus/storefront'; +import { Card, OutletModule, PromotionsModule } from '@spartacus/storefront'; import { IconTestingModule } from 'projects/storefrontlib/cms-components/misc/icon/testing/icon-testing.module'; import { of } from 'rxjs'; import { CheckoutStepService } from '../services/checkout-step.service'; @@ -149,6 +149,7 @@ describe('CheckoutReviewSubmitComponent', () => { PromotionsModule, RouterTestingModule, IconTestingModule, + OutletModule, ], declarations: [ CheckoutReviewSubmitComponent, diff --git a/feature-libs/checkout/base/components/checkout-review-submit/checkout-review-submit.module.ts b/feature-libs/checkout/base/components/checkout-review-submit/checkout-review-submit.module.ts index 2414205b933..334e59b90f7 100644 --- a/feature-libs/checkout/base/components/checkout-review-submit/checkout-review-submit.module.ts +++ b/feature-libs/checkout/base/components/checkout-review-submit/checkout-review-submit.module.ts @@ -9,6 +9,7 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; import { CmsConfig, + FeaturesConfigModule, I18nModule, provideDefaultConfig, UrlModule, @@ -33,6 +34,7 @@ import { CheckoutReviewSubmitComponent } from './checkout-review-submit.componen PromotionsModule, IconModule, OutletModule, + FeaturesConfigModule, ], providers: [ provideDefaultConfig({ diff --git a/feature-libs/checkout/base/components/checkout-review/checkout-review-shipping/checkout-review-shipping.component.spec.ts b/feature-libs/checkout/base/components/checkout-review/checkout-review-shipping/checkout-review-shipping.component.spec.ts index 6319b1d3c5e..2fdb5b847c8 100644 --- a/feature-libs/checkout/base/components/checkout-review/checkout-review-shipping/checkout-review-shipping.component.spec.ts +++ b/feature-libs/checkout/base/components/checkout-review/checkout-review-shipping/checkout-review-shipping.component.spec.ts @@ -11,12 +11,19 @@ import { IconTestingModule } from 'projects/storefrontlib/cms-components/misc/ic import { of } from 'rxjs'; import createSpy = jasmine.createSpy; -import { ChangeDetectorRef, Pipe, PipeTransform } from '@angular/core'; +import { + ChangeDetectorRef, + Component, + Input, + Pipe, + PipeTransform, +} from '@angular/core'; import { ActiveCartFacade, DeliveryMode, OrderEntry, } from '@spartacus/cart/base/root'; +import { Card, OutletModule } from '@spartacus/storefront'; import { CheckoutStepService } from '../../services/checkout-step.service'; import { CheckoutReviewShippingComponent } from './checkout-review-shipping.component'; @@ -107,14 +114,38 @@ class MockUrlPipe implements PipeTransform { transform(): any {} } +@Component({ + selector: 'cx-card', + template: '', +}) +class MockCardComponent { + @Input() + border: boolean; + @Input() + content: Card; + @Input() + fitToContainer: boolean; + @Input() + index: number; +} + describe('CheckoutReviewShippingComponent', () => { let component: CheckoutReviewShippingComponent; let fixture: ComponentFixture; beforeEach(async () => { await TestBed.configureTestingModule({ - imports: [I18nTestingModule, RouterTestingModule, IconTestingModule], - declarations: [CheckoutReviewShippingComponent, MockUrlPipe], + imports: [ + I18nTestingModule, + RouterTestingModule, + IconTestingModule, + OutletModule, + ], + declarations: [ + CheckoutReviewShippingComponent, + MockUrlPipe, + MockCardComponent, + ], providers: [ { provide: CheckoutDeliveryAddressFacade, diff --git a/feature-libs/checkout/scheduled-replenishment/components/checkout-place-order/checkout-place-order.component.spec.ts b/feature-libs/checkout/scheduled-replenishment/components/checkout-place-order/checkout-place-order.component.spec.ts index ad8433fdf99..83b5aa7873b 100644 --- a/feature-libs/checkout/scheduled-replenishment/components/checkout-place-order/checkout-place-order.component.spec.ts +++ b/feature-libs/checkout/scheduled-replenishment/components/checkout-place-order/checkout-place-order.component.spec.ts @@ -2,7 +2,11 @@ import { Pipe, PipeTransform } from '@angular/core'; import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; import { ReactiveFormsModule, UntypedFormGroup } from '@angular/forms'; import { RouterTestingModule } from '@angular/router/testing'; -import { I18nTestingModule, RoutingService } from '@spartacus/core'; +import { + GlobalMessageService, + I18nTestingModule, + RoutingService, +} from '@spartacus/core'; import { DaysOfWeek, OrderFacade, @@ -11,7 +15,11 @@ import { ScheduledReplenishmentOrderFacade, ScheduleReplenishmentForm, } from '@spartacus/order/root'; -import { LaunchDialogService, LAUNCH_CALLER } from '@spartacus/storefront'; +import { + AtMessageModule, + LaunchDialogService, + LAUNCH_CALLER, +} from '@spartacus/storefront'; import { BehaviorSubject, EMPTY, of } from 'rxjs'; import { CheckoutReplenishmentFormService } from '../services/checkout-replenishment-form.service'; import { CheckoutScheduledReplenishmentPlaceOrderComponent } from './checkout-place-order.component'; @@ -85,7 +93,12 @@ describe('CheckoutScheduledReplenishmentPlaceOrderComponent', () => { beforeEach( waitForAsync(() => { TestBed.configureTestingModule({ - imports: [ReactiveFormsModule, RouterTestingModule, I18nTestingModule], + imports: [ + ReactiveFormsModule, + RouterTestingModule, + I18nTestingModule, + AtMessageModule, + ], declarations: [ MockUrlPipe, CheckoutScheduledReplenishmentPlaceOrderComponent, @@ -102,6 +115,10 @@ describe('CheckoutScheduledReplenishmentPlaceOrderComponent', () => { provide: ScheduledReplenishmentOrderFacade, useClass: MockScheduledReplenishmentOrderFacade, }, + { + provide: GlobalMessageService, + useValue: {}, + }, ], }).compileComponents(); })