8
8
namespace Magento \GraphQl \Wishlist ;
9
9
10
10
use Exception ;
11
+ use Magento \Catalog \Test \Fixture \Product as ProductFixture ;
12
+ use Magento \Customer \Test \Fixture \Customer as CustomerFixture ;
11
13
use Magento \Framework \Exception \AuthenticationException ;
12
14
use Magento \Integration \Api \CustomerTokenServiceInterface ;
15
+ use Magento \TestFramework \Fixture \Config ;
16
+ use Magento \TestFramework \Fixture \DataFixture ;
17
+ use Magento \TestFramework \Fixture \DataFixtureStorage ;
18
+ use Magento \TestFramework \Fixture \DataFixtureStorageManager ;
13
19
use Magento \TestFramework \Helper \Bootstrap ;
14
20
use Magento \TestFramework \TestCase \GraphQlAbstract ;
21
+ use Magento \Wishlist \Test \Fixture \AddProductToWishlist as AddProductToWishlistFixture ;
15
22
16
23
/**
17
24
* Test coverage for updating a product from wishlist
@@ -23,12 +30,18 @@ class UpdateProductsFromWishlistTest extends GraphQlAbstract
23
30
*/
24
31
private $ customerTokenService ;
25
32
33
+ /**
34
+ * @var DataFixtureStorage
35
+ */
36
+ private $ fixtures ;
37
+
26
38
/**
27
39
* Set Up
28
40
*/
29
41
protected function setUp (): void
30
42
{
31
43
$ objectManager = Bootstrap::getObjectManager ();
44
+ $ this ->fixtures = $ objectManager ->get (DataFixtureStorageManager::class)->getStorage ();
32
45
$ this ->customerTokenService = $ objectManager ->get (CustomerTokenServiceInterface::class);
33
46
}
34
47
@@ -145,6 +158,48 @@ public function testUpdateProductWithValidQtyAndNoDescription()
145
158
self ::assertEquals ('simple-1 ' , $ itemsInWishlist ['product ' ]['sku ' ]);
146
159
}
147
160
161
+ #[
162
+ Config('wishlist/general/active ' , true ),
163
+ DataFixture(ProductFixture::class, as: 'product ' ),
164
+ DataFixture(CustomerFixture::class, as: 'customer ' ),
165
+ DataFixture(AddProductToWishlistFixture::class, [
166
+ 'customer_id ' => '$customer.id$ ' ,
167
+ 'product_ids ' => [
168
+ '$product.id$ '
169
+ ],
170
+ 'name ' => 'Test Wish List ' ,
171
+ ], as: 'wishlist ' )
172
+ ]
173
+ public function testClearWishlistDescription (): void
174
+ {
175
+ $ customerEmail = $ this ->fixtures ->get ('customer ' )->getEmail ();
176
+ $ wishlist = $ this ->getWishlist ($ customerEmail );
177
+
178
+ $ customerWishlist = $ wishlist ['customer ' ]['wishlists ' ][0 ];
179
+ $ wishlistId = $ customerWishlist ['id ' ];
180
+ $ wishlistItem = $ customerWishlist ['items_v2 ' ]['items ' ][0 ];
181
+ $ qty = 5 ;
182
+ $ description = 'New Description ' ;
183
+
184
+ $ updateWishlistQuery = $ this ->getQuery ($ wishlistId , $ wishlistItem ['id ' ], $ qty , $ description );
185
+ $ response = $ this ->graphQlMutation ($ updateWishlistQuery , [], '' , $ this ->getHeaderMap ($ customerEmail ));
186
+
187
+ $ this ->assertArrayHasKey ('updateProductsInWishlist ' , $ response );
188
+ $ this ->assertArrayHasKey ('wishlist ' , $ response ['updateProductsInWishlist ' ]);
189
+ $ wishlistResponse = $ response ['updateProductsInWishlist ' ]['wishlist ' ];
190
+ $ this ->assertEquals ($ qty , $ wishlistResponse ['items_v2 ' ]['items ' ][0 ]['quantity ' ]);
191
+ $ this ->assertEquals ($ description , $ wishlistResponse ['items_v2 ' ]['items ' ][0 ]['description ' ]);
192
+
193
+ $ updateWishlistQueryNoDescription = $ this ->getQuery ($ wishlistId , $ wishlistItem ['id ' ], $ qty , "" );
194
+ $ responseNoDescription = $ this ->graphQlMutation ($ updateWishlistQueryNoDescription , [], '' , $ this ->getHeaderMap ($ customerEmail ));
195
+
196
+ $ this ->assertArrayHasKey ('updateProductsInWishlist ' , $ responseNoDescription );
197
+ $ this ->assertArrayHasKey ('wishlist ' , $ responseNoDescription ['updateProductsInWishlist ' ]);
198
+ $ wishlistResponseNoDescription = $ responseNoDescription ['updateProductsInWishlist ' ]['wishlist ' ];
199
+ $ this ->assertEquals ($ qty , $ wishlistResponseNoDescription ['items_v2 ' ]['items ' ][0 ]['quantity ' ]);
200
+ $ this ->assertEquals ('' , $ wishlistResponseNoDescription ['items_v2 ' ]['items ' ][0 ]['description ' ]);
201
+ }
202
+
148
203
/**
149
204
* Authentication header map
150
205
*
0 commit comments