Skip to content

Commit 4ac627e

Browse files
committed
MC-36897: [GraphQl] Issues with updating wishlist quantity. Adding Recommended Store config changes
- added tests to cover bugs
1 parent 482357d commit 4ac627e

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

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

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,78 @@ public function testGuestCannotGetWishlist()
124124
$this->graphQlQuery($query);
125125
}
126126

127+
/**
128+
* Add product to wishlist with quantity 0
129+
*
130+
* @magentoConfigFixture default_store wishlist/general/active 1
131+
* @magentoApiDataFixture Magento/Customer/_files/customer.php
132+
* @magentoApiDataFixture Magento/Catalog/_files/product_simple_duplicated.php
133+
*/
134+
public function testAddProductToWishlistWithZeroQty()
135+
{
136+
$customerWishlistQuery =
137+
<<<QUERY
138+
{
139+
customer {
140+
wishlist {
141+
id
142+
}
143+
}
144+
}
145+
QUERY;
146+
147+
$response = $this->graphQlQuery(
148+
$customerWishlistQuery,
149+
[],
150+
'',
151+
$this->getCustomerAuthHeaders('customer@example.com', 'password')
152+
);
153+
$qty = 0;
154+
$sku = 'simple-1';
155+
$wishlistId = $response['customer']['wishlist']['id'];
156+
$addProductToWishlistQuery =
157+
<<<QUERY
158+
mutation{
159+
addProductsToWishlist(
160+
wishlistId:{$wishlistId}
161+
wishlistItems:[
162+
{
163+
sku:"{$sku}"
164+
quantity:{$qty}
165+
}
166+
])
167+
{
168+
wishlist{
169+
id
170+
items_count
171+
items{product{name sku} description qty}
172+
}
173+
user_errors{code message}
174+
}
175+
}
176+
177+
QUERY;
178+
$addToWishlistResponse = $this->graphQlMutation(
179+
$addProductToWishlistQuery,
180+
[],
181+
'',
182+
$this->getCustomerAuthHeaders('customer@example.com', 'password')
183+
);
184+
$this->assertArrayHasKey('user_errors', $addToWishlistResponse['addProductsToWishlist']);
185+
$this->assertCount(1, $addToWishlistResponse['addProductsToWishlist']['user_errors']);
186+
$this->assertEmpty($addToWishlistResponse['addProductsToWishlist']['wishlist']['items']);
187+
$this->assertEquals(
188+
0,
189+
$addToWishlistResponse['addProductsToWishlist']['wishlist']['items_count'],
190+
'Count is greater than 0'
191+
);
192+
$message = 'The quantity of a wish list item cannot be 0';
193+
$this->assertEquals(
194+
$message,
195+
$addToWishlistResponse['addProductsToWishlist']['user_errors'][0]['message']
196+
);
197+
}
198+
127199
/**
128200
* @magentoConfigFixture default_store wishlist/general/active 0
129201
* @magentoApiDataFixture Magento/Customer/_files/customer.php

0 commit comments

Comments
 (0)