Skip to content

Commit 072f000

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-95426' into 2.2.7-develop-pr53
2 parents a330532 + 9a110d8 commit 072f000

File tree

15 files changed

+221
-114
lines changed

15 files changed

+221
-114
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,18 @@
2626
<waitForPageLoad stepKey="waitForPageLoadAfterDeleteAttribute"/>
2727
<see selector="{{AdminMessagesSection.success}}" userInput="You deleted the product attribute." stepKey="seeDeleteSuccessMessage"/>
2828
</actionGroup>
29+
<actionGroup name="navigateToCreatedProductAttribute">
30+
<arguments>
31+
<argument name="productAttribute"/>
32+
</arguments>
33+
<amOnPage url="{{AdminProductAttributeGridPage.url}}" stepKey="navigateToProductAttributeGrid"/>
34+
<waitForPageLoad stepKey="waitForAttributesGridPageLoad"/>
35+
<conditionalClick selector="{{AdminDataGridHeaderSection.clearFilters}}" dependentSelector="{{AdminDataGridHeaderSection.clearFilters}}" visible="true" stepKey="clearExistingFilters"/>
36+
<waitForPageLoad stepKey="waitForAttributesGridPageLoad1"/>
37+
<fillField selector="{{AdminProductAttributeGridSection.gridFilterAttributeCode}}"
38+
userInput="{{productAttribute.attribute_code}}" stepKey="setAttributeCode"/>
39+
<click selector="{{AdminDataGridHeaderSection.applyFilters}}" stepKey="searchForAttributeFromTheGrid"/>
40+
<click selector="{{AdminDataGridTableSection.row('1')}}" stepKey="clickOnAttributeRow"/>
41+
<waitForPageLoad stepKey="waitForAttributePageLoad" />
42+
</actionGroup>
2943
</actionGroups>

app/code/Magento/Catalog/Test/Mftf/Page/AdminProductAttributeEditPage.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,7 @@
1111
<page name="AdminProductAttributeEditPage" url="catalog/product_attribute/edit/" area="admin" module="Magento_Catalog">
1212
<section name="AdminProductAttributeEditSection"/>
1313
<section name="AdminConfirmationModalSection"/>
14+
<section name="AdminMainActionsSection"/>
15+
<section name="AdminMessagesSection"/>
1416
</page>
1517
</pages>

app/code/Magento/Catalog/Test/Mftf/Page/AdminProductAttributeFormPage.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@
1111
<section name="AttributePropertiesSection"/>
1212
<section name="StorefrontPropertiesSection"/>
1313
<section name="AdvancedAttributePropertiesSection"/>
14+
<section name="AdminAttributeOptionsSection"/>
1415
</page>
1516
</pages>

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,9 @@
2929
<element name="addToColumnOptions" type="select" selector="#is_used_in_grid"/>
3030
<element name="useInFilterOptions" type="select" selector="#is_filterable_in_grid"/>
3131
</section>
32+
<section name="AdminAttributeOptionsSection">
33+
<element name="addOption" type="button" selector="#add_new_option_button"/>
34+
<element name="nthOptionAdminLabel" type="input"
35+
selector="(//*[@id='manage-options-panel']//tr[{{var}}]//input[contains(@name, 'option[value]')])[1]" parameterized="true"/>
36+
</section>
3237
</sections>
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
9+
<test name="AdminCreateProductDropdownAttributeTest">
10+
<annotations>
11+
<features value="Catalog"/>
12+
<stories value="Create/configure Dropdown product attribute"/>
13+
<title value="Admin should be able to create dropdown product attribute"/>
14+
<description value="Admin should be able to create dropdown product attribute"/>
15+
<severity value="CRITICAL"/>
16+
<testCaseId value="MAGETWO-95868"/>
17+
<group value="Catalog"/>
18+
</annotations>
19+
<before>
20+
<actionGroup ref="LoginAsAdmin" stepKey="login"/>
21+
</before>
22+
<after>
23+
<!-- Remove attribute -->
24+
<actionGroup ref="deleteProductAttribute" stepKey="deleteAttribute">
25+
<argument name="ProductAttribute" value="productAttributeWithDropdownTwoOptions"/>
26+
</actionGroup>
27+
<actionGroup ref="logout" stepKey="logout"/>
28+
</after>
29+
30+
<amOnPage url="{{ProductAttributePage.url}}" stepKey="navigateToNewProductAttributePage"/>
31+
<waitForPageLoad stepKey="waitForPageLoad"/>
32+
33+
<!-- Set attribute properties -->
34+
<fillField selector="{{AttributePropertiesSection.defaultLabel}}"
35+
userInput="{{ProductAttributeFrontendLabel.label}}" stepKey="fillDefaultLabel"/>
36+
<selectOption selector="{{AttributePropertiesSection.inputType}}"
37+
userInput="{{productAttributeWithDropdownTwoOptions.frontend_input}}" stepKey="fillInputType"/>
38+
39+
<!-- Set advanced attribute properties -->
40+
<click selector="{{AdvancedAttributePropertiesSection.advancedAttributePropertiesSectionToggle}}"
41+
stepKey="showAdvancedAttributePropertiesSection"/>
42+
<waitForElementVisible selector="{{AdvancedAttributePropertiesSection.attributeCode}}"
43+
stepKey="waitForSlideOut"/>
44+
<fillField selector="{{AdvancedAttributePropertiesSection.attributeCode}}"
45+
userInput="{{productAttributeWithDropdownTwoOptions.attribute_code}}"
46+
stepKey="fillAttributeCode"/>
47+
48+
<!-- Add new attribute options -->
49+
<click selector="{{AdminAttributeOptionsSection.addOption}}" stepKey="clickAddOption1"/>
50+
<fillField selector="{{AdminAttributeOptionsSection.nthOptionAdminLabel('1')}}"
51+
userInput="Fish and Chips" stepKey="fillAdminValue1"/>
52+
53+
<click selector="{{AdminAttributeOptionsSection.addOption}}" stepKey="clickAddOption2"/>
54+
<fillField selector="{{AdminAttributeOptionsSection.nthOptionAdminLabel('2')}}"
55+
userInput="Fish &amp; Chips" stepKey="fillAdminValue2"/>
56+
57+
<!-- Save the new product attribute -->
58+
<click selector="{{AdminMainActionsSection.save}}" stepKey="clickSave1"/>
59+
<waitForElementVisible selector="{{AdminMessagesSection.successMessage}}"
60+
stepKey="waitForSuccessMessage"/>
61+
62+
<actionGroup ref="navigateToCreatedProductAttribute" stepKey="navigateToAttribute">
63+
<argument name="productAttribute" value="productAttributeWithDropdownTwoOptions"/>
64+
</actionGroup>
65+
<!-- Check attribute data -->
66+
<grabValueFrom selector="{{AdminAttributeOptionsSection.nthOptionAdminLabel('2')}}"
67+
stepKey="secondOptionAdminLabel"/>
68+
<assertEquals actual="$secondOptionAdminLabel" expected="'Fish &amp; Chips'"
69+
stepKey="assertSecondOption"/>
70+
</test>
71+
</tests>

