Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 0915691

Browse files
authored
Merge pull request #2851 from magento-borg/MAGETWO-77744-file-error-message
[borg] MAGETWO-77744: [Magento Cloud] - Error message when uploading unsupported file format
2 parents 9bfb67e + c5e6aa0 commit 0915691

29 files changed

+447
-37
lines changed

app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@
157157
<click selector="{{AdminProductSEOSection.sectionHeader}}" stepKey="openSeoSection"/>
158158
<fillField userInput="{{simpleProduct.urlKey}}" selector="{{AdminProductSEOSection.urlKeyInput}}" stepKey="fillUrlKey"/>
159159

160-
<click selector="{{AdminProductCustomizableOptionsSection.customezableOptions}}" stepKey="openCustomOptionsSection"/>
160+
<click selector="{{AdminProductCustomizableOptionsSection.customizableOptions}}" stepKey="openCustomOptionsSection"/>
161161
<click selector="{{AdminProductCustomizableOptionsSection.addOptionBtn}}" stepKey="clickAddOption"/>
162162
<fillField userInput="option1" selector="{{AdminProductCustomizableOptionsSection.optionTitleInput}}" stepKey="fillOptionTitle"/>
163163
<click selector="{{AdminProductCustomizableOptionsSection.optionTypeOpenDropDown}}" stepKey="openTypeDropDown"/>

app/code/Magento/Catalog/Test/Mftf/ActionGroup/CustomOptionsActionGroup.xml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,8 @@
66
*/
77
-->
88

9-
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10-
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd">
11-
12-
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd">
1310
<actionGroup name="CreateCustomRadioOptions">
14-
1511
<!-- ActionGroup will add a single custom option to a product -->
1612
<!-- You must already be on the product creation page -->
1713
<arguments>
@@ -39,8 +35,23 @@
3935

4036
<fillField stepKey="fillInValueTitle2" selector="{{AdminProductCustomizableOptionsSection.valueTitle}}" userInput="{{productOption2.title}}"/>
4137
<fillField stepKey="fillInValuePrice2" selector="{{AdminProductCustomizableOptionsSection.valuePrice}}" userInput="{{productOption2.price}}"/>
38+
</actionGroup>
4239

43-
40+
<!--Add a custom option of type "file" to a product-->
41+
<actionGroup name="AddProductCustomOptionFile">
42+
<arguments>
43+
<argument name="option" defaultValue="ProductOptionFile"/>
44+
</arguments>
45+
<conditionalClick selector="{{AdminProductCustomizableOptionsSection.customizableOptions}}" dependentSelector="{{AdminProductCustomizableOptionsSection.addOptionBtn}}" visible="false" stepKey="openCustomOptionSection"/>
46+
<click selector="{{AdminProductCustomizableOptionsSection.addOptionBtn}}" stepKey="clickAddOption"/>
47+
<waitForElementVisible selector="{{AdminProductCustomizableOptionsSection.lastOptionTitle}}" stepKey="waitForOption"/>
48+
<fillField selector="{{AdminProductCustomizableOptionsSection.lastOptionTitle}}" userInput="{{option.title}}" stepKey="fillTitle"/>
49+
<click selector="{{AdminProductCustomizableOptionsSection.lastOptionTypeParent}}" stepKey="openTypeSelect"/>
50+
<click selector="{{AdminProductCustomizableOptionsSection.optionType('File')}}" stepKey="selectTypeFile"/>
51+
<waitForElementVisible selector="{{AdminProductCustomizableOptionsSection.optionPrice}}" stepKey="waitForElements"/>
52+
<fillField selector="{{AdminProductCustomizableOptionsSection.optionPrice}}" userInput="{{option.price}}" stepKey="fillPrice"/>
53+
<selectOption selector="{{AdminProductCustomizableOptionsSection.optionPriceType}}" userInput="{{option.price_type}}" stepKey="selectPriceType"/>
54+
<fillField selector="{{AdminProductCustomizableOptionsSection.optionFileExtensions}}" userInput="{{option.file_extension}}" stepKey="fillCompatibleExtensions"/>
4455
</actionGroup>
4556

