Skip to content

Commit bb54646

Browse files
committed
Merge branch 'github-2.3-develop' into MAGETWO-98584
2 parents f92c8fd + 8f45cf8 commit bb54646

File tree

9 files changed

+327
-19
lines changed

9 files changed

+327
-19
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,11 @@
428428
<var key="sku" entityType="product" entityKey="sku" />
429429
<requiredEntity type="product_option">ProductOptionDropDownWithLongValuesTitle</requiredEntity>
430430
</entity>
431+
<entity name="ProductWithTextFieldAndAreaOptions" type="product">
432+
<var key="sku" entityType="product" entityKey="sku" />
433+
<requiredEntity type="product_option">ProductOptionField</requiredEntity>
434+
<requiredEntity type="product_option">ProductOptionArea</requiredEntity>
435+
</entity>
431436
<entity name="ApiVirtualProductWithDescription" type="product">
432437
<data key="sku" unique="suffix">api-virtual-product</data>
433438
<data key="type_id">virtual</data>

app/code/Magento/Checkout/Test/Mftf/Data/QuoteData.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,17 @@
2424
<data key="shippingMethod">Flat Rate - Fixed</data>
2525
<data key="currency">$</data>
2626
</entity>
27+
<entity name="quoteQty3Price123" type="Quote">
28+
<data key="price">123.00</data>
29+
<data key="qty">3</data>
30+
<data key="subtotal">369.00</data>
31+
<data key="currency">$</data>
32+
</entity>
33+
<entity name="quoteQty11Subtotal1320" type="Quote">
34+
<data key="price">100.00</data>
35+
<data key="customOptionsPrice">20</data>
36+
<data key="qty">11</data>
37+
<data key="subtotal">1,320.00</data>
38+
<data key="currency">$</data>
39+
</entity>
2740
</entities>
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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="StorefrontUpdateShoppingCartSimpleProductQtyTest">
12+
<annotations>
13+
<features value="Checkout"/>
14+
<title value="Check updating shopping cart while updating items qty"/>
15+
<description value="Check updating shopping cart while updating items qty"/>
16+
<testCaseId value="MC-14731" />
17+
<group value="shoppingCart"/>
18+
<group value="mtf_migrated"/>
19+
</annotations>
20+
<before>
21+
<createData entity="_defaultCategory" stepKey="createCategory"/>
22+
<createData entity="SimpleProduct" stepKey="createProduct">
23+
<requiredEntity createDataKey="createCategory"/>
24+
</createData>
25+
26+
<!-- Add the newly created product to the shopping cart -->
27+
<actionGroup ref="AddSimpleProductToCart" stepKey="addToCartFromStorefrontProductPage">
28+
<argument name="product" value="$$createProduct$$"/>
29+
</actionGroup>
30+
</before>
31+
<after>
32+
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
33+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
34+
</after>
35+
36+
<!-- Go to the shopping cart -->
37+
<amOnPage url="{{CheckoutCartPage.url}}" stepKey="amOnPageShoppingCart"/>
38+
<waitForPageLoad stepKey="waitForCheckoutPageLoad1"/>
39+
40+
<!-- Change the product QTY -->
41+
<fillField selector="{{CheckoutCartProductSection.ProductQuantityByName($$createProduct.name$$)}}" userInput="{{quoteQty3Price123.qty}}" stepKey="changeCartQty"/>
42+
<click selector="{{CheckoutCartProductSection.updateShoppingCartButton}}" stepKey="openShoppingCart"/>
43+
<waitForPageLoad stepKey="waitForCheckoutPageLoad2"/>
44+
45+
<!-- The price and QTY values should be updated for the product -->
46+
<grabValueFrom selector="{{CheckoutCartProductSection.ProductQuantityByName($$createProduct.name$$)}}" stepKey="grabProductQtyInCart"/>
47+
<see userInput="{{quoteQty3Price123.currency}}{{quoteQty3Price123.subtotal}}" selector="{{CheckoutCartProductSection.productSubtotalByName($$createProduct.name$$)}}" stepKey="assertProductPrice"/>
48+
<assertEquals stepKey="assertProductQtyInCart">
49+
<actualResult type="variable">grabProductQtyInCart</actualResult>
50+
<expectedResult type="string">{{quoteQty3Price123.qty}}</expectedResult>
51+
</assertEquals>
52+
53+
<!-- Subtotal should be updated -->
54+
<see userInput="{{quoteQty3Price123.currency}}{{quoteQty3Price123.subtotal}}" selector="{{CheckoutCartSummarySection.subtotal}}" stepKey="assertCartSubtotal"/>
55+
56+
<!-- Minicart product price and subtotal should be updated -->
57+
<actionGroup ref="clickViewAndEditCartFromMiniCart" stepKey="openMinicart"/>
58+
<grabValueFrom selector="{{StorefrontMinicartSection.itemQuantity($$createProduct.name$$)}}" stepKey="grabProductQtyInMinicart"/>
59+
<assertEquals stepKey="assertProductQtyInMinicart">
60+
<actualResult type="variable">grabProductQtyInMinicart</actualResult>
61+
<expectedResult type="string">{{quoteQty3Price123.qty}}</expectedResult>
62+
</assertEquals>
63+
<see userInput="{{quoteQty3Price123.currency}}{{quoteQty3Price123.subtotal}}" selector="{{StorefrontMinicartSection.subtotal}}" stepKey="assertMinicartSubtotal"/>
64+
</test>
65+
</tests>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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="StorefrontUpdateShoppingCartSimpleWithCustomOptionsProductQtyTest">
12+
<annotations>
13+
<features value="Checkout"/>
14+
<title value="Check updating shopping cart while updating qty of items with custom options"/>
15+
<description value="Check updating shopping cart while updating qty of items with custom options"/>
16+
<testCaseId value="MC-14732" />
17+
<group value="shoppingCart"/>
18+
<group value="mtf_migrated"/>
19+
</annotations>
20+
<before>
21+
<createData entity="_defaultCategory" stepKey="createCategory"/>
22+
<createData entity="ApiSimpleProductWithCustomPrice" stepKey="createProduct">
23+
<requiredEntity createDataKey="createCategory"/>
24+
</createData>
25+
26+
<!-- Add two custom options to the product: field and textarea -->
27+
<updateData createDataKey="createProduct" entity="ProductWithTextFieldAndAreaOptions" stepKey="updateProductWithOption"/>
28+
29+
<!-- Go to the product page, fill the custom options values and add the product to the shopping cart -->
30+
<amOnPage url="{{StorefrontProductPage.url($$createProduct.custom_attributes[url_key]$$)}}" stepKey="amOnProductPage"/>
31+
<waitForPageLoad stepKey="waitForCatalogPageLoad"/>
32+
<fillField userInput="OptionField" selector="{{StorefrontProductInfoMainSection.productOptionFieldInput(ProductOptionField.title)}}" stepKey="fillProductOptionInputField"/>
33+
<fillField userInput="OptionArea" selector="{{StorefrontProductInfoMainSection.productOptionAreaInput(ProductOptionArea.title)}}" stepKey="fillProductOptionInputArea"/>
34+
<actionGroup ref="StorefrontAddToCartCustomOptionsProductPageActionGroup" stepKey="addToCartFromStorefrontProductPage">
35+
<argument name="productName" value="$createProduct.name$"/>
36+
</actionGroup>
37+
</before>
38+
<after>
39+
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
40+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
41+
</after>
42+
43+
<!-- Go to the shopping cart -->
44+
<amOnPage url="{{CheckoutCartPage.url}}" stepKey="amOnPageShoppingCart"/>
45+
<waitForPageLoad stepKey="waitForCheckoutPageLoad"/>
46+
47+
<!-- Change the product QTY -->
48+
<fillField selector="{{CheckoutCartProductSection.ProductQuantityByName($$createProduct.name$$)}}" userInput="{{quoteQty11Subtotal1320.qty}}" stepKey="changeCartQty"/>
49+
<click selector="{{CheckoutCartProductSection.updateShoppingCartButton}}" stepKey="updateShoppingCart"/>
50+
<waitForPageLoad stepKey="waitShoppingCartUpdated"/>
51+
52+
<!-- The price and QTY values should be updated for the product -->
53+
<grabValueFrom selector="{{CheckoutCartProductSection.ProductQuantityByName($$createProduct.name$$)}}" stepKey="grabProductQtyInCart"/>
54+
<see userInput="{{quoteQty11Subtotal1320.currency}}{{quoteQty11Subtotal1320.subtotal}}" selector="{{CheckoutCartProductSection.productSubtotalByName($$createProduct.name$$)}}" stepKey="assertProductPrice"/>
55+
<assertEquals stepKey="assertProductQtyInCart">
56+
<expectedResult type="string">{{quoteQty11Subtotal1320.qty}}</expectedResult>
57+
<actualResult type="variable">grabProductQtyInCart</actualResult>
58+
</assertEquals>
59+
<see userInput="{{quoteQty11Subtotal1320.currency}}{{quoteQty11Subtotal1320.subtotal}}" selector="{{CheckoutCartSummarySection.subtotal}}" stepKey="assertSubtotal"/>
60+
61+
<!-- Minicart product price and subtotal should be updated -->
62+
<actionGroup ref="clickViewAndEditCartFromMiniCart" stepKey="openMinicart"/>
63+
<grabValueFrom selector="{{StorefrontMinicartSection.itemQuantity($$createProduct.name$$)}}" stepKey="grabProductQtyInMinicart"/>
64+
<assertEquals stepKey="assertProductQtyInMinicart">
65+
<expectedResult type="string">{{quoteQty11Subtotal1320.qty}}</expectedResult>
66+
<actualResult type="variable">grabProductQtyInMinicart</actualResult>
67+
</assertEquals>
68+
<see userInput="{{quoteQty11Subtotal1320.currency}}{{quoteQty11Subtotal1320.subtotal}}" selector="{{StorefrontMinicartSection.subtotal}}" stepKey="assertMinicartSubtotal"/>
69+
</test>
70+
</tests>

