Skip to content

Commit cc67aa0

Browse files
authored
Merge pull request magento#4919 from magento-tsg-csl3/2.3-develop-pr35
[TSG-CSL3] For 2.3 (pr35)
2 parents 6f1c7e3 + 19fae12 commit cc67aa0

File tree

24 files changed

+487
-81
lines changed

24 files changed

+487
-81
lines changed

app/code/Magento/Catalog/Test/Mftf/Data/ProductAttributeOptionData.xml

+8
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,14 @@
8686
<data key="label" unique="suffix">White</data>
8787
<data key="value" unique="suffix">white</data>
8888
</entity>
89+
<entity name="ProductAttributeOption9" type="ProductAttributeOption">
90+
<var key="attribute_code" entityKey="attribute_code" entityType="ProductAttribute"/>
91+
<data key="label" unique="suffix">Blue</data>
92+
<data key="is_default">false</data>
93+
<data key="sort_order">3</data>
94+
<requiredEntity type="StoreLabel">Option11Store0</requiredEntity>
95+
<requiredEntity type="StoreLabel">Option11Store1</requiredEntity>
96+
</entity>
8997
<!-- Product attribute options from file "export_import_configurable_product.csv" -->
9098
<entity name="ProductAttributeOptionOneForExportImport" extends="productAttributeOption1" type="ProductAttributeOption">
9199
<data key="label">option1</data>

app/code/Magento/Catalog/Test/Mftf/Data/StoreLabelData.xml

