Skip to content

Commit

Permalink
Merge f626f14 into afd0be4
Browse files Browse the repository at this point in the history
  • Loading branch information
anjana-bl authored Sep 10, 2024
2 parents afd0be4 + f626f14 commit 18b2280
Show file tree
Hide file tree
Showing 37 changed files with 1,093 additions and 104 deletions.
2 changes: 1 addition & 1 deletion .env-cmdrc
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"CX_OPPS": "true"
},
"s4-service":{
"CX_BASE_URL": "https://api.cg79x9wuu9-eccommerc1-s1-public.model-t.myhybris.cloud",
"CX_BASE_URL": "https://api.cg79x9wuu9-eccommerc1-s8-public.model-t.myhybris.cloud",
"CX_S4_SERVICE": "true",
"CX_B2B": "true"
}
Expand Down
1 change: 1 addition & 0 deletions feature-libs/order/components/order-details/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ export * from './order-details.module';
export * from './order-details.service';
export * from './my-account-v2-order-consignments.service';
export * from './order-overview/order-overview.component';
export * from './order-overview/order-overview-component.service';
export * from './my-account-v2/index';
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import { ReorderDialogComponent } from './order-detail-reorder/reorder-dialog/re
import { OrderDetailTotalsComponent } from './order-detail-totals/order-detail-totals.component';
import { OrderOverviewComponent } from './order-overview/order-overview.component';
import { defaultReorderLayoutConfig } from './reoder-layout.config';
import { OrderOverviewComponentService } from './order-overview/order-overview-component.service';