app/code/Magento/Theme/Model/Design/Backend/File.php

Lines changed: 59 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
use Magento\Theme\Model\Design\Config\FileUploader\FileProcessor;
2323

2424
/**
25+
* File Backend
26+
*
2527
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2628
*/
2729
class File extends BackendFile
@@ -88,36 +90,29 @@ public function beforeSave()
8890
{
8991
$values = $this->getValue();
9092
$value = reset($values) ?: [];
91-
if (!isset($value['file'])) {
93+
94+
// Need to check name when it is uploaded in the media gallary
95+
$file = $value['file'] ?? $value['name'] ?? null;
96+
if (!isset($file)) {
9297
throw new LocalizedException(
9398
__('%1 does not contain field \'file\'', $this->getData('field_config/field'))
9499
);
95100
}
96101
if (isset($value['exists'])) {
97-
$this->setValue($value['file']);
102+
$this->setValue($file);
98103
return $this;
99104
}
100105

101-
$filename = basename($value['file']);
102-
$result = $this->_mediaDirectory->copyFile(
103-
$this->getTmpMediaPath($filename),
104-
$this->_getUploadDir() . '/' . $filename
105-
);
106-
if ($result) {
107-
$this->_mediaDirectory->delete($this->getTmpMediaPath($filename));
108-
if ($this->_addWhetherScopeInfo()) {
109-
$filename = $this->_prependScopeInfo($filename);
110-
}
111-
$this->setValue($filename);
112-
} else {
113-
$this->unsValue();
114-
}
106+
$this->updateMediaDirectory(basename($file), $value['url']);
115107

116108
return $this;
117109
}
118110

119111
/**
120-
* @return array
112+
* After Load
113+
*
114+
* @return File
115+
* @throws LocalizedException
121116
*/
122117
public function afterLoad()
123118
{
@@ -166,6 +161,8 @@ protected function getUploadDirPath($uploadDir)
166161
}
167162

168163
/**
164+
* Get Value
165+
*
169166
* @return array
170167
*/
171168
public function getValue()
@@ -231,4 +228,49 @@ private function getMime()
231228
}
232229
return $this->mime;
233230
}
231+
232+
/**
233+
* Get Relative Media Path
234+
*
235+
* @param string $path
236+
* @return string
237+
*/
238+
private function getRelativeMediaPath(string $path): string
239+
{
240+
return str_replace('/pub/media/', '', $path);
241+
}
242+
243+
/**
244+
* Move file to the correct media directory
245+
*
246+
* @param string $filename
247+
* @param string $url
248+
* @throws LocalizedException
249+
*/
250+
private function updateMediaDirectory(string $filename, string $url)
251+
{
252+
$relativeMediaPath = $this->getRelativeMediaPath($url);
253+
$tmpMediaPath = $this->getTmpMediaPath($filename);
254+
$mediaPath = $this->_mediaDirectory->isFile($relativeMediaPath) ? $relativeMediaPath : $tmpMediaPath;
255+
$destinationMediaPath = $this->_getUploadDir() . '/' . $filename;
256+
257+
$result = $mediaPath === $destinationMediaPath;
258+
if (!$result) {
259+
$result = $this->_mediaDirectory->copyFile(
260+
$mediaPath,
261+
$destinationMediaPath
262+
);
263+
}
264+
if ($result) {
265+
if ($mediaPath === $tmpMediaPath) {
266+
$this->_mediaDirectory->delete($mediaPath);
267+
}
268+
if ($this->_addWhetherScopeInfo()) {
269+
$filename = $this->_prependScopeInfo($filename);
270+
}
271+
$this->setValue($filename);
272+
} else {
273+
$this->unsValue();
274+
}
275+
}
234276
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="NavigateToFaviconMediaFolderActionGroup">
11+
<arguments>
12+
<argument name="StoreFolder" type="string"/>
13+
</arguments>
14+
<conditionalClick selector="{{MediaGallerySection.StorageRootArrow}}" dependentSelector="{{MediaGallerySection.checkIfArrowExpand}}" stepKey="clickArrowIfClosed" visible="true"/>
15+
<waitForElement selector="{{AdminDesignConfigSection.faviconArrow}}" stepKey="waitForFaviconFolder"/>
16+
<conditionalClick selector="{{AdminDesignConfigSection.faviconArrow}}" dependentSelector="{{AdminDesignConfigSection.checkIfFaviconArrowExpand}}" stepKey="clickFaviconArrowIfClosed" visible="true"/>
17+
<waitForElement selector="{{AdminDesignConfigSection.storesArrow}}" stepKey="waitForStoresFolder"/>
18+
<conditionalClick selector="{{AdminDesignConfigSection.storesArrow}}" dependentSelector="{{AdminDesignConfigSection.checkIfStoresArrowExpand}}" stepKey="clickStoresArrowIfClosed" visible="true"/>
19+
<waitForElement selector="{{StoreFolder}}" stepKey="waitForStoreFolder"/>
20+
<click selector="{{StoreFolder}}" stepKey="clickOnCreatedFolder"/>
21+
<waitForLoadingMaskToDisappear stepKey="waitForLoading"/>
22+
</actionGroup>
23+
</actionGroups>