+8
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,12 @@
7272
<data key="store_id">1</data>
7373
<data key="label">Red</data>
7474
</entity>
75+
<entity name="Option11Store0" type="StoreLabel">
76+
<data key="store_id">0</data>
77+
<data key="label">Blue</data>
78+
</entity>
79+
<entity name="Option11Store1" type="StoreLabel">
80+
<data key="store_id">1</data>
81+
<data key="label">Blue</data>
82+
</entity>
7583
</entities>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="AdminProductGridFilteringByCustomAttributeTest">
12+
<annotations>
13+
<features value="Catalog"/>
14+
<stories value="Product grid"/>
15+
<title value="Sorting the product grid by custom product attribute"/>
16+
<description value="Sorting the product grid by custom product attribute should sort Alphabetically instead of value id"/>
17+
<severity value="MAJOR"/>
18+
<useCaseId value="MC-19031"/>
19+
<testCaseId value="MC-20329"/>
20+
<group value="catalog"/>
21+
</annotations>
22+
<before>
23+
<!--Login as admin and delete all products -->
24+
<actionGroup ref="LoginAsAdmin" stepKey="login"/>
25+
<actionGroup ref="deleteAllProductsUsingProductGrid" stepKey="deleteAllProducts"/>
26+
<!--Create dropdown product attribute-->
27+
<createData entity="productDropDownAttribute" stepKey="createDropdownAttribute"/>
28+
<!--Create attribute options-->
29+
<createData entity="ProductAttributeOption7" stepKey="createFirstProductAttributeOption">
30+
<requiredEntity createDataKey="createDropdownAttribute"/>
31+
</createData>
32+
<createData entity="ProductAttributeOption8" stepKey="createSecondProductAttributeOption">
33+
<requiredEntity createDataKey="createDropdownAttribute"/>
34+
</createData>
35+
<createData entity="ProductAttributeOption9" stepKey="createThirdProductAttributeOption">
36+
<requiredEntity createDataKey="createDropdownAttribute"/>
37+
</createData>
38+
<!--Add attribute to default attribute set-->
39+
<createData entity="AddToDefaultSet" stepKey="addAttributeToDefaultSet">
40+
<requiredEntity createDataKey="createDropdownAttribute"/>
41+
</createData>
42+
<!--Create category-->
43+
<createData entity="_defaultCategory" stepKey="createCategory"/>
44+
<!--Create 3 products-->
45+
<createData entity="ApiSimpleProduct" stepKey="createFirstProduct">
46+
<requiredEntity createDataKey="createCategory"/>
47+
</createData>
48+
<createData entity="ApiSimpleProduct" stepKey="createSecondProduct">
49+
<requiredEntity createDataKey="createCategory"/>
50+
</createData>
51+
<createData entity="ApiSimpleProduct" stepKey="createThirdProduct">
52+
<requiredEntity createDataKey="createCategory"/>
53+
</createData>
54+
<!--Update first product-->
55+
<actionGroup ref="SearchForProductOnBackendActionGroup" stepKey="searchForFirstProduct">
56+
<argument name="product" value="$$createFirstProduct$$"/>
57+
</actionGroup>
58+
<actionGroup ref="OpenEditProductOnBackendActionGroup" stepKey="editFirstProduct">
59+
<argument name="product" value="$$createFirstProduct$$"/>
60+
</actionGroup>
61+
<selectOption selector="{{AdminProductFormSection.customSelectField($$createDropdownAttribute.attribute[attribute_code]$$)}}" userInput="$$createFirstProductAttributeOption.option[store_labels][0][label]$$" stepKey="setFirstAttributeValue"/>
62+
<actionGroup ref="saveProductForm" stepKey="saveFirstProduct"/>
63+
<!--Update second product-->
64+
<actionGroup ref="SearchForProductOnBackendActionGroup" stepKey="searchForSecondProduct">
65+
<argument name="product" value="$$createSecondProduct$$"/>
66+
</actionGroup>
67+
<actionGroup ref="OpenEditProductOnBackendActionGroup" stepKey="editSecondProduct">
68+
<argument name="product" value="$$createSecondProduct$$"/>
69+
</actionGroup>
70+
<selectOption selector="{{AdminProductFormSection.customSelectField($$createDropdownAttribute.attribute[attribute_code]$$)}}" userInput="$$createSecondProductAttributeOption.option[store_labels][0][label]$$" stepKey="setSecondAttributeValue"/>
71+
<actionGroup ref="saveProductForm" stepKey="saveSecondProduct"/>
72+
<!--Update third product-->
73+
<actionGroup ref="SearchForProductOnBackendActionGroup" stepKey="searchForThirdProduct">
74+
<argument name="product" value="$$createThirdProduct$$"/>
75+
</actionGroup>
76+
<actionGroup ref="OpenEditProductOnBackendActionGroup" stepKey="editThirdProduct">
77+
<argument name="product" value="$$createThirdProduct$$"/>
78+
</actionGroup>
79+
<selectOption selector="{{AdminProductFormSection.customSelectField($$createDropdownAttribute.attribute[attribute_code]$$)}}" userInput="$$createThirdProductAttributeOption.option[store_labels][0][label]$$" stepKey="setThirdAttributeValue"/>
80+
<actionGroup ref="saveProductForm" stepKey="saveThirdProduct"/>
81+
</before>
82+
<after>
83+
<!--Delete products-->
84+
<deleteData createDataKey="createFirstProduct" stepKey="deleteFirstProduct"/>
85+
<deleteData createDataKey="createSecondProduct" stepKey="deleteSecondProduct"/>
86+
<deleteData createDataKey="createThirdProduct" stepKey="deleteThirdProduct"/>
87+
<!--Delete attribute-->
88+
<deleteData createDataKey="createDropdownAttribute" stepKey="deleteDropdownAttribute"/>
89+
<!--Delete category-->
90+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
91+
<actionGroup ref="NavigateToAndResetProductGridToDefaultView" stepKey="NavigateToAndResetProductGridToDefaultViewAfterTest"/>
92+
<actionGroup ref="logout" stepKey="logout"/>
93+
</after>
94+
<amOnPage url="{{AdminProductIndexPage.url}}" stepKey="navigateToProductIndex"/>
95+
<waitForPageLoad stepKey="waitForProductGridPageLoad"/>
96+
<actionGroup ref="clearFiltersAdminDataGrid" stepKey="clearProductGridFilters"/>
97+
<!--Sort by custom attribute DESC using grabbed value-->
98+
<conditionalClick selector="{{AdminProductGridSection.columnHeader($$createDropdownAttribute.attribute[frontend_labels][0][label]$$)}}" dependentSelector="{{AdminProductGridSection.columnHeader($$createDropdownAttribute.attribute[frontend_labels][0][label]$$)}}" visible="true" stepKey="ascendSortByCustomAttribute"/>
99+
<waitForPageLoad stepKey="waitForProductGridLoad"/>
100+
<!--Check products sorting. Expected result => Blue-Green-Red -->
101+
<see selector="{{AdminProductGridSection.productGridNameProduct($$createSecondProduct.name$$)}}" userInput="$$createSecondProduct.name$$" stepKey="seeSecondProductName"/>
102+
<see selector="{{AdminProductGridSection.productGridNameProduct($$createFirstProduct.name$$)}}" userInput="$$createFirstProduct.name$$" stepKey="seeFirstProductName"/>
103+
<see selector="{{AdminProductGridSection.productGridNameProduct($$createThirdProduct.name$$)}}" userInput="$$createThirdProduct.name$$" stepKey="seeThirdProductName"/>
104+
</test>
105+
</tests>

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

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
</actionGroup>
5757

