Skip to content

Commit ae0c0ec

Browse files
committed
Merge remote-tracking branch 'origin/2.4.9-alpha3-develop' into AC-15627
2 parents 078cad0 + b3774fb commit ae0c0ec

File tree

4 files changed

+58
-26
lines changed

4 files changed

+58
-26
lines changed

app/code/Magento/Wishlist/view/frontend/web/js/view/wishlist-mixin.js

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,52 @@ define(['jquery', 'Magento_Customer/js/customer-data'], function ($, customerDat
1111
initialize: function () {
1212
this._super();
1313

14+
let updateTimer = null;
15+
1416
const selector = '.wishlist .counter.qty, .customer-menu .wishlist .counter, .link.wishlist .counter',
15-
wishlist = customerData.get('wishlist');
17+
wishlist = customerData.get('wishlist'),
18+
clearPeriodicCounterUpdate = function () {
19+
if (updateTimer) {
20+
clearInterval(updateTimer);
21+
updateTimer = null;
22+
}
23+
},
24+
updateCounters = function (updatedWishlist) {
25+
const counters = $(selector);
1626

17-
wishlist.subscribe(function (updatedWishlist) {
18-
const counters = $(selector);
27+
if (typeof updatedWishlist.counter !== 'undefined'
28+
&& updatedWishlist.counter !== null
29+
&& counters.length
30+
) {
31+
const expectedText = updatedWishlist.counter.toString(),
32+
currentText = counters.first().text().trim();
1933

20-
if (typeof updatedWishlist.counter !== 'undefined'
21-
&& updatedWishlist.counter !== null
22-
&& counters.length
23-
) {
24-
counters.text(updatedWishlist.counter);
25-
}
26-
if (updatedWishlist.counter === null) {
27-
counters.hide();
34+
// Check if text is already correct
35+
if (currentText === expectedText) {
36+
clearPeriodicCounterUpdate();
37+
return;
38+
}
39+
40+
counters.text(updatedWishlist.counter);
41+
counters.show();
42+
}
43+
if (updatedWishlist.counter === null) {
44+
clearPeriodicCounterUpdate();
45+
counters.hide();
46+
}
47+
};
48+
49+
// Subscribe to future wishlist changes
50+
wishlist.subscribe(updateCounters);
51+
52+
// Simple timer to periodically update counters
53+
updateTimer = setInterval(function () {
54+
const wishlistData = wishlist();
55+
56+
if (wishlistData && typeof wishlistData.counter !== 'undefined') {
57+
updateCounters(wishlistData);
2858
}
29-
});
59+
}, 1000);
3060

3161
return this;
3262
}

dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryInterfaceTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,7 +1092,7 @@ public function testGetListWithFilteringByWebsite()
10921092

10931093
/**
10941094
* @magentoApiDataFixture Magento/Catalog/_files/products_with_websites_and_stores.php
1095-
* @dataProvider testGetListWithFilteringByStoreDataProvider
1095+
* @dataProvider getListWithFilteringByStoreDataProvider
10961096
*
10971097
* @param array $searchCriteria
10981098
* @param array $skus
@@ -1137,7 +1137,7 @@ public function testGetListWithFilteringByStore(array $searchCriteria, array $sk
11371137
*
11381138
* @return array
11391139
*/
1140-
public static function testGetListWithFilteringByStoreDataProvider()
1140+
public static function getListWithFilteringByStoreDataProvider()
11411141
{
11421142
return [
11431143
[

dev/tests/api-functional/testsuite/Magento/Customer/Api/GroupRepositoryTest.php

Lines changed: 9 additions & 9 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 2016 Adobe
4+
* All Rights Reserved.
55
*/
66

77
namespace Magento\Customer\Api;
@@ -171,7 +171,7 @@ public function testCreateGroupRest()
171171
/**
172172
* Verify that creating a new group with excluded website as extension attributes works via REST.
173173
*
174-
* @dataProvider testExcludedWebsitesRestDataProvider
174+
* @dataProvider excludedWebsitesRestDataProvider
175175
* @param string $code
176176
* @param null|array $excludeWebsitesIds
177177
* @param null|array $result
@@ -223,7 +223,7 @@ public function testCreateGroupWithExcludedWebsiteRest(
223223
*
224224
* @return array
225225
*/
226-
public static function testExcludedWebsitesRestDataProvider(): array
226+
public static function excludedWebsitesRestDataProvider(): array
227227
{
228228
return [
229229
['Create Group No Excludes REST', [], null],
@@ -612,7 +612,7 @@ public function testCreateGroupSoap()
612612
/**
613613
* Verify that creating a new group with excluded website as extension attributes works via SOAP.
614614
*
615-
* @dataProvider testExcludedWebsitesSoapDataProvider
615+
* @dataProvider excludedWebsitesSoapDataProvider
616616
* @param string $code
617617
* @param array $excludeWebsitesIds
618618
* @param array|null $result
@@ -665,7 +665,7 @@ public function testCreateGroupWithExcludedWebsiteSoap(
665665
*
666666
* @return array
667667
*/
668-
public static function testExcludedWebsitesSoapDataProvider(): array
668+
public static function excludedWebsitesSoapDataProvider(): array
669669
{
670670
return [
671671
['Create Group No Excludes SOAP', [], null],
@@ -1092,7 +1092,7 @@ private function createGroup($group)
10921092
/**
10931093
* Data provider for testSearchGroups
10941094
*/
1095-
public static function testSearchGroupsDataProvider()
1095+
public static function searchGroupsDataProvider()
10961096
{
10971097
return [
10981098
['tax_class_id', 3, []],
@@ -1148,7 +1148,7 @@ public static function testSearchGroupsDataProvider()
11481148
* @param string $filterValue Value of the field to be filtered by
11491149
* @param array $expectedResult Expected search result
11501150
*
1151-
* @dataProvider testSearchGroupsDataProvider
1151+
* @dataProvider searchGroupsDataProvider
11521152
*/
11531153
public function testSearchGroups($filterField, $filterValue, $expectedResult)
11541154
{
@@ -1248,7 +1248,7 @@ public function testSearchGroupsWithMultipleFilterGroupsAndSorting()
12481248
* @param string $filterValue Value of the field to be filtered by
12491249
* @param array $expectedResult Expected search result
12501250
*
1251-
* @dataProvider testSearchGroupsDataProvider
1251+
* @dataProvider searchGroupsDataProvider
12521252
*/
12531253
public function testSearchGroupsWithGET($filterField, $filterValue, $expectedResult)
12541254
{

dev/tests/js/jasmine/tests/app/code/Magento/Wishlist/view/frontend/web/js/view/wishlist-mixin.test.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ define([
2525
subscribeCallback = callback;
2626
}
2727

28-
wishlistDataMock = {
29-
subscribe: jasmine.createSpy('subscribe').and.callFake(setupSubscribeCallback)
30-
};
28+
// Create wishlistDataMock as a function (KnockoutJS observable) with subscribe method
29+
wishlistDataMock = jasmine.createSpy('wishlistObservable').and.returnValue({
30+
counter: null // Default return value
31+
});
32+
wishlistDataMock.subscribe = jasmine.createSpy('subscribe').and.callFake(setupSubscribeCallback);
3133

3234
customerDataMock.get.and.returnValue(wishlistDataMock);
3335

0 commit comments

Comments
 (0)