|
@@ -36,6 +36,7 @@ import {
|
|
|
GetOrderPromotionsByCode,
|
|
GetOrderPromotionsByCode,
|
|
|
RemoveCouponCode,
|
|
RemoveCouponCode,
|
|
|
SetCustomerForOrder,
|
|
SetCustomerForOrder,
|
|
|
|
|
+ TestOrderFragment,
|
|
|
} from './graphql/generated-e2e-shop-types';
|
|
} from './graphql/generated-e2e-shop-types';
|
|
|
import {
|
|
import {
|
|
|
CREATE_CUSTOMER_GROUP,
|
|
CREATE_CUSTOMER_GROUP,
|
|
@@ -519,8 +520,12 @@ describe('Promotions applied to Orders', () => {
|
|
|
productVariantId: getVariantBySlug('item-sale-1').id,
|
|
productVariantId: getVariantBySlug('item-sale-1').id,
|
|
|
quantity: 2,
|
|
quantity: 2,
|
|
|
});
|
|
});
|
|
|
|
|
+
|
|
|
|
|
+ function getItemSale1Line(lines: TestOrderFragment.Lines[]): TestOrderFragment.Lines {
|
|
|
|
|
+ return lines.find(l => l.productVariant.id === getVariantBySlug('item-sale-1').id)!;
|
|
|
|
|
+ }
|
|
|
expect(addItemToOrder!.adjustments.length).toBe(0);
|
|
expect(addItemToOrder!.adjustments.length).toBe(0);
|
|
|
- expect(addItemToOrder!.lines[2].adjustments.length).toBe(2); // 2x tax
|
|
|
|
|
|
|
+ expect(getItemSale1Line(addItemToOrder!.lines).adjustments.length).toBe(2); // 2x tax
|
|
|
expect(addItemToOrder!.total).toBe(2640);
|
|
expect(addItemToOrder!.total).toBe(2640);
|
|
|
|
|
|
|
|
const { applyCouponCode } = await shopClient.query<
|
|
const { applyCouponCode } = await shopClient.query<
|
|
@@ -531,7 +536,7 @@ describe('Promotions applied to Orders', () => {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
expect(applyCouponCode!.total).toBe(1920);
|
|
expect(applyCouponCode!.total).toBe(1920);
|
|
|
- expect(applyCouponCode!.lines[2].adjustments.length).toBe(4); // 2x tax, 2x promotion
|
|
|
|
|
|
|
+ expect(getItemSale1Line(applyCouponCode!.lines).adjustments.length).toBe(4); // 2x tax, 2x promotion
|
|
|
|
|
|
|
|
const { removeCouponCode } = await shopClient.query<
|
|
const { removeCouponCode } = await shopClient.query<
|
|
|
RemoveCouponCode.Mutation,
|
|
RemoveCouponCode.Mutation,
|
|
@@ -540,11 +545,11 @@ describe('Promotions applied to Orders', () => {
|
|
|
couponCode,
|
|
couponCode,
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- expect(removeCouponCode!.lines[2].adjustments.length).toBe(2); // 2x tax
|
|
|
|
|
|
|
+ expect(getItemSale1Line(removeCouponCode!.lines).adjustments.length).toBe(2); // 2x tax
|
|
|
expect(removeCouponCode!.total).toBe(2640);
|
|
expect(removeCouponCode!.total).toBe(2640);
|
|
|
|
|
|
|
|
const { activeOrder } = await shopClient.query<GetActiveOrder.Query>(GET_ACTIVE_ORDER);
|
|
const { activeOrder } = await shopClient.query<GetActiveOrder.Query>(GET_ACTIVE_ORDER);
|
|
|
- expect(activeOrder!.lines[2].adjustments.length).toBe(2); // 2x tax
|
|
|
|
|
|
|
+ expect(getItemSale1Line(activeOrder!.lines).adjustments.length).toBe(2); // 2x tax
|
|
|
expect(activeOrder!.total).toBe(2640);
|
|
expect(activeOrder!.total).toBe(2640);
|
|
|
|
|
|
|
|
await deletePromotion(promotion.id);
|
|
await deletePromotion(promotion.id);
|