5858
<magentoCLI command="indexer:reindex" stepKey="reindex"/>
59+
<magentoCLI command="cache:flush" arguments="full_page" stepKey="flushCache"/>
5960
</before>
6061
<after>
6162
<!-- Change "Category Products" and "Product Categories" indexers to "Update on Save" mode -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AssertStorefrontShippingLabelDescriptionInOrderSummaryActionGroup">
12+
<annotations>
13+
<description>Validates that the Shipping label description is present and correct.</description>
14+
</annotations>
15+
16+
<arguments>
17+
<argument name="labelDescription" type="string"/>
18+
</arguments>
19+
<waitForElementVisible selector="{{CheckoutOrderSummarySection.orderSummaryShippingTotalLabelDescription}}" time="30" stepKey="waitForElement"/>
20+
<see selector="{{CheckoutOrderSummarySection.orderSummaryShippingTotalLabelDescription}}" userInput="{{labelDescription}}" stepKey="seeShippingMethodLabelDescription"/>
21+
</actionGroup>
22+
</actionGroups>

app/code/Magento/Checkout/Test/Mftf/ActionGroup/CheckoutActionGroup.xml

+9
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,15 @@
171171
<seeInCurrentUrl url="{{CheckoutPage.url}}/#payment" stepKey="assertCheckoutPaymentUrl"/>
172172
</actionGroup>
173173

174+
<!-- Submit Shipping Address on Checkout Shipping page -->
175+
<actionGroup name="StorefrontCheckoutForwardFromShippingStep">
176+
<annotations>
177+
<description>Clicks next on Checkout Shipping step</description>
178+
</annotations>
179+
<waitForElementVisible selector="{{CheckoutShippingSection.next}}" time="30" stepKey="waitForNextButton"/>
180+
<click selector="{{CheckoutShippingSection.next}}" stepKey="clickNext"/>
181+
</actionGroup>
182+
174183
<!-- Logged in user checkout filling shipping section -->
175184
<actionGroup name="LoggedInUserCheckoutAddNewShippingSectionWithoutRegionActionGroup">
176185
<annotations>

app/code/Magento/Checkout/Test/Mftf/Section/CheckoutOrderSummarySection.xml

+1
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@
1919
<element name="additionalAddress" type="text" selector=".block.block-addresses-list"/>
2020
<element name="miniCartTabClosed" type="button" selector=".title[aria-expanded='false']" timeout="30"/>
2121
<element name="itemsQtyInCart" type="text" selector=".items-in-cart > .title > strong > span"/>
22+
<element name="orderSummaryShippingTotalLabelDescription" type="text" selector=".shipping.totals .label.description"/>
2223
</section>
2324
</sections>

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

+31-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
define([
77
'jquery',
88
'Magento_Checkout/js/view/summary/abstract-total',
9-
'Magento_Checkout/js/model/quote'
10-
], function ($, Component, quote) {
9+
'Magento_Checkout/js/model/quote',
10+
'Magento_SalesRule/js/view/summary/discount'
11+
], function ($, Component, quote, discountView) {
1112
'use strict';
1213

1314
return Component.extend({
@@ -57,6 +58,34 @@ define([
5758
price = this.totals()['shipping_amount'];
5859

5960
return this.getFormattedPrice(price);
61+
},
62+
63+
/**
64+
* If is set coupon code, but there wasn't displayed discount view.
65+
*
66+
* @return {Boolean}
67+
*/
68+
haveToShowCoupon: function () {
69+
var couponCode = this.totals()['coupon_code'];
70+
71+
if (typeof couponCode === 'undefined') {
72+
couponCode = false;
73+
}
74+
75+
return couponCode && !discountView().isDisplayed();
76+
},
77+
78+
/**
79+
* Returns coupon code description.
80+
*
81+
* @return {String}
82+
*/
83+
getCouponDescription: function () {
84+
if (!this.haveToShowCoupon()) {
85+
return '';
86+
}
87+
88+
return '(' + this.totals()['coupon_code'] + ')';
6089
}
6190
});
6291
});

app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithDefaultSetLinksTest.xml

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
<magentoCLI stepKey="addDownloadableDomain" command="downloadable:domains:add static.magento.com"/>
2424
<!-- Create category -->
2525
<createData entity="SimpleSubCategory" stepKey="createCategory"/>
26-
26+
<!-- Reindex and clear page cache -->
27+
<magentoCLI command="indexer:reindex" stepKey="reindex"/>
28+
<magentoCLI command="cache:flush" arguments="full_page" stepKey="flushCache"/>
2729
<!-- Login as admin -->
2830
<actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/>
2931
</before>

app/code/Magento/Eav/Model/Entity/Attribute/Source/Table.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ public function addValueSortToCollection($collection, $dir = \Magento\Framework\
213213
$valueExpr
214214
);
215215

216-
$collection->getSelect()->order("{$attribute->getAttributeCode()} {$dir}");
216+
$collection->getSelect()->order("{$attribute->getAttributeCode()}_value {$dir}");
217217

218218
return $this;
219219
}

app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Option.php

