Skip to content

Commit 4ed2b79

Browse files
authored
Merge branch '2.4-develop' into Arrows_Delivery_07022024
2 parents 08fa249 + 6f4805f commit 4ed2b79

File tree

8 files changed

+122
-28
lines changed

8 files changed

+122
-28
lines changed

app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,9 @@ function (
141141
* Update address action
142142
*/
143143
updateAddress: function () {
144-
var addressData, newBillingAddress;
144+
var addressData, newBillingAddress, needsToUpdateAddress;
145145

146+
needsToUpdateAddress = true;
146147
addressUpdated = true;
147148

148149
if (this.selectedAddress() && !this.isAddressFormVisible()) {
@@ -156,7 +157,9 @@ function (
156157
this.source.trigger(this.dataScopePrefix + '.custom_attributes.data.validate');
157158
}
158159

159-
if (!this.source.get('params.invalid')) {
160+
if (this.source.get('params.invalid')) {
161+
needsToUpdateAddress = false;
162+
} else {
160163
addressData = this.source.get(this.dataScopePrefix);
161164

162165
if (customer.isLoggedIn() && !this.customerHasAddresses) { //eslint-disable-line max-depth
@@ -168,9 +171,9 @@ function (
168171
selectBillingAddress(newBillingAddress);
169172
checkoutData.setSelectedBillingAddress(newBillingAddress.getKey());
170173
checkoutData.setNewCustomerBillingAddress(addressData);
171-
this.updateAddresses(true);
172174
}
173175
}
176+
this.updateAddresses(needsToUpdateAddress);
174177
},
175178

176179
/**

app/code/Magento/QuoteGraphQl/Model/Resolver/MaskedCartId.php

+1-5
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,7 @@ private function getQuoteMaskId(int $quoteId): string
9595
*/
9696
private function ensureQuoteMaskExist(int $quoteId): string
9797
{
98-
try {
99-
$maskedId = $this->quoteIdToMaskedQuoteId->execute($quoteId);
100-
} catch (NoSuchEntityException $e) {
101-
$maskedId = '';
102-
}
98+
$maskedId = $this->quoteIdToMaskedQuoteId->execute($quoteId);
10399
if ($maskedId === '') {
104100
$quoteIdMask = $this->quoteIdMaskFactory->create();
105101
$quoteIdMask->setQuoteId($quoteId);

app/code/Magento/QuoteGraphQl/Test/Unit/Model/Resolver/MaskedCartIdTest.php

+29-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace Magento\QuoteGraphQl\Test\Unit\Model\Resolver;
99

1010
use Magento\Framework\Exception\LocalizedException;
11+
use Magento\Framework\Exception\NoSuchEntityException;
1112
use Magento\Framework\GraphQl\Config\Element\Field;
1213
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
1314
use Magento\GraphQl\Model\Query\Context;
@@ -16,7 +17,6 @@
1617
use Magento\Quote\Model\QuoteIdMaskFactory;
1718
use Magento\Quote\Model\QuoteIdToMaskedQuoteIdInterface;
1819
use Magento\Quote\Model\ResourceModel\Quote\QuoteIdMask as QuoteIdMaskResourceModel;
19-
use Magento\QuoteGraphQl\Model\Resolver\Cart;
2020
use Magento\QuoteGraphQl\Model\Resolver\MaskedCartId;
2121
use PHPUnit\Framework\MockObject\MockObject;
2222
use PHPUnit\Framework\TestCase;
@@ -134,4 +134,32 @@ public function testResolve(): void
134134
->with($this->quoteIdMask);
135135
$this->maskedCartId->resolve($this->fieldMock, $this->contextMock, $this->resolveInfoMock, $this->valueMock);
136136
}
137+
138+
/**
139+
* @return void
140+
* @throws \Exception
141+
*/
142+
public function testResolveForExceptionWhenQuoteNotExists(): void
143+
{
144+
$this->expectExceptionMessage('Current user does not have an active cart.');
145+
$this->valueMock = ['model' => $this->quoteMock];
146+
$cartId = 0;
147+
$this->quoteIdToMaskedQuoteId->method('execute')->with($cartId)->willThrowException(
148+
new NoSuchEntityException(
149+
__(
150+
'No such entity with %fieldName = %fieldValue',
151+
[
152+
'fieldName' => 'quoteId',
153+
'fieldValue' => $cartId
154+
]
155+
)
156+
)
157+
);
158+
$this->maskedCartId->resolve(
159+
$this->fieldMock,
160+
$this->contextMock,
161+
$this->resolveInfoMock,
162+
$this->valueMock
163+
);
164+
}
137165
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Copyright 2024 Adobe
4+
All Rights Reserved.
5+
NOTICE: All information contained herein is, and remains
6+
the property of Adobe and its suppliers, if any. The intellectual
7+
and technical concepts contained herein are proprietary to Adobe
8+
and its suppliers and are protected by all applicable
9+
intellectual property laws, including trade secret and copyright
10+
laws. Dissemination of this information or reproduction of this
11+
material is strictly forbidden unless prior written permission is
12+
obtained from Adobe.
13+
-->
14+
15+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
16+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
17+
<test name="AdminReportsOrderProductsDatePickerTest">
18+
<annotations>
19+
<features value="Reports"/>
20+
<stories value="Calendar Date Button"/>
21+
<title value="Admin Ordered Products Report date range visibility issue."/>
22+
<description value="Admin Ordered Products Report date range visibility issue."/>
23+
<severity value="AVERAGE"/>
24+
<testCaseId value="AC-12188"/>
25+
</annotations>
26+
<before>
27+
<actionGroup ref="AdminLoginActionGroup" stepKey="LoginAsAdmin"/>
28+
</before>
29+
<after>
30+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
31+
</after>
32+
<actionGroup ref="AdminNavigateMenuActionGroup" stepKey="navigateToReportsOrderedPage">
33+
<argument name="menuUiId" value="{{AdminMenuReports.dataUiId}}"/>
34+
<argument name="submenuUiId" value="{{AdminMenuReportsProductsOrdered.dataUiId}}"/>
35+
</actionGroup>
36+
<actionGroup ref="AdminAssertPageTitleActionGroup" stepKey="seePageTitle">
37+
<argument name="title" value="{{AdminMenuReportsProductsOrdered.pageTitle}}"/>
38+
</actionGroup>
39+
<click selector="{{OrderedProductsSection.refresh}}" stepKey="refresh"/>
40+
<waitForPageLoad time="5" stepKey="waitForOrderList"/>
41+
<click selector="{{OrderReportMainSection.fromDatePicker}}" stepKey="clickFromDatePicker"/>
42+
<waitForElementVisible selector="{{OrderReportMainSection.datePickerCalendar}}" stepKey="seePopupDatePicker"/>
43+
<click selector="{{OrderReportMainSection.selectTodayButton}}" stepKey="clickOnTodayButton"/>
44+
<click selector="{{OrderReportMainSection.selectCloseButton}}" stepKey="clickOnCloseButton"/>
45+
46+
<!-- Verify data -->
47+
<grabValueFrom selector="{{SoldReportFilterSection.dateTo}}" stepKey="fillToDate"/>
48+
<assertNotEmpty stepKey="assertToDateNotEmpty">
49+
<actualResult type="variable">$fillToDate</actualResult>
50+
</assertNotEmpty>
51+
</test>
52+
</tests>

dev/tests/integration/testsuite/Magento/Framework/Image/Adapter/InterfaceTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ public function resizeDataProvider()
296296
[$this->_getFixture('image_adapters_test.png'), [100, null]],
297297
[$this->_getFixture('image_adapters_test.png'), [null, null]],
298298
[$this->_getFixture('image_adapters_test.png'), [-100, -50]],
299+
[$this->_getFixture('image_adapters_test.png'), [200, 0]]
299300
]
300301
);
301302
}

dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/view/billing-address-validate.test.js

+18-2
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ define([
107107

108108
describe('Magento_Checkout/js/view/billing-address', function () {
109109
describe('"updateAddress" method', function () {
110-
it('should not call updateAddresses when form is invalid', function () {
110+
it('should call updateAddresses when form is invalid with false', function () {
111111
billingAddress.source.set.and.callFake(function (key, value) {
112112
if (key === 'params.invalid' && value === true) {
113113
billingAddress.source.get.and.callFake(function () {
@@ -120,9 +120,25 @@ define([
120120
});
121121
spyOn(billingAddress, 'updateAddresses');
122122
billingAddress.updateAddress();
123-
expect(billingAddress.updateAddresses).not.toHaveBeenCalled();
123+
expect(billingAddress.updateAddresses).toHaveBeenCalledWith(false);
124124
expect(selectBillingAddress).not.toHaveBeenCalled();
125125
});
126+
127+
it('should call updateAddresses when form is valid with true', function () {
128+
billingAddress.source.get.and.callFake(function (key) {
129+
if (key === 'params.invalid') {
130+
return false; // Simulate valid form data
131+
} else if (key === billingAddress.dataScopePrefix) {
132+
return lastSelectedBillingAddress; // Return mock address data
133+
}
134+
return null;
135+
});
136+
137+
spyOn(billingAddress, 'updateAddresses');
138+
billingAddress.updateAddress();
139+
expect(billingAddress.updateAddresses).toHaveBeenCalledWith(true);
140+
expect(selectBillingAddress).toHaveBeenCalled();
141+
});
126142
});
127143
});
128144
});

lib/internal/Magento/Framework/Image/Adapter/AbstractAdapter.php

+14-10
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
/**
1313
* Image abstract adapter
1414
*
15+
* phpcs:disable Magento2.Classes.AbstractApi
1516
* @api
1617
* @SuppressWarnings(PHPMD.TooManyFields)
1718
*/
@@ -27,25 +28,25 @@ abstract class AbstractAdapter implements AdapterInterface
2728
* Position constants.
2829
* Used mainly for watermarks
2930
*/
30-
const POSITION_TOP_LEFT = 'top-left';
31+
public const POSITION_TOP_LEFT = 'top-left';
3132

32-
const POSITION_TOP_RIGHT = 'top-right';
33+
public const POSITION_TOP_RIGHT = 'top-right';
3334

34-
const POSITION_BOTTOM_LEFT = 'bottom-left';
35+
public const POSITION_BOTTOM_LEFT = 'bottom-left';
3536

36-
const POSITION_BOTTOM_RIGHT = 'bottom-right';
37+
public const POSITION_BOTTOM_RIGHT = 'bottom-right';
3738

38-
const POSITION_STRETCH = 'stretch';
39+
public const POSITION_STRETCH = 'stretch';
3940

40-
const POSITION_TILE = 'tile';
41+
public const POSITION_TILE = 'tile';
4142

42-
const POSITION_CENTER = 'center';
43+
public const POSITION_CENTER = 'center';
4344
/**#@-*/
4445

4546
/**
4647
* The size of the font to use as default
4748
*/
48-
const DEFAULT_FONT_SIZE = 15;
49+
public const DEFAULT_FONT_SIZE = 15;
4950

5051
/**
5152
* @var int
@@ -604,7 +605,10 @@ protected function _checkAspectRatio($frameWidth, $frameHeight)
604605
}
605606
// keep aspect ratio
606607
if ($this->_imageSrcWidth / $this->_imageSrcHeight >= $frameWidth / $frameHeight) {
607-
$dstHeight = round($dstWidth / $this->_imageSrcWidth * $this->_imageSrcHeight);
608+
$dstHeight = max(
609+
1,
610+
round($dstWidth / $this->_imageSrcWidth * $this->_imageSrcHeight)
611+
);
608612
} else {
609613
$dstWidth = round($dstHeight / $this->_imageSrcHeight * $this->_imageSrcWidth);
610614
}
@@ -624,7 +628,7 @@ protected function _checkDimensions($frameWidth, $frameHeight)
624628
{
625629
if ($frameWidth !== null && $frameWidth <= 0 ||
626630
$frameHeight !== null && $frameHeight <= 0 ||
627-
empty($frameWidth) && empty($frameHeight)
631+
($frameWidth === null && $frameHeight === null)
628632
) {
629633
//phpcs:ignore Magento2.Exceptions.DirectThrow
630634
throw new \InvalidArgumentException('Invalid image dimensions.');

lib/web/mage/calendar.js

+1-7
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ define([
330330
(
331331
printDate.getDate() === today.getDate() &&
332332
printDate.getMonth() === today.getMonth() &&
333-
printDate.getYear() === today.getYear() ? ' ui-datepicker-today' : ''
333+
printDate.getYear() === today.getYear() ? ' ui-datepicker-today' : ''
334334
)
335335
) + '"' + ((!otherMonth || showOtherMonths) && daySettings[2] ?
336336
' title="' + daySettings[2] + '"' : '') + // cell title
@@ -514,13 +514,7 @@ define([
514514
if (this.options.from && this.options.to) {
515515
from = this.element.find('#' + this.options.from.id);
516516
to = this.element.find('#' + this.options.to.id);
517-
this.options.onSelect = $.proxy(function (selectedDate) {
518-
to[this._picker()]('option', 'minDate', selectedDate);
519-
}, this);
520517
$.mage.calendar.prototype._initPicker.call(this, from);
521-
from.on('change', $.proxy(function () {
522-
to[this._picker()]('option', 'minDate', from[this._picker()]('getDate'));
523-
}, this));
524518
this.options.onSelect = $.proxy(function (selectedDate) {
525519
from[this._picker()]('option', 'maxDate', selectedDate);
526520
}, this);

0 commit comments

Comments
 (0)