Skip to content

Commit 22aac1f

Browse files
committed
Merge remote-tracking branch 'origin/2.3-develop' into MC-20073
# Conflicts: # app/code/Magento/CatalogRule/Test/Mftf/Section/AdminNewCatalogPriceRuleSection.xml
2 parents d023e98 + 2bd4cb5 commit 22aac1f

File tree

21 files changed

+724
-13
lines changed

21 files changed

+724
-13
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\Captcha\Test\Unit\CustomerData;
10+
11+
use Magento\Captcha\Helper\Data as CaptchaHelper;
12+
use Magento\Customer\Model\Session as CustomerSession;
13+
use Magento\Captcha\CustomerData\Captcha;
14+
use Magento\Captcha\Model\DefaultModel;
15+
use Magento\Customer\Api\Data\CustomerInterface as CustomerData;
16+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
17+
use PHPUnit\Framework\TestCase;
18+
19+
class CaptchaTest extends TestCase
20+
{
21+
/**
22+
* @var CaptchaHelper|\PHPUnit_Framework_MockObject_MockObject
23+
*/
24+
private $helperMock;
25+
26+
/**
27+
* @var CustomerSession|\PHPUnit_Framework_MockObject_MockObject
28+
*/
29+
private $customerSessionMock;
30+
31+
/**
32+
* @var Captcha
33+
*/
34+
private $model;
35+
36+
/**
37+
* @var array
38+
*/
39+
private $formIds;
40+
41+
/**
42+
* @var ObjectManagerHelper
43+
*/
44+
protected $objectManagerHelper;
45+
46+
/**
47+
* Create mocks and model
48+
*/
49+
protected function setUp()
50+
{
51+
$this->helperMock = $this->createMock(CaptchaHelper::class);
52+
$this->customerSessionMock = $this->createMock(CustomerSession::class);
53+
$this->formIds = [
54+
'user_login'
55+
];
56+
$this->objectManagerHelper = new ObjectManagerHelper($this);
57+
$this->model = $this->objectManagerHelper->getObject(
58+
Captcha::class,
59+
[
60+
'helper' => $this->helperMock,
61+
'formIds' => $this->formIds,
62+
'customerSession' => $this->customerSessionMock
63+
]
64+
);
65+
}
66+
67+
/**
68+
* Test getSectionData() when user is login and require captcha
69+
*/
70+
public function testGetSectionDataWhenLoginAndRequireCaptcha()
71+
{
72+
$emailLogin = 'test@localhost.com';
73+
74+
$userLoginModel = $this->createMock(DefaultModel::class);
75+
$userLoginModel->expects($this->any())->method('isRequired')->with($emailLogin)
76+
->willReturn(true);
77+
$this->helperMock->expects($this->any())->method('getCaptcha')->with('user_login')->willReturn($userLoginModel);
78+
79+
$this->customerSessionMock->expects($this->any())->method('isLoggedIn')
80+
->willReturn(true);
81+
82+
$customerDataMock = $this->createMock(CustomerData::class);
83+
$customerDataMock->expects($this->any())->method('getEmail')->willReturn($emailLogin);
84+
$this->customerSessionMock->expects($this->any())->method('getCustomerData')
85+
->willReturn($customerDataMock);
86+
87+
/* Assert to test */
88+
$this->assertEquals(
89+
[
90+
"user_login" => [
91+
"isRequired" => true,
92+
"timestamp" => time()
93+
]
94+
],
95+
$this->model->getSectionData()
96+
);
97+
}
98+
}

