|
|
@@ -2342,6 +2342,61 @@ describe('Orders resolver', () => {
|
|
|
.price,
|
|
|
).toBe(108720);
|
|
|
});
|
|
|
+
|
|
|
+ // https://github.com/vendure-ecommerce/vendure/issues/1558
|
|
|
+ it('cancelling OrderItem avoids items that have been fulfilled', async () => {
|
|
|
+ await shopClient.asUserWithCredentials(customers[0].emailAddress, password);
|
|
|
+ const { addItemToOrder } = await shopClient.query<
|
|
|
+ AddItemToOrder.Mutation,
|
|
|
+ AddItemToOrder.Variables
|
|
|
+ >(ADD_ITEM_TO_ORDER, {
|
|
|
+ productVariantId: 'T_1',
|
|
|
+ quantity: 2,
|
|
|
+ });
|
|
|
+
|
|
|
+ await proceedToArrangingPayment(shopClient);
|
|
|
+ const order = await addPaymentToOrder(shopClient, singleStageRefundablePaymentMethod);
|
|
|
+ orderGuard.assertSuccess(order);
|
|
|
+
|
|
|
+ await adminClient.query<CreateFulfillment.Mutation, CreateFulfillment.Variables>(
|
|
|
+ CREATE_FULFILLMENT,
|
|
|
+ {
|
|
|
+ input: {
|
|
|
+ lines: [
|
|
|
+ {
|
|
|
+ orderLineId: order.lines[0].id,
|
|
|
+ quantity: 1,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ handler: {
|
|
|
+ code: manualFulfillmentHandler.code,
|
|
|
+ arguments: [{ name: 'method', value: 'Test' }],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ );
|
|
|
+
|
|
|
+ const { cancelOrder } = await adminClient.query<CancelOrder.Mutation, CancelOrder.Variables>(
|
|
|
+ CANCEL_ORDER,
|
|
|
+ {
|
|
|
+ input: {
|
|
|
+ orderId: order.id,
|
|
|
+ lines: [{ orderLineId: order.lines[0].id, quantity: 1 }],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ );
|
|
|
+ orderGuard.assertSuccess(cancelOrder);
|
|
|
+
|
|
|
+ const { order: order2 } = await adminClient.query<GetOrder.Query, GetOrder.Variables>(GET_ORDER, {
|
|
|
+ id: order.id,
|
|
|
+ });
|
|
|
+
|
|
|
+ const items = order2!.lines[0].items;
|
|
|
+ const itemWhichIsCancelledAndFulfilled = items.find(
|
|
|
+ i => i.cancelled === true && i.fulfillment != null,
|
|
|
+ );
|
|
|
+ expect(itemWhichIsCancelledAndFulfilled).toBeUndefined();
|
|
|
+ });
|
|
|
});
|
|
|
});
|
|
|
|