4657
</actionGroups>

app/code/Magento/Catalog/Test/Mftf/Section/AdminProductCustomizableOptionsSection.xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
1111
<section name="AdminProductCustomizableOptionsSection">
1212
<element name="checkIfCustomizableOptionsTabOpen" type="text" selector="//span[text()='Customizable Options']/parent::strong/parent::*[@data-state-collapsible='closed']"/>
13-
<element name="customezableOptions" type="text" selector="//strong[contains(@class, 'admin__collapsible-title')]/span[text()='Customizable Options']"/>
13+
<element name="customizableOptions" type="text" selector="//strong[contains(@class, 'admin__collapsible-title')]/span[text()='Customizable Options']"/>
1414
<element name="useDefaultOptionTitle" type="text" selector="[data-index='options'] tr.data-row [data-index='title'] [name^='options_use_default']"/>
1515
<element name="useDefaultOptionTitleByIndex" type="text" selector="[data-index='options'] [data-index='values'] tr[data-repeat-index='{{var1}}'] [name^='options_use_default']" parameterized="true"/>
1616
<element name="addOptionBtn" type="button" selector="button[data-index='button_add']"/>
@@ -20,7 +20,6 @@
2020
<element name="optionTypeTextField" type="button" selector=".admin__dynamic-rows[data-index='options'] .action-menu._active li li"/>
2121
<element name="maxCharactersInput" type="input" selector="input[name='product[options][0][max_characters]']"/>
2222

23-
2423
<element name="checkSelect" type="select" selector="//span[text()='{{var1}}']/parent::div/parent::div/parent::div//span[text()='Option Type']/parent::label/parent::div//div[@data-role='selected-option']" parameterized="true"/>
2524
<element name="checkDropDown" type="select" selector="//span[text()='{{var1}}']/parent::div/parent::div/parent::div//parent::label/parent::div//li[@class='admin__action-multiselect-menu-inner-item']//label[text()='Drop-down']" parameterized="true"/>
2625
<element name="clickAddValue" type="button" selector="//span[text()='{{var1}}']/parent::div/parent::div/parent::div//tfoot//button" parameterized="true"/>
@@ -38,5 +37,10 @@
3837
<element name="addValue" type="button" selector="//*[@data-index='custom_options']//*[@data-index='options']/tbody/tr[last()]//*[@data-action='add_new_row']" />
3938
<element name="valueTitle" type="input" selector="//*[@data-index='custom_options']//*[@data-index='options']/tbody/tr[last()]//*[contains(@class, 'admin__control-table')]//tbody/tr[last()]//*[@data-index='title']//input" />
4039
<element name="valuePrice" type="input" selector="//*[@data-index='custom_options']//*[@data-index='options']/tbody/tr[last()]//*[contains(@class, 'admin__control-table')]//tbody/tr[last()]//*[@data-index='price']//input" />
40+
41+
<element name="optionPrice" type="input" selector="//*[@data-index='custom_options']//*[@data-index='options']/tbody/tr[last()]//*[@name='product[options][0][price]']"/>
42+
<element name="optionPriceType" type="select" selector="//*[@data-index='custom_options']//*[@data-index='options']/tbody/tr[last()]//*[@name='product[options][0][price_type]']"/>
43+
<element name="optionSku" type="input" selector="//*[@data-index='custom_options']//*[@data-index='options']/tbody/tr[last()]//*[@name='product[options][0][sku]']"/>
44+
<element name="optionFileExtensions" type="input" selector="//*[@data-index='custom_options']//*[@data-index='options']/tbody/tr[last()]//*[@name='product[options][0][file_extension]']"/>
4145
</section>
4246
</sections>

