Skip to content

Commit 911a6e6

Browse files
authored
Merge pull request #3677 from magento-epam/EPAM-PR-22
Fixed: MAGETWO-94556 Undefined variables during product save MAGETWO-96106 CMS Block status is not staged
2 parents cfc6ea2 + d0965c7 commit 911a6e6

File tree

11 files changed

+224
-7
lines changed

11 files changed

+224
-7
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010
<section name="DropdownAttributeOptionsSection">
1111
<element name="nthOptionAdminLabel" type="input"
1212
selector="(//*[@id='manage-options-panel']//tr[{{var}}]//input[contains(@name, 'option[value]')])[1]" parameterized="true"/>
13+
<element name="deleteButton" type="button" selector="(//td[@class='col-delete'])[1]" timeout="30"/>
1314
</section>
1415
</sections>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
11+
<entity name="Sales25offBlock" type="block">
12+
<data key="title" unique="suffix">Sales25off</data>
13+
<data key="identifier" unique="suffix">Sales25off</data>
14+
<data key="store_id">All Store Views</data>
15+
<data key="content">sales25off everything!</data>
16+
<data key="is_active">0</data>
17+
</entity>
18+
</entities>
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+
<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd">
11+
<page name="AdminEditBlockPage" url="cms/block/edit/block_id" area="admin" module="Magento_Cms">
12+
<section name="AdminUpdateBlockSection"/>
13+
</page>
14+
</pages>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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="urn:magento:mftf:Page/etc/SectionObject.xsd">
11+
<section name="AdminBlockGridSection">
12+
<element name="search" type="input" selector="//input[@placeholder='Search by keyword']"/>
13+
<element name="searchButton" type="button" selector="//div[@class='data-grid-search-control-wrap']//label[@class='data-grid-search-label']/following-sibling::button[@class='action-submit']"/>
14+
<element name="checkbox" type="checkbox" selector="//label[@class='data-grid-checkbox-cell-inner']//input[@class='admin__control-checkbox']"/>
15+
<element name="select" type="select" selector="//tr[@class='data-row']//button[@class='action-select']"/>
16+
<element name="editInSelect" type="text" selector="//a[contains(text(), 'Edit')]"/>
17+
</section>
18+
</sections>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<element name="currentVariationsQuantityCells" type="textarea" selector=".admin__control-fields[data-index='quantity_container']"/>
1919
<element name="currentVariationsAttributesCells" type="textarea" selector=".admin__control-fields[data-index='attributes']"/>
2020
<element name="currentVariationsStatusCells" type="textarea" selector="._no-header[data-index='status']"/>
21+
<element name="firstSKUInConfigurableProductsGrid" type="input" selector="//input[@name='configurable-matrix[0][sku]']"/>
2122
<element name="actionsBtn" type="button" selector="(//button[@class='action-select']/span[contains(text(), 'Select')])[{{var1}}]" parameterized="true"/>
2223
<element name="removeProductBtn" type="button" selector="//a[text()='Remove Product']"/>
2324
<element name="disableProductBtn" type="button" selector="//a[text()='Disable Product']"/>

