Skip to content

Commit 0c1d452

Browse files
committed
Merge remote-tracking branch 'origin/AC-14682' into spartans_pr_26082025
2 parents 0998eaf + 4c114d5 commit 0c1d452

File tree

2 files changed

+65
-7
lines changed

2 files changed

+65
-7
lines changed

app/code/Magento/WishlistGraphQl/Model/UpdateWishlistItem.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2020 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -78,9 +78,7 @@ public function execute(WishlistItemData $wishlistItemData, Wishlist $wishlist)
7878

7979
$wishlistItemToUpdate->setOptions($updatedOptions);
8080
$wishlistItemToUpdate->setQty($wishlistItemData->getQuantity());
81-
if ($wishlistItemData->getDescription()) {
82-
$wishlistItemToUpdate->setDescription($wishlistItemData->getDescription());
83-
}
81+
$wishlistItemToUpdate->setDescription($wishlistItemData->getDescription() ?: "");
8482

8583
$this->wishlistResource->save($wishlist);
8684
}

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

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2020 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

88
namespace Magento\GraphQl\Wishlist;
99

1010
use Exception;
11+
use Magento\Catalog\Test\Fixture\Product as ProductFixture;
12+
use Magento\Customer\Test\Fixture\Customer as CustomerFixture;
1113
use Magento\Framework\Exception\AuthenticationException;
1214
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;
1319
use Magento\TestFramework\Helper\Bootstrap;
1420
use Magento\TestFramework\TestCase\GraphQlAbstract;
21+
use Magento\Wishlist\Test\Fixture\AddProductToWishlist as AddProductToWishlistFixture;
1522

1623
/**
1724
* Test coverage for updating a product from wishlist
@@ -23,12 +30,18 @@ class UpdateProductsFromWishlistTest extends GraphQlAbstract
2330
*/
2431
private $customerTokenService;
2532

33+
/**
34+
* @var DataFixtureStorage
35+
*/
36+
private $fixtures;
37+
2638
/**
2739
* Set Up
2840
*/
2941
protected function setUp(): void
3042
{
3143
$objectManager = Bootstrap::getObjectManager();
44+
$this->fixtures = $objectManager->get(DataFixtureStorageManager::class)->getStorage();
3245
$this->customerTokenService = $objectManager->get(CustomerTokenServiceInterface::class);
3346
}
3447

@@ -145,6 +158,53 @@ public function testUpdateProductWithValidQtyAndNoDescription()
145158
self::assertEquals('simple-1', $itemsInWishlist['product']['sku']);
146159
}
147160

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(
195+
$updateWishlistQueryNoDescription,
196+
[],
197+
'',
198+
$this->getHeaderMap($customerEmail)
199+
);
200+
201+
$this->assertArrayHasKey('updateProductsInWishlist', $responseNoDescription);
202+
$this->assertArrayHasKey('wishlist', $responseNoDescription['updateProductsInWishlist']);
203+
$wishlistResponseNoDescription = $responseNoDescription['updateProductsInWishlist']['wishlist'];
204+
$this->assertEquals($qty, $wishlistResponseNoDescription['items_v2']['items'][0]['quantity']);
205+
$this->assertEquals('', $wishlistResponseNoDescription['items_v2']['items'][0]['description']);
206+
}
207+
148208
/**
149209
* Authentication header map
150210
*

0 commit comments

Comments
 (0)