app/code/Magento/Catalog/Test/Mftf/Section/StorefrontCategoryProductSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<element name="ProductImageByName" type="text" selector="//main//li[.//a[contains(text(), '{{var1}}')]]//img[@class='product-image-photo']" parameterized="true"/>
2424
<element name="ProductImageBySrc" type="text" selector=".products-grid img[src*='{{pattern}}']" parameterized="true"/>
2525
<element name="ProductInfoByName" type="text" selector="//main//li[.//a[contains(text(), '{{var1}}')]]//div[@class='product-item-info']" parameterized="true"/>
26+
<element name="ProductAddToCartByName" type="button" selector="//main//li[.//a[contains(text(), '{{var1}}')]]//a[contains(@class, 'tocart')]" parameterized="true"/>
2627
<element name="ProductAddToCompareByName" type="text" selector="//main//li[.//a[contains(text(), '{{var1}}')]]//a[contains(@class, 'tocompare')]" parameterized="true"/>
2728
<element name="ProductImageByNameAndSrc" type="text" selector="//main//li[.//a[contains(text(), '{{var1}}')]]//img[contains(@src, '{{src}}')]" parameterized="true"/>
2829
</section>

app/code/Magento/Catalog/Test/Mftf/Section/StorefrontProductPageSection.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
1111
<section name="StorefrontProductPageSection">
1212
<element name="qtyInput" type="button" selector="input.input-text.qty"/>
13-
<element name="addToCartBtn" type="button" selector="button.action.tocart.primary"/>
13+
<element name="addToCartBtn" type="button" selector="button.action.tocart.primary" timeout="30"/>
1414
<element name="successMsg" type="button" selector="div.message-success"/>
15+
<element name="alertMessage" type="text" selector=".page.messages [role=alert]"/>
16+
<element name="messagesBlock" type="text" selector=".page.messages"/>
1517
<element name="addToWishlist" type="button" selector="//a[@class='action towishlist']" timeout="30"/>
1618
<element name="customTextOptionInput" type="input" selector=".input-text.product-custom-option"/>
1719
<element name="charCounter" type="text" selector=".character-counter"/>

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@
6565
<fillField userInput="{{_defaultProduct.price}}" selector="{{AdminProductFormSection.productPrice}}" stepKey="fillPrice"/>
6666
<fillField userInput="{{_defaultProduct.quantity}}" selector="{{AdminProductFormSection.productQuantity}}" stepKey="fillQuantity"/>
6767

68-
<!--<click selector="{{AdminProductCustomizableOptionsSection.customezableOptions}}" stepKey="openCustomOptionsSection"/>-->
69-
<conditionalClick selector="{{AdminProductCustomizableOptionsSection.customezableOptions}}" dependentSelector="{{AdminProductCustomizableOptionsSection.checkIfCustomizableOptionsTabOpen}}" visible="true" stepKey="clickIfContentTabCloses2"/>
68+
<!--<click selector="{{AdminProductCustomizableOptionsSection.customizableOptions}}" stepKey="openCustomOptionsSection"/>-->
69+
<conditionalClick selector="{{AdminProductCustomizableOptionsSection.customizableOptions}}" dependentSelector="{{AdminProductCustomizableOptionsSection.checkIfCustomizableOptionsTabOpen}}" visible="true" stepKey="clickIfContentTabCloses2"/>
7070
<click selector="{{AdminProductCustomizableOptionsSection.addOptionBtn}}" stepKey="clickAddOption"/>
7171
<waitForPageLoad stepKey="waitAfterAddOption"/>
7272
<fillField selector="input[name='product[options][0][title]']" userInput="Radio Option" stepKey="fillOptionTitle"/>
@@ -98,7 +98,7 @@
9898
<waitForLoadingMaskToDisappear stepKey="waitForProductPagetoSaveAgain"/>
9999
<seeElement selector="{{AdminProductMessagesSection.successMessage}}" stepKey="seeSaveProductMessageAgain"/>
100100

101-
<click selector="{{AdminProductCustomizableOptionsSection.customezableOptions}}" stepKey="openCustomOptionsSection2"/>
101+
<click selector="{{AdminProductCustomizableOptionsSection.customizableOptions}}" stepKey="openCustomOptionsSection2"/>
102102
<seeNumberOfElements selector=".admin__dynamic-rows[data-index='values'] tr.data-row" userInput="3" stepKey="see4RowsOfOptions"/>
103103