app/code/Magento/Theme/Test/Mftf/Section/AdminDesignConfigSection.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,22 @@
1414
<element name="watermarkSection" type="text" selector="[data-index='watermark'] .admin__fieldset-wrapper-content"/>
1515
<element name="imageUploadInputByFieldsetName" type="input" selector="//*[contains(@class,'fieldset-wrapper')][child::*[contains(@class,'fieldset-wrapper-title')]//*[contains(text(),'{{arg1}}')]]//*[contains(@class,'file-uploader')]//input" parameterized="true"/>
1616
<element name="imageUploadPreviewByFieldsetName" type="input" selector="//*[contains(@class,'fieldset-wrapper')][child::*[contains(@class,'fieldset-wrapper-title')]//*[contains(text(),'{{arg1}}')]]//*[contains(@class,'file-uploader-preview')]//img" parameterized="true"/>
17+
<element name="addSelectedFromMediaGallery" type="input" selector="//button[contains(@title,'Add Selected')]"/>
18+
<element name="htmlHeaderSection" type="text" selector="[data-index='head']"/>
19+
<element name="selectFromGalleryByFieldsetName" type="input" selector="//*[contains(@class,'fieldset-wrapper')][child::*[contains(@class,'fieldset-wrapper-title')]//*[contains(text(),'{{arg1}}')]]//*[contains(@class,'file-uploader')]//label[contains(text(), 'Select from Gallery')]" parameterized="true"/>
20+
<element name="imageUploadFromMediaGallery" type="input" selector="//input[contains(@class,'fileupload')]" />
21+
<element name="saveConfiguration" type="input" selector="//button[contains(@title, 'Save Configuration')]" />
22+
<element name="successNotification" type="text" selector="//div[contains(@data-ui-id, 'messages-message-success')]" />
23+
<element name="useDefaultByFieldsetName" type="input" selector="//*[contains(@class,'fieldset-wrapper')][child::*[contains(@class,'fieldset-wrapper-title')]//*[contains(text(),'{{arg1}}')]]//*[contains(@class,'file-uploader')]//span[contains(text(), 'Use Default Value')]" parameterized="true" />
1724
<element name="logoSectionHeader" type="text" selector="[data-index='email']"/>
1825
<element name="logoSection" type="text" selector="[data-index='email'] .admin__fieldset-wrapper-content"/>
1926
<element name="logoUpload" type ="input" selector="[name='email_logo']" />
2027
<element name="logoWrapperOpen" type ="text" selector="[data-index='email'] [data-state-collapsible ='closed']"/>
2128
<element name="logoPreview" type ="text" selector="[alt ='magento-logo.png']"/>
29+
<element name="faviconArrow" type="button" selector="#ZmF2aWNvbg-- > .jstree-icon" />
30+
<element name="checkIfFaviconArrowExpand" type="button" selector="//li[@id='ZmF2aWNvbg--' and contains(@class,'jstree-closed')]" />
31+
<element name="storesArrow" type="button" selector="#ZmF2aWNvbi9zdG9yZXM- > .jstree-icon" />
32+
<element name="checkIfStoresArrowExpand" type="button" selector="//li[@id='ZmF2aWNvbi9zdG9yZXM-' and contains(@class,'jstree-closed')]" />
33+
<element name="storeLink" type="button" selector="#ZmF2aWNvbi9zdG9yZXMvMQ-- > a"/>
2234
</section>
2335
</sections>

0 commit comments

Comments
 (0)