app/code/Magento/Catalog/Block/Adminhtml/Category/Tree.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@ protected function _getNodeJson($node, $level = 0)
407407
public function buildNodeName($node)
408408
{
409409
$result = $this->escapeHtml($node->getName());
410+
$result .= ' (ID: ' . $node->getId() . ')';
410411
if ($this->_withProductCount) {
411412
$result .= ' (' . $node->getProductCount() . ')';
412413
}

app/code/Magento/Catalog/Test/Mftf/Test/AdminFilteringCategoryProductsUsingScopeSelectorTest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@
131131
userInput="$$createProduct1.name$$" stepKey="seeProductName4"/>
132132
<see selector="{{AdminCategoryProductsGridSection.productGridNameProduct($$createProduct12.name$$)}}"
133133
userInput="$$createProduct12.name$$" stepKey="seeProductName5"/>
134-
<waitForText userInput="$$createCategory.name$$ (2)" stepKey="seeCorrectProductCount"/>
134+
<waitForText userInput="$$createCategory.name$$ (ID: 6) (2)" stepKey="seeCorrectProductCount"/>
135135
<dontSee selector="{{AdminCategoryProductsGridSection.productGridNameProduct($$createProduct0.name$$)}}"
136136
userInput="$$createProduct0.name$$" stepKey="dontSeeProductName"/>
137137
<dontSee selector="{{AdminCategoryProductsGridSection.productGridNameProduct($$createProduct2.name$$)}}"
@@ -151,7 +151,7 @@
151151
userInput="$$createProduct2.name$$" stepKey="seeProductName6"/>
152152
<see selector="{{AdminCategoryProductsGridSection.productGridNameProduct($$createProduct12.name$$)}}"
153153
userInput="$$createProduct12.name$$" stepKey="seeProductName7"/>
154-
<waitForText userInput="$$createCategory.name$$ (2)" stepKey="seeCorrectProductCount2"/>
154+
<waitForText userInput="$$createCategory.name$$ (ID: 6) (2)" stepKey="seeCorrectProductCount2"/>
155155
<dontSee selector="{{AdminCategoryProductsGridSection.productGridNameProduct($$createProduct0.name$$)}}"
156156
userInput="$$createProduct0.name$$" stepKey="dontSeeProductName2"/>
157157
<dontSee selector="{{AdminCategoryProductsGridSection.productGridNameProduct($$createProduct2.name$$)}}"

app/code/Magento/CatalogRule/Test/Mftf/ActionGroup/CatalogPriceRuleActionGroup.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,4 +233,23 @@
233233
<click selector="{{AdminNewCatalogPriceRuleConditions.activeConditionApplyButton}}" stepKey="clickApply"/>
234234
<waitForElementNotVisible selector="{{AdminNewCatalogPriceRuleConditions.activeConditionApplyButton}}" stepKey="waitForApplyButtonInvisibility"/>
235235
</actionGroup>
236+
237+
<actionGroup name="newCatalogPriceRuleWithInvalidData">
238+
<annotations>
239+
<description>Goes to the Catalog Price Rule grid. Clicks on Add. Fills in the provided Catalog Rule details with invalid data.</description>
240+
</annotations>
241+
<arguments>
242+
<argument name="catalogRule" defaultValue="catalogRuleWithInvalid"/>
243+
</arguments>
244+
245+
<!-- Go to the admin Catalog rule grid and add a new one -->
246+
<amOnPage stepKey="goToPriceRulePage" url="{{CatalogRulePage.url}}"/>
247+
<waitForPageLoad stepKey="waitForPriceRulePage"/>
248+
249+
<click stepKey="addNewRule" selector="{{AdminGridMainControls.add}}"/>
250+
<fillField stepKey="fillPriority" selector="{{AdminNewCatalogPriceRule.priority}}" userInput="{{catalogRule.priority}}"/>
251+
<scrollToTopOfPage stepKey="scrollToTop"/>
252+
<click selector="{{AdminNewCatalogPriceRule.save}}" stepKey="clickSave"/>
253+
<waitForPageLoad stepKey="waitForApplied"/>
254+
</actionGroup>
236255
</actionGroups>

app/code/Magento/CatalogRule/Test/Mftf/Data/CatalogRuleData.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,4 +173,19 @@
173173
<data key="defaultRuleLabelAllStoreViews">Free Shipping in conditions</data>
174174
<data key="defaultStoreView">Free Shipping in conditions</data>
175175
</entity>
176+
177+
<entity name="catalogRuleWithInvalid" type="catalogRule">
178+
<data key="name" unique="suffix">CatalogPriceRule</data>
179+
<data key="description">Catalog Price Rule Description</data>
180+
<data key="is_active">1</data>
181+
<array key="customer_group_ids">
182+
<item>0</item>
183+
</array>
184+
<array key="website_ids">
185+
<item>1</item>
186+
</array>
187+
<data key="simple_action">by_percent</data>
188+
<data key="discount_amount">10</data>
189+
<data key="priority">ten</data>
190+
</entity>
176191
</entities>

app/code/Magento/CatalogRule/Test/Mftf/Section/AdminNewCatalogPriceRuleSection.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
<element name="actionsTab" type="block" selector="[data-index='actions']"/>
4545
<element name="actionsTabTitle" type="block" selector="[data-index='actions'] .fieldset-wrapper-title"/>
4646
<element name="actionsTabBody" type="block" selector="[data-index='actions'] .admin__fieldset-wrapper-content"/>
47+
48+
<element name="fieldError" type="text" selector="//input[@name='{{fieldName}}']/following-sibling::label[@class='admin__field-error']" parameterized="true"/>
4749
</section>
4850

4951
<section name="AdminNewCatalogPriceRuleActions">

app/code/Magento/CatalogRule/Test/Mftf/Test/AdminCreateCatalogPriceRuleTest.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,4 +196,27 @@
196196
<see selector="{{StorefrontCategoryProductSection.ProductInfoByNumber('1')}}" userInput="$$createProduct.name$$" stepKey="seeProduct2"/>
197197
<see selector="{{StorefrontCategoryProductSection.ProductInfoByNumber('1')}}" userInput="$123.00" stepKey="seeDiscountedPrice2"/>
198198
</test>
199+
200+
<test name="AdminCreateCatalogPriceRuleWithInvalidDataTest">
201+
<annotations>
202+
<features value="CatalogRule"/>
203+
<stories value="Create Catalog Price Rule"/>
204+
<title value="Admin can not create catalog price rule with the invalid data"/>
205+
<description value="Admin can not create catalog price rule with the invalid data"/>
206+
<severity value="MAJOR"/>
207+
<group value="CatalogRule"/>
208+
</annotations>
209+
<before>
210+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
211+
</before>
212+
<after>
213+
<amOnPage url="{{AdminLogoutPage.url}}" stepKey="amOnLogoutPage"/>
214+
</after>
215+
216+
<actionGroup ref="newCatalogPriceRuleWithInvalidData" stepKey="createNewPriceRule">
217+
<argument name="catalogRule" value="catalogRuleWithInvalid"/>
218+
</actionGroup>
219+
220+
<see selector="{{AdminNewCatalogPriceRule.fieldError('sort_order')}}" userInput="Please enter a valid number in this field." stepKey="seeSortOrderError"/>
221+
</test>
199222
</tests>

app/code/Magento/CatalogRule/view/adminhtml/ui_component/catalog_rule_form.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,9 @@
208208
</item>
209209
</argument>
210210
<settings>
211+
<validation>
212+
<rule name="validate-digits" xsi:type="boolean">true</rule>
213+
</validation>
211214
<dataType>text</dataType>
212215
<label translate="true">Priority</label>
213216
<dataScope>sort_order</dataScope>

app/code/Magento/Checkout/view/frontend/web/js/view/summary/shipping.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55

66
define([
77
'jquery',
8+
'underscore',
89
'Magento_Checkout/js/view/summary/abstract-total',
910
'Magento_Checkout/js/model/quote',
1011
'Magento_SalesRule/js/view/summary/discount'
11-
], function ($, Component, quote, discountView) {
12+
], function ($, _, Component, quote, discountView) {
1213
'use strict';
1314

1415
return Component.extend({
@@ -22,19 +23,23 @@ define([
2223
* @return {*}
2324
*/
2425
getShippingMethodTitle: function () {
25-
var shippingMethod = '',
26+
var shippingMethod,
2627
shippingMethodTitle = '';
2728

2829
if (!this.isCalculated()) {
2930
return '';
3031
}
3132
shippingMethod = quote.shippingMethod();
3233

34+
if (!_.isArray(shippingMethod) && !_.isObject(shippingMethod)) {
35+
return '';
36+
}
37+
3338
if (typeof shippingMethod['method_title'] !== 'undefined') {
3439
shippingMethodTitle = ' - ' + shippingMethod['method_title'];
3540
}
3641

37-
return shippingMethod ?
42+
return shippingMethodTitle ?
3843
shippingMethod['carrier_title'] + shippingMethodTitle :
3944
shippingMethod['carrier_title'];
4045
},

app/code/Magento/Customer/view/frontend/templates/form/edit.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
</div>
6868
</div>
6969
</div>
70-
<div class="field confirm password required" data-container="confirm-password">
70+
<div class="field confirmation password required" data-container="confirm-password">
7171
<label class="label" for="password-confirmation"><span><?= $block->escapeHtml(__('Confirm New Password')) ?></span></label>
7272
<div class="control">
7373
<input type="password" class="input-text" name="password_confirmation" id="password-confirmation"
@@ -93,7 +93,7 @@
9393
], function($){
9494
var dataForm = $('#form-validate');
9595
var ignore = <?= /* @noEscape */ $_dob->isEnabled() ? '\'input[id$="full"]\'' : 'null' ?>;
96-
96+
9797
dataForm.mage('validation', {
9898
<?php if ($_dob->isEnabled()) : ?>
9999
errorPlacement: function(error, element) {

0 commit comments

Comments
 (0)