app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductCreateTest.xml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,71 @@
6868
<see selector="{{StorefrontProductInfoMainSection.productAttributeOptions1}}" userInput="{{colorProductAttribute2.name}}" stepKey="seeInDropDown2"/>
6969
<see selector="{{StorefrontProductInfoMainSection.productAttributeOptions1}}" userInput="{{colorProductAttribute3.name}}" stepKey="seeInDropDown3"/>
7070
</test>
71+
72+
<test name="AdminCreateConfigurableProductAfterGettingIncorrectSKUMessageTest">
73+
<annotations>
74+
<features value="ConfigurableProduct"/>
75+
<stories value="Create, Read, Update, Delete"/>
76+
<title value="admin should be able to create a configurable product after incorrect sku"/>
77+
<description value="admin should be able to create a configurable product after incorrect sku"/>
78+
<severity value="MAJOR"/>
79+
<testCaseId value="MAGETWO-96365"/>
80+
<useCaseId value="MAGETWO-94556"/>
81+
<group value="ConfigurableProduct"/>
82+
</annotations>
83+
84+
<before>
85+
<createData entity="ApiCategory" stepKey="createCategory"/>
86+
<createData entity="ApiConfigurableProduct" stepKey="createConfigProduct">
87+
<requiredEntity createDataKey="createCategory"/>
88+
</createData>
89+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
90+
</before>
91+
<after>
92+
<deleteData createDataKey="createConfigProduct" stepKey="deleteConfigProduct"/>
93+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
94+
<actionGroup ref="logout" stepKey="logout"/>
95+
</after>
96+
97+
<amOnPage url="{{AdminProductEditPage.url($$createConfigProduct.id$$)}}" stepKey="goToEditPage"/>
98+
<waitForPageLoad stepKey="waitForProductPage"/>
99+
<conditionalClick selector="{{AdminProductFormConfigurationsSection.sectionHeader}}" dependentSelector="{{AdminProductFormConfigurationsSection.createConfigurations}}" visible="false" stepKey="openConfigurationSection"/>
100+
<click selector="{{AdminProductFormConfigurationsSection.createConfigurations}}" stepKey="openConfigurationPane"/>
101+
<click selector="{{AdminCreateProductConfigurationsPanel.filters}}" stepKey="clickFilters"/>
102+
<fillField selector="{{AdminCreateProductConfigurationsPanel.attributeCode}}" userInput="color" stepKey="fillFilterAttributeCodeField"/>
103+
<click selector="{{AdminCreateProductConfigurationsPanel.applyFilters}}" stepKey="clickApplyFiltersButton"/>
104+
<click selector="{{AdminCreateProductConfigurationsPanel.firstCheckbox}}" stepKey="clickOnFirstCheckbox"/>
105+
<click selector="{{AdminCreateProductConfigurationsPanel.next}}" stepKey="clickOnNextButton1"/>
106+
<click selector="{{AdminCreateProductConfigurationsPanel.createNewValue}}" stepKey="clickOnCreateNewValue1"/>
107+
<fillField userInput="{{colorProductAttribute2.name}}" selector="{{AdminCreateProductConfigurationsPanel.attributeName}}" stepKey="fillFieldForNewAttribute1"/>
108+
<click selector="{{AdminCreateProductConfigurationsPanel.saveAttribute}}" stepKey="clickOnSaveNewAttribute1"/>
109+
<click selector="{{AdminCreateProductConfigurationsPanel.next}}" stepKey="clickOnNextButton2"/>
110+
<click selector="{{AdminCreateProductConfigurationsPanel.next}}" stepKey="clickOnNextButton3"/>
111+
<click selector="{{ConfigurableProductSection.generateConfigure}}" stepKey="generateConfigure"/>
112+
<waitForPageLoad stepKey="waitForGenerateConfigure"/>
113+
<grabValueFrom selector="{{AdminProductFormConfigurationsSection.firstSKUInConfigurableProductsGrid}}" stepKey="grabTextFromContent"/>
114+
<fillField stepKey="fillMoreThan64Symbols" selector="{{AdminProductFormConfigurationsSection.firstSKUInConfigurableProductsGrid}}" userInput="01234567890123456789012345678901234567890123456789012345678901234"/>
115+
<click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="saveProduct1"/>
116+
<conditionalClick selector="{{AdminChooseAffectedAttributeSetPopup.closePopUp}}" dependentSelector="{{AdminChooseAffectedAttributeSetPopup.closePopUp}}" visible="true" stepKey="clickOnCloseInPopup"/>
117+
<see stepKey="seeErrorMessage" userInput="Please enter less or equal than 64 symbols."/>
118+
<fillField stepKey="fillCorrectSKU" selector="{{AdminProductFormConfigurationsSection.firstSKUInConfigurableProductsGrid}}" userInput="$grabTextFromContent"/>
119+
<click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="saveProduct2"/>
120+
<conditionalClick selector="{{AdminChooseAffectedAttributeSetPopup.confirm}}" dependentSelector="{{AdminChooseAffectedAttributeSetPopup.confirm}}" visible="true" stepKey="clickOnConfirmInPopup"/>
121+
<see userInput="You saved the product." stepKey="seeSaveConfirmation"/>
122+
<amOnPage url="{{AdminProductAttributeGridPage.url}}" stepKey="goToProductAttributes"/>
123+
<waitForPageLoad stepKey="waitForProductAttributes"/>
124+
<click selector="{{AdminProductAttributeGridSection.ResetFilter}}" stepKey="resetFiltersOnGrid1"/>
125+
<fillField selector="{{AdminProductAttributeGridSection.FilterByAttributeCode}}" userInput="color" stepKey="fillFilter"/>
126+
<click selector="{{AdminProductAttributeGridSection.Search}}" stepKey="clickSearch"/>
127+
<click selector="{{AdminProductAttributeGridSection.AttributeCode('color')}}" stepKey="clickRowToEdit"/>
128+
<click selector="{{DropdownAttributeOptionsSection.deleteButton(1)}}" stepKey="deleteOption"/>
129+
<click selector="{{AttributePropertiesSection.Save}}" stepKey="saveAttribute"/>
130+
<click selector="{{AdminProductAttributeGridSection.ResetFilter}}" stepKey="resetFiltersOnGrid2"/>
131+
<actionGroup stepKey="deleteProduct1" ref="deleteProductBySku">
132+
<argument name="sku" value="$grabTextFromContent"/>
133+
</actionGroup>
134+
<amOnPage url="{{AdminProductIndexPage.url}}" stepKey="visitAdminProductPage"/>
135+
<waitForPageLoad time="60" stepKey="waitForPageLoadInitial"/>
136+
<conditionalClick selector="{{AdminProductGridFilterSection.clearFilters}}" dependentSelector="{{AdminProductGridFilterSection.clearFilters}}" visible="true" stepKey="clickClearFiltersInitial"/>
137+
</test>
71138
</tests>