+11-5
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,13 @@ public function addOptionValueToCollection($collection, $attribute, $valueExpr)
4242
"{$optionTable2}.option_id={$valueExpr} AND {$optionTable2}.store_id=?",
4343
$collection->getStoreId()
4444
);
45-
$valueExpr = $connection->getCheckSql(
46-
"{$optionTable2}.value_id IS NULL",
47-
"{$optionTable1}.option_id",
48-
"{$optionTable2}.option_id"
45+
$valueIdExpr = $connection->getIfNullSql(
46+
"{$optionTable2}.option_id",
47+
"{$optionTable1}.option_id"
48+
);
49+
$valueExpr = $connection->getIfNullSql(
50+
"{$optionTable2}.value",
51+
"{$optionTable1}.value"
4952
);
5053

5154
$collection->getSelect()->joinLeft(
@@ -55,7 +58,10 @@ public function addOptionValueToCollection($collection, $attribute, $valueExpr)
5558
)->joinLeft(
5659
[$optionTable2 => $this->getTable('eav_attribute_option_value')],
5760
$tableJoinCond2,
58-
[$attributeCode => $valueExpr]
61+
[
62+
$attributeCode => $valueIdExpr,
63+
$attributeCode . '_value' => $valueExpr,
64+
]
5965
);
6066

6167
return $this;

app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Source/TableTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ public function testAddValueSortToCollection()
314314
$attrOption->expects($this->once())->method('addOptionValueToCollection')
315315
->with($collection, $this->abstractAttributeMock, $expr)
316316
->willReturnSelf();
317-
$select->expects($this->once())->method('order')->with("{$attributeCode} {$dir}");
317+
$select->expects($this->once())->method('order')->with("{$attributeCode}_value {$dir}");
318318

319319
$this->assertEquals($this->model, $this->model->addValueSortToCollection($collection, $dir));
320320
}

app/code/Magento/Quote/Model/QuoteRepository.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ protected function loadQuote($loadMethod, $loadField, $identifier, array $shared
224224
{
225225
/** @var CartInterface $quote */
226226
$quote = $this->cartFactory->create();
227-
if ($sharedStoreIds && method_exists($quote, 'setSharedStoreIds')) {
227+
if ($sharedStoreIds && is_callable([$quote, 'setSharedStoreIds'])) {
228228
$quote->setSharedStoreIds($sharedStoreIds);
229229
}
230230
$quote->setStoreId($this->storeManager->getStore()->getId())->$loadMethod($identifier);

app/code/Magento/Quote/Test/Unit/Model/QuoteRepositoryTest.php

+30-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface;
1010
use Magento\Framework\Api\SortOrder;
1111
use Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface;
12+
use PHPUnit\Framework\MockObject\Matcher\InvokedCount as InvokedCountMatch;
1213
use Magento\Framework\ObjectManagerInterface;
1314
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
1415
use Magento\Quote\Api\Data\CartInterface;
@@ -284,7 +285,14 @@ public function testGetWithSharedStoreIds()
284285
$this->assertEquals($this->quoteMock, $this->model->get($cartId, $sharedStoreIds));
285286
}
286287

287-
public function testGetForCustomer()
288+
/**
289+
* Test getForCustomer method
290+
*
291+
* @param InvokedCountMatch $invokeTimes
292+
* @param array $sharedStoreIds
293+
* @dataProvider getForCustomerDataProvider
294+
*/
295+
public function testGetForCustomer(InvokedCountMatch $invokeTimes, array $sharedStoreIds)
288296
{
289297
$cartId = 17;
290298
$customerId = 23;
@@ -298,7 +306,7 @@ public function testGetForCustomer()
298306
$this->storeMock->expects(static::once())
299307
->method('getId')
300308
->willReturn(1);
301-
$this->quoteMock->expects(static::never())
309+
$this->quoteMock->expects($invokeTimes)
302310
->method('setSharedStoreIds');
303311
$this->quoteMock->expects(static::once())
304312
->method('loadByCustomer')
@@ -312,8 +320,27 @@ public function testGetForCustomer()
312320
->method('load')
313321
->with($this->quoteMock);
314322

323+
static::assertEquals($this->quoteMock, $this->model->getForCustomer($customerId, $sharedStoreIds));
315324
static::assertEquals($this->quoteMock, $this->model->getForCustomer($customerId));
316-
static::assertEquals($this->quoteMock, $this->model->getForCustomer($customerId));
325+
}
326+
327+
/**
328+
* Checking how many times we invoke setSharedStoreIds() in protected method loadQuote()
329+
*
330+
* @return array
331+
*/
332+
public function getForCustomerDataProvider()
333+
{
334+
return [
335+
[
336+
'invoke_number_times' => static::never(),
337+
'shared_store_ids' => []
338+
],
339+
[
340+
'invoke_number_times' => static::once(),
341+
'shared_store_ids' => [1]
342+
]
343+
];
317344
}
318345

319346
/**

0 commit comments

Comments
 (0)