Skip to content

Commit 665421f

Browse files
author
Prabhu Ram
committed
PWA-1379: [GraphQl] AddWishlistItemsToCartOutput.status doesn't return the correct status if items are not added to cart
- Addressed review comments
1 parent f6a7cc4 commit 665421f

File tree

2 files changed

+4
-31
lines changed

2 files changed

+4
-31
lines changed

app/code/Magento/WishlistGraphQl/etc/schema.graphqls

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ type AddWishlistItemsToCartOutput {
7474

7575
type WishlistCartUserInputError {
7676
message: String! @doc(description: "A localized error message")
77-
code: WishlistCartUserInputErrorType! @doc(description: "Wishlist-Cart-specific error code")
78-
wishlistId: ID! @doc(description: "The id of the wishlist associated with the error")
79-
wishlistItemId: ID! @doc(description: "The id of the wishlist item associated with the error")
77+
code: WishlistCartUserInputErrorType! @doc(description: "An error code that describes the error encountered")
78+
wishlistId: ID! @doc(description: "The unique ID of the `Wishlist` object containing an error")
79+
wishlistItemId: ID! @doc(description: "The unique ID of the wish list item containing an error")
8080
}
8181

8282
enum WishlistCartUserInputErrorType {

dev/tests/api-functional/testsuite/Magento/GraphQl/Wishlist/AddWishlistItemsToCartTest.php

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ public function testAddAllWishlistItemsToCart(): void
223223
$quantity2 = 2;
224224
$addProductsToWishlistQuery = $this->addSecondProductToWishlist($wishlistId, $sku2, $quantity2);
225225
$this->graphQlMutation($addProductsToWishlistQuery, [], '', $this->getHeaderMap());
226-
$addWishlistToCartQuery = $this->addWishlistItemToCartWithNoItemId($wishlistId);
226+
$addWishlistToCartQuery = $this->getAddAllItemsToCartQuery($wishlistId);
227227

228228
$response = $this->graphQlMutation($addWishlistToCartQuery, [], '', $this->getHeaderMap());
229229

@@ -234,8 +234,6 @@ public function testAddAllWishlistItemsToCart(): void
234234
$this->assertEmpty($wishlistAfterItemsAddedToCart['customer']['wishlists'][0]['items_v2']['items']);
235235
$customerCart = $this->getCustomerCart('customer@example.com');
236236
$this->assertCount(2, $customerCart['customerCart']['items']);
237-
$this->assertEquals('simple-1', $customerCart['customerCart']['items'][0]['product']['sku']);
238-
$this->assertEquals($sku2, $customerCart['customerCart']['items'][1]['product']['sku']);
239237
}
240238

241239
/**
@@ -419,31 +417,6 @@ private function addSecondProductToWishlist(
419417
MUTATION;
420418
}
421419

422-
/**
423-
* Returns GraphQl mutation string to add wishlist items to Cart
424-
*
425-
* @param string $wishlistId
426-
* @return string
427-
*/
428-
private function addWishlistItemToCartWithNoItemId(
429-
string $wishlistId
430-
): string {
431-
return <<<MUTATION
432-
mutation {
433-
addWishlistItemsToCart
434-
(
435-
wishlistId: "{$wishlistId}"
436-
) {
437-
status
438-
add_wishlist_items_to_cart_user_errors{
439-
message
440-
code
441-
}
442-
}
443-
}
444-
MUTATION;
445-
}
446-
447420
/**
448421
* Get customer cart query
449422
*

0 commit comments

Comments
 (0)