|
@@ -30,6 +30,7 @@ import { ErrorCode } from './graphql/generated-e2e-shop-types';
|
|
|
import * as CodegenShop from './graphql/generated-e2e-shop-types';
|
|
import * as CodegenShop from './graphql/generated-e2e-shop-types';
|
|
|
import {
|
|
import {
|
|
|
ATTEMPT_LOGIN,
|
|
ATTEMPT_LOGIN,
|
|
|
|
|
+ CANCEL_ORDER,
|
|
|
CREATE_SHIPPING_METHOD,
|
|
CREATE_SHIPPING_METHOD,
|
|
|
DELETE_PRODUCT,
|
|
DELETE_PRODUCT,
|
|
|
DELETE_PRODUCT_VARIANT,
|
|
DELETE_PRODUCT_VARIANT,
|
|
@@ -103,6 +104,7 @@ describe('Shop orders', () => {
|
|
|
| CodegenShop.UpdatedOrderFragment
|
|
| CodegenShop.UpdatedOrderFragment
|
|
|
| CodegenShop.TestOrderFragmentFragment
|
|
| CodegenShop.TestOrderFragmentFragment
|
|
|
| CodegenShop.TestOrderWithPaymentsFragment
|
|
| CodegenShop.TestOrderWithPaymentsFragment
|
|
|
|
|
+ | CodegenShop.CanceledOrderFragment
|
|
|
| CodegenShop.ActiveOrderCustomerFragment;
|
|
| CodegenShop.ActiveOrderCustomerFragment;
|
|
|
const orderResultGuard: ErrorResultGuard<OrderSuccessResult> = createErrorResultGuard(
|
|
const orderResultGuard: ErrorResultGuard<OrderSuccessResult> = createErrorResultGuard(
|
|
|
input => !!input.lines,
|
|
input => !!input.lines,
|
|
@@ -1865,6 +1867,7 @@ describe('Shop orders', () => {
|
|
|
}, `No ProductVariant with the id '34' could be found`),
|
|
}, `No ProductVariant with the id '34' could be found`),
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
|
|
+ let orderWithDeletedProductVariantId: string;
|
|
|
it('errors when transitioning to ArrangingPayment with deleted variant', async () => {
|
|
it('errors when transitioning to ArrangingPayment with deleted variant', async () => {
|
|
|
const orchidProductId = 'T_19';
|
|
const orchidProductId = 'T_19';
|
|
|
const orchidVariantId = 'T_33';
|
|
const orchidVariantId = 'T_33';
|
|
@@ -1879,6 +1882,7 @@ describe('Shop orders', () => {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
orderResultGuard.assertSuccess(addItemToOrder);
|
|
orderResultGuard.assertSuccess(addItemToOrder);
|
|
|
|
|
+ orderWithDeletedProductVariantId = addItemToOrder.id;
|
|
|
|
|
|
|
|
await adminClient.query<Codegen.DeleteProductMutation, Codegen.DeleteProductMutationVariables>(
|
|
await adminClient.query<Codegen.DeleteProductMutation, Codegen.DeleteProductMutationVariables>(
|
|
|
DELETE_PRODUCT,
|
|
DELETE_PRODUCT,
|
|
@@ -1900,6 +1904,22 @@ describe('Shop orders', () => {
|
|
|
);
|
|
);
|
|
|
expect(transitionOrderToState!.errorCode).toBe(ErrorCode.ORDER_STATE_TRANSITION_ERROR);
|
|
expect(transitionOrderToState!.errorCode).toBe(ErrorCode.ORDER_STATE_TRANSITION_ERROR);
|
|
|
});
|
|
});
|
|
|
|
|
+
|
|
|
|
|
+ // https://github.com/vendure-ecommerce/vendure/issues/1567
|
|
|
|
|
+ it('allows transitioning to Cancelled with deleted variant', async () => {
|
|
|
|
|
+ const { cancelOrder } = await adminClient.query<
|
|
|
|
|
+ CodegenShop.CancelOrderMutation,
|
|
|
|
|
+ CodegenShop.CancelOrderMutationVariables
|
|
|
|
|
+ >(CANCEL_ORDER, {
|
|
|
|
|
+ input: {
|
|
|
|
|
+ orderId: orderWithDeletedProductVariantId,
|
|
|
|
|
+ },
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ orderResultGuard.assertSuccess(cancelOrder);
|
|
|
|
|
+
|
|
|
|
|
+ expect(cancelOrder.state).toBe('Cancelled');
|
|
|
|
|
+ });
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
// https://github.com/vendure-ecommerce/vendure/issues/1195
|
|
// https://github.com/vendure-ecommerce/vendure/issues/1195
|