app/code/Magento/Catalog/view/adminhtml/web/js/options.js

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -182,24 +182,16 @@ define([
182182
});
183183
}
184184
editForm.on('beforeSubmit', function () {
185-
var optionsValues = [],
186-
optionContainer = optionPanel.find('table tbody');
185+
var optionContainer = optionPanel.find('table tbody'),
186+
optionsValues;
187187

188188
if (optionPanel.hasClass(activePanelClass)) {
189-
optionContainer.find('input')
190-
.each(function () {
191-
if (this.disabled) {
192-
return;
193-
}
194-
195-
if (this.type === 'checkbox' || this.type === 'radio') {
196-
if (this.checked) {
197-
optionsValues.push(this.name + '=' + jQuery(this).val());
198-
}
199-
} else {
200-
optionsValues.push(this.name + '=' + jQuery(this).val());
201-
}
202-
});
189+
optionsValues = jQuery.map(
190+
optionContainer.find('tr'),
191+
function (row) {
192+
return jQuery(row).find('input, select, textarea').serialize();
193+
}
194+
);
203195
jQuery('<input>')
204196
.attr({
205197
type: 'hidden',

app/code/Magento/Swatches/Test/Mftf/ActionGroup/ColorPickerActionGroup.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@
1010
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd">
1111
<actionGroup name="setColorPickerValueByHex">
1212
<arguments>
13+
<argument name="nthColorPicker" type="string" defaultValue="1"/>
1314
<argument name="hexColor" type="string" defaultValue="e74c3c"/>
1415
</arguments>
1516
<!-- This 6x backspace stuff is some magic that is necessary to interact with this field correctly -->
16-
<pressKey selector="{{AdminColorPickerSection.hexByIndex}}"
17+
<pressKey selector="{{AdminColorPickerSection.hexByIndex(nthColorPicker)}}"
1718
parameterArray="[\Facebook\WebDriver\WebDriverKeys::BACKSPACE,\Facebook\WebDriver\WebDriverKeys::BACKSPACE,
1819
\Facebook\WebDriver\WebDriverKeys::BACKSPACE,\Facebook\WebDriver\WebDriverKeys::BACKSPACE,
1920
\Facebook\WebDriver\WebDriverKeys::BACKSPACE,\Facebook\WebDriver\WebDriverKeys::BACKSPACE,'{{hexColor}}']" stepKey="fillHex"/>
20-
<click selector="{{AdminColorPickerSection.submitByIndex}}" stepKey="submitColor"/>
21+
<click selector="{{AdminColorPickerSection.submitByIndex(nthColorPicker)}}" stepKey="submitColor"/>
2122
</actionGroup>
2223
<actionGroup name="openSwatchMenuByIndex">
2324
<arguments>

app/code/Magento/Swatches/Test/Mftf/Section/AdminColorPickerSection.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1010
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
1111
<section name="AdminColorPickerSection">
12-
<element name="hexByIndex" type="input" selector=".colorpicker_hex>input"/>
13-
<element name="submitByIndex" type="button" selector=".colorpicker_submit"/>
12+
<element name="hexByIndex" type="input" selector="//div[@class='colorpicker'][{{var}}]/div[@class='colorpicker_hex']/input" parameterized="true"/>
13+
<element name="submitByIndex" type="button" selector="//div[@class='colorpicker'][{{var}}]/div[@class='colorpicker_submit']" parameterized="true"/>
1414
</section>
1515
</sections>

app/code/Magento/Swatches/Test/Mftf/Section/AdminManageSwatchSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212
<element name="adminInputByIndex" type="input" selector="optionvisual[value][option_{{var}}][0]" parameterized="true"/>
1313
<element name="addSwatch" type="button" selector="#add_new_swatch_visual_option_button" timeout="30"/>
1414
<element name="chooseColorRow" type="button" selector="#swatch-visual-options-panel table tbody tr:nth-of-type({{var}}) .swatch_row_name.colorpicker_handler" parameterized="true"/>
15+
<element name="nthIsDefault" type="input" selector="(//input[@name='defaultvisual[]'])[{{var}}]" parameterized="true"/>
1516
</section>
1617
</sections>

app/code/Magento/Swatches/Test/Mftf/Test/AdminCreateVisualSwatchWithNonValidOptionsTest.xml

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,50 @@
6060
<scrollToTopOfPage stepKey="scrollToTop"/>
6161

6262
<!-- Save the new product attribute -->
63-
<click selector="{{AttributePropertiesSection.Save}}" stepKey="clickSave1"/>
63+
<click selector="{{AdminMainActionsSection.save}}" stepKey="clickSave1"/>
6464
<waitForElementVisible selector="{{AdminMessagesSection.error}}" stepKey="waitForError"/>
6565

6666
<!-- Fill options data -->
6767
<fillField selector="{{AdminManageSwatchSection.adminInputByIndex('0')}}"
6868
userInput="red" stepKey="fillAdmin"/>
6969

70+
<!-- Add 2 additional new swatch options -->
71+
<click selector="{{AdminManageSwatchSection.addSwatch}}" stepKey="clickAddSwatch1"/>
72+
<actionGroup ref="openSwatchMenuByIndex" stepKey="clickSwatch1">
73+
<argument name="index" value="1"/>
74+
</actionGroup>
75+
<click selector="{{AdminManageSwatchSection.chooseColorRow('2')}}" stepKey="clickChooseColor1"/>
76+
<actionGroup ref="setColorPickerValueByHex" stepKey="fillHex1">
77+
<argument name="nthColorPicker" value="2"/>
78+
<argument name="hexColor" value="00ff00"/>
79+
</actionGroup>
80+
<fillField selector="{{AdminManageSwatchSection.adminInputByIndex('1')}}"
81+
userInput="green" stepKey="fillAdmin1"/>
82+
83+
<click selector="{{AdminManageSwatchSection.addSwatch}}" stepKey="clickAddSwatch2"/>
84+
<actionGroup ref="openSwatchMenuByIndex" stepKey="clickSwatch2">
85+
<argument name="index" value="2"/>
86+
</actionGroup>
87+
<click selector="{{AdminManageSwatchSection.chooseColorRow('3')}}" stepKey="clickChooseColor2"/>
88+
<actionGroup ref="setColorPickerValueByHex" stepKey="fillHex2">
89+
<argument name="nthColorPicker" value="3"/>
90+
<argument name="hexColor" value="0000ff"/>
91+
</actionGroup>
92+
<fillField selector="{{AdminManageSwatchSection.adminInputByIndex('2')}}"
93+
userInput="blue" stepKey="fillAdmin2"/>
94+
95+
<!-- Mark second option as default -->
96+
<click selector="{{AdminManageSwatchSection.nthIsDefault('2')}}" stepKey="setSecondOptionAsDefault"/>
97+
7098
<!-- Save the new product attribute -->
71-
<click selector="{{AttributePropertiesSection.Save}}" stepKey="clickSave2"/>
99+
<click selector="{{AdminMainActionsSection.save}}" stepKey="clickSave2"/>
72100
<waitForElementVisible selector="{{AdminMessagesSection.successMessage}}"
73101
stepKey="waitForSuccessMessage"/>
102+
103+
<actionGroup ref="navigateToCreatedProductAttribute" stepKey="navigateToAttribute">
104+
<argument name="productAttribute" value="VisualSwatchAttribute"/>
105+
</actionGroup>
106+
<!-- Check attribute data -->
107+
<seeCheckboxIsChecked selector="{{AdminManageSwatchSection.nthIsDefault('2')}}" stepKey="checkDefaultOption"/>
74108
</test>
75109
</tests>

0 commit comments

Comments
 (0)