Skip to content

Commit

Permalink
fix(CTC-135): do not create order with empty tags array
Browse files Browse the repository at this point in the history
  • Loading branch information
arnoerpenbeck committed May 3, 2024
1 parent 037c416 commit b783dd0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions event/src/order/orderMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class OrderMapper {

public async mapOrder(commercetoolsOrder: CommercetoolsOrder): Promise<FulfillmenttoolsOrder> {
const configuration = await getConfiguration();
return {
const order: FulfillmenttoolsOrder = {
tenantOrderId: commercetoolsOrder.orderNumber || commercetoolsOrder.id,
consumer: this.mapConsumer(commercetoolsOrder),
orderDate: new Date(commercetoolsOrder.createdAt),
Expand All @@ -31,8 +31,12 @@ export class OrderMapper {
paymentInfo: {
currency: commercetoolsOrder.totalPrice.currencyCode,
},
tags: this.mapTags(commercetoolsOrder, configuration),
};
const tags = this.mapTags(commercetoolsOrder, configuration);
if (tags && tags.length > 0) {
order.tags = tags;
}
return order;
}

private async getPreselectedFacilities(commercetoolsOrder: CommercetoolsOrder): Promise<PreselectedFacility[]> {
Expand Down
1 change: 1 addition & 0 deletions event/tests/orderMapper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ describe('OrderMapper', () => {
expect(article.title).toEqual('Cigköfte Wrap');
expect(article.imageUrl).toEqual('https://fancy-image.example.com');
expect(fulfillmenttoolsOrder.tenantOrderId).toEqual('orderNumber');
expect(fulfillmenttoolsOrder.tags).toBeUndefined();
});

it('defaults to id if orderNumber is undefined', async () => {
Expand Down

0 comments on commit b783dd0

Please sign in to comment.