|
|
@@ -26,6 +26,8 @@ import {
|
|
|
GetProductVariantList,
|
|
|
GetProductWithVariantList,
|
|
|
GetProductWithVariants,
|
|
|
+ GetProductWithVariantsQuery,
|
|
|
+ GetProductWithVariantsQueryVariables,
|
|
|
LanguageCode,
|
|
|
ProductVariantFragment,
|
|
|
ProductVariantListOptions,
|
|
|
@@ -1304,6 +1306,33 @@ describe('Product resolver', () => {
|
|
|
expect(removeOptionGroupFromProduct.productVariantCount).toBe(2);
|
|
|
});
|
|
|
|
|
|
+ it('removeOptionGroupFromProduct succeeds if all related ProductVariants are also deleted', async () => {
|
|
|
+ const { product } = await adminClient.query<
|
|
|
+ GetProductWithVariantsQuery,
|
|
|
+ GetProductWithVariantsQueryVariables
|
|
|
+ >(GET_PRODUCT_WITH_VARIANTS, { id: 'T_2' });
|
|
|
+
|
|
|
+ // Delete all variants for that product
|
|
|
+ for (const variant of product!.variants) {
|
|
|
+ await adminClient.query<DeleteProductVariant.Mutation, DeleteProductVariant.Variables>(
|
|
|
+ DELETE_PRODUCT_VARIANT,
|
|
|
+ {
|
|
|
+ id: variant.id,
|
|
|
+ },
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ const { removeOptionGroupFromProduct } = await adminClient.query<
|
|
|
+ RemoveOptionGroupFromProduct.Mutation,
|
|
|
+ RemoveOptionGroupFromProduct.Variables
|
|
|
+ >(REMOVE_OPTION_GROUP_FROM_PRODUCT, {
|
|
|
+ optionGroupId: product!.optionGroups[0].id,
|
|
|
+ productId: product!.id,
|
|
|
+ });
|
|
|
+
|
|
|
+ removeOptionGuard.assertSuccess(removeOptionGroupFromProduct);
|
|
|
+ });
|
|
|
+
|
|
|
it(
|
|
|
'removeOptionGroupFromProduct errors with an invalid productId',
|
|
|
assertThrowsWithMessage(
|