app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,9 @@ define([
393393
this.formSaveParams = arguments;
394394
this.attributeSetHandlerModal().openModal();
395395
} else {
396+
if (this.validateForm(this.formElement())) {
397+
this.clearOutdatedData();
398+
}
396399
this.formElement().save(arguments[0], arguments[1]);
397400

398401
if (this.formElement().source.get('params.invalid')) {
@@ -401,6 +404,17 @@ define([
401404
}
402405
},
403406

407+
/**
408+
* @param {Object} formElement
409+
*
410+
* Validates each form element and returns true, if all elements are valid.
411+
*/
412+
validateForm: function (formElement) {
413+
formElement.validate();
414+
415+
return !formElement.additionalInvalid && !formElement.source.get('params.invalid');
416+
},
417+
404418
/**
405419
* Serialize data for specific form fields
406420
*
@@ -418,12 +432,27 @@ define([
418432
if (this.source.data['configurable-matrix']) {
419433
this.source.data['configurable-matrix-serialized'] =
420434
JSON.stringify(this.source.data['configurable-matrix']);
421-
delete this.source.data['configurable-matrix'];
422435
}
423436

424437
if (this.source.data['associated_product_ids']) {
425438
this.source.data['associated_product_ids_serialized'] =
426439
JSON.stringify(this.source.data['associated_product_ids']);
440+
}
441+
},
442+
443+
/**
444+
* Clear outdated data for specific form fields
445+
*
446+
* Outdated fields:
447+
* - configurable-matrix;
448+
* - associated_product_ids.
449+
*/
450+
clearOutdatedData: function () {
451+
if (this.source.data['configurable-matrix']) {
452+
delete this.source.data['configurable-matrix'];
453+
}
454+
455+
if (this.source.data['associated_product_ids']) {
427456
delete this.source.data['associated_product_ids'];
428457
}
429458
},
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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="AdminCreateWidgetWithBlockActionGroup">
11+
<arguments>
12+
<argument name="widget"/>
13+
<argument name="block" type="string"/>
14+
</arguments>
15+
<amOnPage url="{{AdminNewWidgetPage.url}}" stepKey="createWidgetPage"/>
16+
<selectOption selector="{{AdminNewWidgetSection.widgetType}}" userInput="{{widget.type}}" stepKey="selectWidgetType"/>
17+
<selectOption selector="{{AdminNewWidgetSection.widgetDesignTheme}}" userInput="{{widget.designTheme}}" stepKey="selectWidgetDesignTheme"/>
18+
<click selector="{{AdminNewWidgetSection.continue}}" stepKey="continue"/>
19+
<waitForElement selector="{{AdminNewWidgetSection.widgetTitle}}" time="30" stepKey="waitForElement"/>
20+
<fillField selector="{{AdminNewWidgetSection.widgetTitle}}" userInput="{{widget.name}}" stepKey="fillWidgetTitle"/>
21+
<selectOption selector="{{AdminNewWidgetSection.widgetStoreIds}}" userInput="{{widget.store_id}}" stepKey="selectWidgetStoreView"/>
22+
<click selector="{{AdminNewWidgetSection.addLayoutUpdate}}" stepKey="clickAddLayoutUpdate"/>
23+
<waitForPageLoad stepKey="waitForLoad1"/>
24+
<scrollTo selector="{{AdminNewWidgetSection.selectDisplayOn}}" stepKey="scrollToElement" />
25+
<selectOption selector="{{AdminNewWidgetSection.selectDisplayOn}}" userInput="{{widget.display}}" stepKey="selectWidgetDisplayOn"/>
26+
<waitForElement selector="{{AdminNewWidgetSection.selectContainer}}" time="30" stepKey="waitForContainer"/>
27+
<selectOption selector="{{AdminNewWidgetSection.selectContainer}}" userInput="{{widget.container}}" stepKey="selectWidgetContainer"/>
28+
<scrollToTopOfPage stepKey="scrollToAddresses"/>
29+
<waitForAjaxLoad stepKey="waitForAjaxLoad1"/>
30+
<click selector="{{AdminNewWidgetSection.widgetOptions}}" stepKey="goToWidgetOptions"/>
31+
<waitForElement selector="{{AdminNewWidgetSection.widgetSelectBlock}}" time="60" stepKey="waitForSelectBlock"/>
32+
<click selector="{{AdminNewWidgetSection.widgetSelectBlock}}" stepKey="openSelectBlock"/>
33+
<waitForPageLoad stepKey="waitForLoadBlocks"/>
34+
<selectOption selector="{{AdminNewWidgetSection.blockStatus}}" userInput="Disable" stepKey="chooseStatus"/>
35+
<fillField selector="{{AdminNewWidgetSection.selectBlockTitle}}" userInput="{{block}}" stepKey="fillBlockTitle"/>
36+
<click selector="{{AdminNewWidgetSection.searchBlock}}" stepKey="searchBlock"/>
37+
<waitForAjaxLoad stepKey="waitForAjaxLoad"/>
38+
<click selector="{{AdminNewWidgetSection.searchedBlock}}" stepKey="clickSearchedBlock"/>
39+
<waitForPageLoad stepKey="wait"/>
40+
<click selector="{{AdminNewWidgetSection.saveWidget}}" stepKey="saveWidget"/>
41+
<waitForPageLoad stepKey="waitForSaving"/>
42+
<see userInput="The widget instance has been saved." stepKey="seeSuccessMessage"/>
43+
</actionGroup>
44+
</actionGroups>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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+
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
11+
<entity name="WidgetWithBlock" type="widget">
12+
<data key="type">CMS Static Block</data>
13+
<data key="designTheme">Magento Luma</data>
14+
<data key="name" unique="suffix">testName</data>
15+
<data key="store_id">All Store Views</data>
16+
<data key="display">All Pages</data>
17+
<data key="container">Page Top</data>
18+
</entity>
19+
</entities>

app/code/Magento/Widget/Test/Mftf/Section/AdminNewWidgetSection.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@
2525
<element name="applyParameter" type="button" selector=".rule-param-apply"/>
2626
<element name="openChooser" type="button" selector=".rule-chooser-trigger"/>
2727
<element name="selectAll" type="checkbox" selector=".admin__control-checkbox"/>
28+
<element name="widgetSelectBlock" type="button" selector="//button[@class='action-default scalable btn-chooser']"/>
29+
<element name="selectBlockTitle" type="input" selector="//input[@name='chooser_title']"/>
30+
<element name="searchBlock" type="button" selector="//div[@class='admin__filter-actions']/button[@title='Search']"/>
31+
<element name="blockStatus" type="select" selector="//select[@name='chooser_is_active']"/>
32+
<element name="searchedBlock" type="button" selector="//*[@class='magento-message']//tbody/tr/td[1]"/>
33+
<element name="saveWidget" type="select" selector="#save"/>
2834
<element name="displayMode" type="select" selector="select[id*='display_mode']"/>
2935
<element name="restrictTypes" type="select" selector="select[id*='types']"/>
3036
<element name="saveAndContinue" type="button" selector="#save_and_edit_button" timeout="30"/>

dev/tests/js/jasmine/tests/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ define([
4646

4747
variation.serializeData();
4848

49-
expect(variation.source.data['configurable-matrix']).toBeUndefined();
50-
expect(variation.source.data['associated_product_ids']).toBeUndefined();
49+
expect(variation.source.data['configurable-matrix']).toEqual(matrix);
50+
expect(variation.source.data['associated_product_ids']).toEqual(ids);
5151
expect(variation.source.data['configurable-matrix-serialized']).toEqual(resultMatrix);
5252
expect(variation.source.data['associated_product_ids_serialized']).toEqual(resultIds);
5353
});
@@ -112,8 +112,8 @@ define([
112112
variation.source.data['associated_product_ids_serialized'] = JSON.stringify(['some old data']);
113113
variation.serializeData();
114114

115-
expect(variation.source.data['configurable-matrix']).toBeUndefined();
116-
expect(variation.source.data['associated_product_ids']).toBeUndefined();
115+
expect(variation.source.data['configurable-matrix']).toEqual(matrix);
116+
expect(variation.source.data['associated_product_ids']).toEqual(ids);
117117
expect(variation.source.data['configurable-matrix-serialized']).toEqual(resultMatrix);
118118
expect(variation.source.data['associated_product_ids_serialized']).toEqual(resultIds);
119119
});
@@ -164,8 +164,8 @@ define([
164164

165165
variation.serializeData();
166166

167-
expect(variation.source.data['configurable-matrix']).toBeUndefined();
168-
expect(variation.source.data['associated_product_ids']).toBeUndefined();
167+
expect(variation.source.data['configurable-matrix']).toEqual(matrix);
168+
expect(variation.source.data['associated_product_ids']).toEqual(ids);
169169
expect(variation.source.data['configurable-matrix-serialized']).toEqual(resultMatrix);
170170
expect(variation.source.data['associated_product_ids_serialized']).toEqual(resultIds);
171171

0 commit comments

Comments
 (0)