function registerOrderOutletFactory(): () => void {
const isMyAccountV2 = inject(USE_MY_ACCOUNT_V2_ORDER);
Expand Down Expand Up @@ -111,6 +112,7 @@ const moduleComponents = [
AbstractOrderContextModule,
],
providers: [
OrderOverviewComponentService,
provideDefaultConfig(<CmsConfig | FeaturesConfig>{
cmsComponents: {
AccountOrderDetailsActionsComponent: {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { TestBed } from '@angular/core/testing';
import { OrderOverviewComponentService } from './order-overview-component.service';
import { Order } from '@spartacus/order/root';

describe('OrderOverviewComponentService', () => {
let service: OrderOverviewComponentService;

beforeEach(() => {
TestBed.configureTestingModule({
providers: [OrderOverviewComponentService],
});
service = TestBed.inject(OrderOverviewComponentService);
});

it('should be created', () => {
expect(service).toBeTruthy();
});
it('should return true if delivery mode is defined', () => {
const order: Order = {
deliveryMode: { code: 'd1' },
};
expect(service.shouldShowDeliveryMode(order?.deliveryMode)).toEqual(true);
});
it('should return false if delivery mode is not defined', () => {
const order: Order = {};
expect(service.shouldShowDeliveryMode(order?.deliveryMode)).toEqual(false);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* SPDX-FileCopyrightText: 2024 SAP Spartacus team <[email protected]>
*
* SPDX-License-Identifier: Apache-2.0
*/

import { Injectable } from '@angular/core';
import { DeliveryMode } from '@spartacus/cart/base/root';

@Injectable()
export class OrderOverviewComponentService {
shouldShowDeliveryMode(mode: DeliveryMode | undefined): boolean {
return mode !== undefined;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
></cx-card>
</ng-container>

<ng-container *ngIf="order.deliveryMode">
<ng-container *ngIf="shouldShowDeliveryMode(order.deliveryMode)">
<cx-card
[content]="getDeliveryModeCardContent(order?.deliveryMode) | async"
></cx-card>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { Card, CmsComponentData } from '@spartacus/storefront';
import { EMPTY, Observable, of } from 'rxjs';
import { OrderDetailsService } from '../order-details.service';
import { OrderOverviewComponent } from './order-overview.component';
import { OrderOverviewComponentService } from './order-overview-component.service';

@Component({ selector: 'cx-card', template: '' })
class MockCardComponent {
Expand Down Expand Up @@ -125,6 +126,11 @@ class MockOrderDetailsService {
return of(mockOrder);
}
}
class MockOrderOverviewComponentService {
shouldShowDeliveryMode(_mode: DeliveryMode): boolean {
return true;
}
}

const mockData: CmsOrderDetailOverviewComponent = {
simple: false,
Expand All @@ -139,13 +145,18 @@ describe('OrderOverviewComponent', () => {
let fixture: ComponentFixture<OrderOverviewComponent>;
let translationService: TranslationService;
let orderDetailsService: OrderDetailsService;
let componentService: OrderOverviewComponentService;

beforeEach(() => {
TestBed.configureTestingModule({
imports: [I18nTestingModule],
declarations: [OrderOverviewComponent, MockCardComponent],
providers: [
{ provide: TranslationService, useClass: MockTranslationService },
{
provide: OrderOverviewComponentService,
useClass: MockOrderOverviewComponentService,
},
{ provide: OrderDetailsService, useClass: MockOrderDetailsService },
{ provide: CmsComponentData, useValue: MockCmsComponentData },
],
Expand All @@ -157,6 +168,7 @@ describe('OrderOverviewComponent', () => {
component = fixture.componentInstance;
translationService = TestBed.inject(TranslationService);
orderDetailsService = TestBed.inject(OrderDetailsService);
componentService = TestBed.inject(OrderOverviewComponentService);
});

it('should create', () => {
Expand Down Expand Up @@ -517,4 +529,23 @@ describe('OrderOverviewComponent', () => {
expect(address).toEqual(mockFormattedAddress);
});
});

describe('show delivery mode in order summary', () => {
it('should show delivery mode card in order summary', () => {
spyOn(componentService, 'shouldShowDeliveryMode').and.returnValue(true);
const result = component.shouldShowDeliveryMode(mockDeliveryMode);
expect(result).toEqual(true);
expect(componentService.shouldShowDeliveryMode).toHaveBeenCalledWith(
mockDeliveryMode
);
});
it('should not show delivery mode card in order summary', () => {
spyOn(componentService, 'shouldShowDeliveryMode').and.returnValue(false);
const result = component.shouldShowDeliveryMode(undefined);
expect(result).toEqual(false);
expect(componentService.shouldShowDeliveryMode).toHaveBeenCalledWith(
undefined
);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { ChangeDetectionStrategy, Component } from '@angular/core';
import { ChangeDetectionStrategy, Component, inject } from '@angular/core';
import { CartOutlets, DeliveryMode } from '@spartacus/cart/base/root';
import {
Address,
Expand All @@ -18,13 +18,17 @@ import { Observable, combineLatest, of } from 'rxjs';
import { filter, map } from 'rxjs/operators';
import { OrderDetailsService } from '../order-details.service';
import { OrderOutlets, paymentMethodCard } from '@spartacus/order/root';
import { OrderOverviewComponentService } from './order-overview-component.service';

@Component({
selector: 'cx-order-overview',
templateUrl: './order-overview.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class OrderOverviewComponent {
protected orderOverviewComponentService = inject(
OrderOverviewComponentService
);
readonly cartOutlets = CartOutlets;
readonly orderOutlets = OrderOutlets;

Expand Down Expand Up @@ -192,6 +196,9 @@ export class OrderOverviewComponent {
);
}

shouldShowDeliveryMode(mode: DeliveryMode | undefined): boolean {
return this.orderOverviewComponentService.shouldShowDeliveryMode(mode);
}
getDeliveryModeCardContent(deliveryMode: DeliveryMode): Observable<Card> {
return this.translation.translate('orderDetails.shippingMethod').pipe(
filter(() => Boolean(deliveryMode)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
"serviceLocationHeading": "Service Location",
"datePickerLabel": "Schedule Service Date",
"timePickerLabel": "Schedule Service Time",
"unknownError": "An unknown error occurred. Please contact support."
"unknownError": "An unknown error occurred. Please contact support.",
"productDeliveryOptions": "Delivery Options for Products",
"serviceDeliveryOption": "Delivery Option for Services",
"productDeliveryMethods": "Delivery Methods for Products",
"serviceDeliveryMethod": "Delivery Method for Services"
},
"cancelService": {
"heading": "The following items will be included in the cancellation request",
Expand Down
Loading

0 comments on commit 18b2280

Please sign in to comment.