104104
</test>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
-->
88

99
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10-
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd">
10+
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd">
1111
<test name="SimpleProductTwoCustomOptionsTest">
1212
<annotations>
1313
<features value="Catalog"/>
@@ -41,7 +41,7 @@
4141
</after>
4242

4343
<!-- opens the custom option panel and clicks add options -->
44-
<click stepKey="openCustomizableOptions" selector="{{AdminProductCustomizableOptionsSection.customezableOptions}}"/>
44+
<click stepKey="openCustomizableOptions" selector="{{AdminProductCustomizableOptionsSection.customizableOptions}}"/>
4545
<waitForPageLoad stepKey="waitForCustomOptionsOpen"/>
4646

4747
<!-- Create a custom option with 2 values -->

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777

7878
<!-- Update Product with Option Value DropDown 1-->
7979

80-
<conditionalClick selector="{{AdminProductCustomizableOptionsSection.customezableOptions}}" dependentSelector="{{AdminProductCustomizableOptionsSection.checkIfCustomizableOptionsTabOpen}}" visible="true" stepKey="clickIfContentTabCloses2"/>
80+
<conditionalClick selector="{{AdminProductCustomizableOptionsSection.customizableOptions}}" dependentSelector="{{AdminProductCustomizableOptionsSection.checkIfCustomizableOptionsTabOpen}}" visible="true" stepKey="clickIfContentTabCloses2"/>
8181
<click selector="{{AdminProductCustomizableOptionsSection.addOptionBtn}}" stepKey="checkAddOption1"/>
8282
<waitForPageLoad time="10" stepKey="waitForPageLoad7"/>
8383
<fillField selector="{{AdminProductCustomizableOptionsSection.fillOptionTitle('New Option')}}" userInput="Custom Options 1" stepKey="fillOptionTitle1"/>
@@ -104,7 +104,7 @@
104104
<!-- Open tab Customizable Options -->
105105

106106
<waitForPageLoad time="10" stepKey="waitForPageLoad2"/>
107-
<conditionalClick selector="{{AdminProductCustomizableOptionsSection.customezableOptions}}" dependentSelector="{{AdminProductCustomizableOptionsSection.checkIfCustomizableOptionsTabOpen}}" visible="true" stepKey="clickIfContentTabCloses3"/>
107+
<conditionalClick selector="{{AdminProductCustomizableOptionsSection.customizableOptions}}" dependentSelector="{{AdminProductCustomizableOptionsSection.checkIfCustomizableOptionsTabOpen}}" visible="true" stepKey="clickIfContentTabCloses3"/>
108108

109109
<!-- Update Option Customizable Options and Option Value 1-->
110110

@@ -266,7 +266,7 @@
266266
<!-- Open tab Customizable Options -->
267267

268268
<waitForPageLoad time="30" stepKey="waitForPageLoad9"/>
269-
<conditionalClick selector="{{AdminProductCustomizableOptionsSection.customezableOptions}}" dependentSelector="{{AdminProductCustomizableOptionsSection.checkIfCustomizableOptionsTabOpen}}" visible="true" stepKey="clickIfContentTabCloses4" />
269+
<conditionalClick selector="{{AdminProductCustomizableOptionsSection.customizableOptions}}" dependentSelector="{{AdminProductCustomizableOptionsSection.checkIfCustomizableOptionsTabOpen}}" visible="true" stepKey="clickIfContentTabCloses4" />
270270

271271
<!-- Update Option Customizable Options and Option Value 1-->
272272

app/code/Magento/Catalog/view/frontend/web/js/catalog-add-to-cart.js

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,23 @@ define([
4949
});
5050
},
5151

