Skip to content

Commit

Permalink
fix: use product name for basket line item name and order line item n…
Browse files Browse the repository at this point in the history
…ame for orders (#387)
  • Loading branch information
dhhyi authored Sep 28, 2020
1 parent 3ce106b commit 6c7a3d7
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/app/core/models/basket/basket.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { LineItem, LineItemView } from 'ish-core/models/line-item/line-item.mode
import { Payment } from 'ish-core/models/payment/payment.model';
import { ShippingMethod } from 'ish-core/models/shipping-method/shipping-method.model';

interface AbstractBasket<T> {
export interface AbstractBasket<T> {
id: string;
purchaseCurrency?: string;
dynamicMessages?: string[];
Expand Down
3 changes: 2 additions & 1 deletion src/app/core/models/line-item/line-item.mapper.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { BasketRebateData } from 'ish-core/models/basket-rebate/basket-rebate.interface';
import { BasketRebateMapper } from 'ish-core/models/basket-rebate/basket-rebate.mapper';
import { OrderItemData } from 'ish-core/models/order-item/order-item.interface';
import { OrderLineItem } from 'ish-core/models/order/order.model';
import { PriceItemMapper } from 'ish-core/models/price-item/price-item.mapper';
import { PriceMapper } from 'ish-core/models/price/price.mapper';

Expand Down Expand Up @@ -49,7 +50,7 @@ export class LineItemMapper {
}
}

static fromOrderItemData(data: OrderItemData, rebateData?: { [id: string]: BasketRebateData }): LineItem {
static fromOrderItemData(data: OrderItemData, rebateData?: { [id: string]: BasketRebateData }): OrderLineItem {
if (data) {
const orderItem = LineItemMapper.fromData(data, rebateData);

Expand Down
5 changes: 0 additions & 5 deletions src/app/core/models/line-item/line-item.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ export interface LineItem {
isHiddenGift: boolean;
isFreeGift: boolean;

// attributes needed for order line items
name?: string;
description?: string;
fulfillmentStatus?: string;

// attributes needed for quote feature
originSingleBasePrice?: PriceItem;

Expand Down
11 changes: 9 additions & 2 deletions src/app/core/models/order/order.model.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { Basket } from 'ish-core/models/basket/basket.model';
import { AbstractBasket } from 'ish-core/models/basket/basket.model';
import { LineItem } from 'ish-core/models/line-item/line-item.model';

export interface Order extends Basket {
export interface OrderLineItem extends LineItem {
name: string;
description: string;
fulfillmentStatus: string;
}

export interface Order extends AbstractBasket<OrderLineItem> {
documentNo: string;
creationDate: number;
orderCreation: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ describe('Basket Items Effects', () => {
lineItems: [
{
id: 'BIID',
name: 'NAME',
quantity: { value: 1 },
productSKU: 'SKU',
price: undefined,
Expand Down
1 change: 0 additions & 1 deletion src/app/core/store/customer/customer-store.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ describe('Customer Store', () => {

const lineItem = {
id: 'test',
name: 'test',
position: 1,
quantity: { type: 'test', value: 1, unit: 'pcs.' },
productSKU: 'test',
Expand Down
1 change: 0 additions & 1 deletion src/app/core/utils/dev/basket-mock-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export class BasketMockData {
static getBasketItem(): LineItemView {
return {
id: '4712',
name: 'pli name',
quantity: { value: 10 },
productSKU: '4713',
singleBasePrice: { gross: 3, net: 2, currency: 'USD', type: 'PriceItem' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<ng-container *ngIf="isItemVisible(i)">
<!-- product name and price -->
<div class="col-8" *ngIf="product$(pli.productSKU) | async as product">
<a [routerLink]="product | ishProductRoute"> {{ pli.name }} </a>
<a [routerLink]="product | ishProductRoute"> {{ product.name }} </a>
</div>
<div class="col-4 text-right">{{ pli.totals.total | ishPrice }}</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('Basket Items Summary Component', () => {

beforeEach(async () => {
const shoppingFacade = mock(ShoppingFacade);
when(shoppingFacade.product$(anything(), anything())).thenCall(sku => of({ sku }));
when(shoppingFacade.product$(anything(), anything())).thenCall(sku => of({ sku, name: 'SKU:' + sku }));

await TestBed.configureTestingModule({
declarations: [
Expand Down Expand Up @@ -54,7 +54,7 @@ describe('Basket Items Summary Component', () => {
it('should render basket product line items if basket items are there', () => {
fixture.detectChanges();
expect(element.querySelector('.cart-summary-checkout')).toBeTruthy();
expect(element.querySelector('.cart-summary-checkout').textContent).toContain('pli name');
expect(element.querySelector('.cart-summary-checkout').textContent).toContain('SKU:4713');
});

it('should not show anything if there are no basket items', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { debounceTime } from 'rxjs/operators';
import { ShoppingFacade } from 'ish-core/facades/shopping.facade';
import { LineItemUpdate } from 'ish-core/models/line-item-update/line-item-update.model';
import { LineItemView } from 'ish-core/models/line-item/line-item.model';
import { OrderLineItem } from 'ish-core/models/order/order.model';
import { Price } from 'ish-core/models/price/price.model';
import { ProductCompletenessLevel } from 'ish-core/models/product/product.model';
import { SpecialValidators } from 'ish-shared/forms/validators/special-validators';
Expand All @@ -32,7 +33,7 @@ import { SpecialValidators } from 'ish-shared/forms/validators/special-validator
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class LineItemListComponent {
@Input() lineItems: LineItemView[];
@Input() lineItems: Partial<LineItemView & OrderLineItem>[];
@Input() editable = true;
@Input() total: Price;
@Input() lineItemViewType?: 'simple' | 'availability';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</a>
</div>
<div class="mini-product-info">
<a [routerLink]="product | ishProductRoute" (click)="collapse()"> {{ lineItem.name }} </a>
<a [routerLink]="product | ishProductRoute" (click)="collapse()"> {{ product.name }} </a>
<div class="product-price">{{ lineItem.price | ishPrice }}</div>
<div class="cart-pli-data">
<span>{{ 'shopping_cart.pli.qty.label' | translate }}</span> {{ lineItem.quantity.value }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ describe('Mini Basket Component', () => {
component.open();
fixture.detectChanges();
expect(element.textContent.replace(/ /g, '')).toMatchInlineSnapshot(
`"30items/$141,796.98pliname$3.00x10pliname$3.00x10pliname$3.00x10VIEWCART"`
`"30items/$141,796.98$3.00x10$3.00x10$3.00x10VIEWCART"`
);
});

Expand Down

0 comments on commit 6c7a3d7

Please sign in to comment.