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-8061: S/4HANA Service Order UI - Alter Delivery Mode Tab in Checkout #19176

Merged
merged 19 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.showDeliveryMode(order?.deliveryMode)).toEqual(true);
});
it('should return false if delivery mode is not defined', () => {
const order: Order = {};
expect(service.showDeliveryMode(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 {
showDeliveryMode(mode: DeliveryMode | undefined): boolean {
Platonn marked this conversation as resolved.
Show resolved Hide resolved
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="showDeliveryMode(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 {
showDeliveryMode(_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,21 @@ describe('OrderOverviewComponent', () => {
expect(address).toEqual(mockFormattedAddress);
});
});

describe('show delivery mode in order summary', () => {
it('should show delivery mode card in order summary', () => {
spyOn(componentService, 'showDeliveryMode').and.returnValue(true);
const result = component.showDeliveryMode(mockDeliveryMode);
expect(result).toEqual(true);
expect(componentService.showDeliveryMode).toHaveBeenCalledWith(
mockDeliveryMode
);
});
it('should not show delivery mode card in order summary', () => {
spyOn(componentService, 'showDeliveryMode').and.returnValue(false);
const result = component.showDeliveryMode(undefined);
expect(result).toEqual(false);
expect(componentService.showDeliveryMode).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 {
);
}

showDeliveryMode(mode: DeliveryMode | undefined): boolean {
return this.orderOverviewComponentService.showDeliveryMode(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