52+
/**
53+
* @private
54+
*/
55+
_redirect: function (url) {
56+
var urlParts, locationParts, forceReload;
57+
58+
urlParts = url.split('#');
59+
locationParts = window.location.href.split('#');
60+
forceReload = urlParts[0] === locationParts[0];
61+
62+
window.location.assign(url);
63+
64+
if (forceReload) {
65+
window.location.reload();
66+
}
67+
},
68+
5269
/**
5370
* @return {Boolean}
5471
*/
@@ -62,34 +79,28 @@ define([
6279
* @param {Object} form
6380
*/
6481
submitForm: function (form) {
65-
var addToCartButton, self = this;
66-
67-
if (form.has('input[type="file"]').length && form.find('input[type="file"]').val() !== '') {
68-
self.element.off('submit');
69-
// disable 'Add to Cart' button
70-
addToCartButton = $(form).find(this.options.addToCartButtonSelector);
71-
addToCartButton.prop('disabled', true);
72-
addToCartButton.addClass(this.options.addToCartButtonDisabledClass);
73-
form.submit();
74-
} else {
75-
self.ajaxSubmit(form);
76-
}
82+
this.ajaxSubmit(form);
7783
},
7884

7985
/**
8086
* @param {String} form
8187
*/
8288
ajaxSubmit: function (form) {
83-
var self = this;
89+
var self = this,
90+
formData;
8491

8592
$(self.options.minicartSelector).trigger('contentLoading');
8693
self.disableAddToCartButton(form);
94+
formData = new FormData(form[0]);
8795

8896
$.ajax({
8997
url: form.attr('action'),
90-
data: form.serialize(),
98+
data: formData,
9199
type: 'post',
92100
dataType: 'json',
101+
cache: false,
102+
contentType: false,
103+
processData: false,
93104

94105
/** @inheritdoc */
95106
beforeSend: function () {
@@ -125,7 +136,8 @@ define([
125136
parameters.push(eventData.redirectParameters.join('&'));
126137
res.backUrl = parameters.join('#');
127138
}
128-
window.location = res.backUrl;
139+
140+
self._redirect(res.backUrl);
129141

130142
return;
131143
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
11+
<section name="AdminDataGridHeaderSection">
12+
<element name="attributeCodeFilterInput" type="input" selector=".admin__data-grid-filters input[name='attribute_code']"/>
13+
</section>
14+
</sections>

app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -926,6 +926,8 @@ protected function _prepareProduct(\Magento\Framework\DataObject $buyRequest, $p
926926
return $result;
927927
}
928928
}
929+
} elseif (is_string($result)) {
930+
return __($result)->render();
929931
}
930932
}
931933

app/code/Magento/ConfigurableProduct/Test/Mftf/Section/AdminCreateProductConfigurationsPanelSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<element name="id" type="text" selector="//tr[contains(@data-repeat-index, '0')]/td[2]/div"/>
1919

2020
<element name="selectAll" type="button" selector=".action-select-all"/>
21+
<element name="selectAllByAttribute" type="button" selector="//div[@data-attribute-title='{{attr}}']//button[contains(@class, 'action-select-all')]" parameterized="true"/>
2122
<element name="createNewValue" type="input" selector=".action-create-new" timeout="30"/>
2223
<element name="attributeName" type="input" selector="li[data-attribute-option-title=''] .admin__field-create-new .admin__control-text"/>
2324
<element name="saveAttribute" type="button" selector="li[data-attribute-option-title=''] .action-save" timeout="30"/>

app/code/Magento/ConfigurableProduct/Test/Mftf/Section/AdminNewAttributePanelSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<element name="newAttributeIFrame" type="iframe" selector="create_new_attribute_container"/>
1515
<element name="defaultLabel" type="input" selector="input[name='frontend_label[0]']"/>
1616
<element name="inputType" type="select" selector="select[name='frontend_input']" timeout="30"/>
17+
<element name="valuesRequired" type="select" selector="select#is_required"/>
1718
<element name="addOption" type="button" selector="#add_new_option_button"/>
1819
<element name="isDefault" type="radio" selector="[data-role='options-container'] tr:nth-of-type({{row}}) input[name='default[]']" parameterized="true"/>
1920
<element name="optionAdminValue" type="input" selector="[data-role='options-container'] input[name='option[value][option_{{row}}][0]']" parameterized="true"/>

0 commit comments

Comments
 (0)