Skip to content

Commit 5e38f1d

Browse files
committed
MAGETWO-95752: Unable to create Configurations for Configurable Products
1 parent 401203a commit 5e38f1d

File tree

6 files changed

+142
-5
lines changed

6 files changed

+142
-5
lines changed

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

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

99
<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">
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
1111
<!--Filter the product grid by new from date filter-->
1212
<actionGroup name="filterProductGridBySetNewFromDate">
1313
<conditionalClick selector="{{AdminProductGridFilterSection.clearFilters}}" dependentSelector="{{AdminProductGridFilterSection.clearFilters}}" visible="true" stepKey="clickClearFilters"/>
@@ -33,6 +33,7 @@
3333
<actionGroup name="deleteProductUsingProductGrid">
3434
<arguments>
3535
<argument name="product"/>
36+
<argument name="productCount" type="string" defaultValue="1"/>
3637
</arguments>
3738
<!--TODO use other action group for filtering grid when MQE-539 is implemented -->
3839
<amOnPage url="{{AdminProductIndexPage.url}}" stepKey="visitAdminProductPage"/>
@@ -48,7 +49,7 @@
4849
<click selector="{{AdminProductGridSection.bulkActionOption('Delete')}}" stepKey="clickDeleteAction"/>
4950
<waitForElementVisible selector="{{AdminProductGridConfirmActionSection.title}}" stepKey="waitForConfirmModal"/>
5051
<click selector="{{AdminProductGridConfirmActionSection.ok}}" stepKey="confirmProductDelete"/>
51-
<see selector="{{AdminMessagesSection.success}}" userInput="A total of 1 record(s) have been deleted." stepKey="seeSuccessMessage"/>
52+
<see selector="{{AdminMessagesSection.success}}" userInput="A total of {{productCount}} record(s) have been deleted." stepKey="seeSuccessMessage"/>
5253
<conditionalClick selector="{{AdminProductGridFilterSection.clearFilters}}" dependentSelector="{{AdminProductGridFilterSection.clearFilters}}" visible="true" stepKey="clickClearFiltersInitial2"/>
5354
</actionGroup>
5455

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
-->
88

99
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10-
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/DataGenerator/etc/dataProfileSchema.xsd">
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/dataProfileSchema.xsd">
1111
<entity name="colorProductAttribute" type="product_attribute">
1212
<data key="default_label" unique="suffix">Color</data>
1313
<data key="attribute_quantity">1</data>
14+
<data key="input_type">Dropdown</data>
1415
</entity>
1516
<entity name="colorProductAttribute1" type="product_attribute">
1617
<data key="name" unique="suffix">White</data>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,5 +188,6 @@
188188
</section>
189189
<section name="AdminChooseAffectedAttributeSetPopup">
190190
<element name="confirm" type="button" selector="button[data-index='confirm_button']" timeout="30"/>
191+
<element name="closePopUp" type="button" selector="//*[contains(@class,'product_form_product_form_configurable_attribute_set')]//button[@data-role='closeBtn']" timeout="30"/>
191192
</section>
192193
</sections>

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
-->
88

99
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10-
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
1111
<section name="AdminProductFormConfigurationsSection">
1212
<element name="sectionHeader" type="text" selector=".admin__collapsible-block-wrapper[data-index='configurable']"/>
1313
<element name="createConfigurations" type="button" selector="button[data-index='create_configurable_products_button']" timeout="30"/>
@@ -22,5 +22,7 @@
2222
<element name="removeProductBtn" type="button" selector="//a[text()='Remove Product']"/>
2323
<element name="disableProductBtn" type="button" selector="//a[text()='Disable Product']"/>
2424
<element name="enableProductBtn" type="button" selector="//a[text()='Enable Product']"/>
25+
<element name="confProductSku" type="input" selector="//*[@name='configurable-matrix[{{arg}}][sku]']" parameterized="true"/>
26+
<element name="confProductSkuMessage" type="text" selector="//*[@name='configurable-matrix[{{arg}}][sku]']/following-sibling::label" parameterized="true"/>
2527
</section>
2628
</sections>
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
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="AdminCheckValidatorConfigurableProductTest">
12+
<annotations>
13+
<features value="ConfigurableProduct"/>
14+
<stories value="Create a Configurable Product via the Admin"/>
15+
<title value="Check that validator works correctly when creating Configurations for Configurable Products"/>
16+
<description value="Verify validator works correctly for Configurable Products"/>
17+
<severity value="MAJOR"/>
18+
<testCaseId value="MC-13719"/>
19+
<group value="configurableProduct"/>
20+
</annotations>
21+
22+
<before>
23+
<!--Login as admin-->
24+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
25+
<!--Create Category-->
26+
<createData entity="ApiCategory" stepKey="createCategory"/>
27+
<!--Create Configurable product-->
28+
<createData entity="ApiConfigurableProduct" stepKey="createConfigProduct">
29+
<requiredEntity createDataKey="createCategory"/>
30+
</createData>
31+
</before>
32+
33+
<after>
34+
<!--Delete created data-->
35+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
36+
<actionGroup ref="deleteProductUsingProductGrid" stepKey="deleteProduct">
37+
<argument name="product" value="ApiConfigurableProduct"/>
38+
<argument name="productCount" value="2"/>
39+
</actionGroup>
40+
41+
<amOnPage url="{{AdminProductIndexPage.url}}" stepKey="openAdminProductPage"/>
42+
<actionGroup ref="clearFiltersAdminDataGrid" stepKey="resetProductsFilter" />
43+
44+
<!-- Remove attribute -->
45+
<actionGroup ref="deleteProductAttribute" stepKey="deleteAttribute">
46+
<argument name="ProductAttribute" value="productAttributeWithDropdownTwoOptions"/>
47+
</actionGroup>
48+
<amOnPage url="{{AdminProductAttributeGridPage.url}}" stepKey="goToProductAttributesGridPage"/>
49+
<actionGroup ref="clearFiltersAdminDataGrid" stepKey="resetAttributesFilter" />
50+
<actionGroup ref="logout" stepKey="logout"/>
51+
</after>
52+
53+
<!-- Find the product that we just created using the product grid -->
54+
<amOnPage url="{{AdminProductIndexPage.url}}" stepKey="visitAdminProductPage"/>
55+
<actionGroup ref="clearFiltersAdminDataGrid" stepKey="clearProductsFilter" />
56+
<actionGroup ref="filterProductGridBySku" stepKey="findCreatedProduct">
57+
<argument name="product" value="ApiConfigurableProduct"/>
58+
</actionGroup>
59+
<waitForPageLoad stepKey="waitForProductFilterLoad"/>
60+
<click selector="{{AdminProductGridSection.firstRow}}" stepKey="clickOnProduct"/>
61+
<waitForPageLoad stepKey="waitForProductPageLoad"/>
62+
63+
<!-- Create configurations based off the Text Swatch we created earlier -->
64+
<click selector="{{AdminProductFormConfigurationsSection.createConfigurations}}" stepKey="clickCreateConfigurations"/>
65+
66+
<!--Create new attribute-->
67+
<waitForElementVisible selector="{{AdminCreateProductConfigurationsPanel.createNewAttribute}}" stepKey="waitForNewAttributePageOpened"/>
68+
<click selector="{{AdminCreateProductConfigurationsPanel.createNewAttribute}}" stepKey="clickCreateNewAttribute"/>
69+
<switchToIFrame selector="{{AdminNewAttributePanelSection.newAttributeIFrame}}" stepKey="enterAttributePanelIFrame"/>
70+
<waitForElementVisible selector="{{AdminNewAttributePanel.defaultLabel}}" time="30" stepKey="waitForIframeLoad"/>
71+
<fillField selector="{{AdminNewAttributePanel.defaultLabel}}" userInput="{{productAttributeWithDropdownTwoOptions.attribute_code}}" stepKey="fillDefaultLabel"/>
72+
<selectOption selector="{{AdminNewAttributePanelSection.inputType}}" userInput="{{colorProductAttribute.input_type}}" stepKey="selectAttributeInputType"/>
73+
<!--Add option to attribute-->
74+
<click selector="{{AdminNewAttributePanelSection.addOption}}" stepKey="clickAddOption"/>
75+
<waitForElementVisible selector="{{AdminNewAttributePanelSection.isDefault('1')}}" time="30" stepKey="waitForOptionRow"/>
76+
<fillField selector="{{AdminNewAttributePanelSection.optionAdminValue('0')}}" userInput="ThisIsLongNameNameLengthMoreThanSixtyFourThisIsLongNameNameLength" stepKey="fillAdminLabel"/>
77+
<fillField selector="{{AdminNewAttributePanelSection.optionDefaultStoreValue('0')}}" userInput="{{colorProductAttribute1.name}}" stepKey="fillDefaultLabel1"/>
78+
79+
<!--Save attribute-->
80+
<click selector="{{AdminNewAttributePanelSection.saveAttribute}}" stepKey="clickOnNewAttributePanel"/>
81+
<waitForPageLoad stepKey="waitForSaveAttribute"/>
82+
<switchToIFrame stepKey="switchOutOfIFrame"/>
83+
84+
<!--Find attribute in grid and select-->
85+
<conditionalClick selector="{{AdminDataGridHeaderSection.clearFilters}}" dependentSelector="{{AdminDataGridHeaderSection.clearFilters}}" visible="true" stepKey="clearExistingFilters"/>
86+
<click selector="{{AdminDataGridHeaderSection.filters}}" stepKey="clickOnFilters"/>
87+
<fillField selector="{{AdminProductAttributeGridSection.attributeCodeFilterInput}}" userInput="{{productAttributeWithDropdownTwoOptions.attribute_code}}" stepKey="fillFilterAttributeCodeField"/>
88+
<click selector="{{AdminDataGridHeaderSection.applyFilters}}" stepKey="clickApplyFiltersButton"/>
89+
<click selector="{{AdminDataGridTableSection.rowCheckbox('1')}}" stepKey="clickOnFirstCheckbox"/>
90+
<click selector="{{AdminCreateProductConfigurationsPanel.next}}" stepKey="clickNextStep"/>
91+
<waitForElementVisible selector="{{AdminCreateProductConfigurationsPanelSection.selectAllByAttribute(productAttributeWithDropdownTwoOptions.attribute_code)}}" stepKey="waitForNextPageOpened"/>
92+
<click selector="{{AdminCreateProductConfigurationsPanelSection.selectAllByAttribute(productAttributeWithDropdownTwoOptions.attribute_code)}}" stepKey="clickSelectAll"/>
93+
<click selector="{{AdminCreateProductConfigurationsPanel.next}}" stepKey="clickNextStep1"/>
94+
<waitForElementVisible selector="{{AdminCreateProductConfigurationsPanel.applySinglePriceToAllSkus}}" stepKey="waitForNextPageOpened1"/>
95+
<click selector="{{AdminCreateProductConfigurationsPanel.applySinglePriceToAllSkus}}" stepKey="clickOnApplySinglePriceToAllSkus"/>
96+
<fillField selector="{{AdminCreateProductConfigurationsPanel.singlePrice}}" userInput="10" stepKey="enterAttributePrice"/>
97+
<click selector="{{AdminCreateProductConfigurationsPanel.applySingleQuantityToEachSkus}}" stepKey="clickOnApplySingleQuantityToEachSku"/>
98+
<fillField selector="{{AdminCreateProductConfigurationsPanel.quantity}}" userInput="100" stepKey="enterAttributeQuantity"/>
99+
<click selector="{{AdminCreateProductConfigurationsPanel.next}}" stepKey="clickNextStep2"/>
100+
<waitForElementVisible selector="{{AdminCreateProductConfigurationsPanel.next}}" stepKey="waitForNextPageOpened2"/>
101+
<click selector="{{AdminCreateProductConfigurationsPanel.next}}" stepKey="generateProducts"/>
102+
<waitForElementVisible selector="{{AdminProductFormActionSection.saveButton}}" stepKey="waitForSaveButtonVisible"/>
103+
<click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="saveProduct"/>
104+
<waitForElementVisible selector="{{AdminChooseAffectedAttributeSetPopup.confirm}}" stepKey="waitForPopUpVisible"/>
105+
<click selector="{{AdminChooseAffectedAttributeSetPopup.confirm}}" stepKey="clickOnConfirmInPopup"/>
106+
<dontSeeElement selector="{{AdminMessagesSection.success}}" stepKey="dontSeeSaveProductMessage"/>
107+
108+
<!--Close modal window-->
109+
<click selector="{{AdminChooseAffectedAttributeSetPopup.closePopUp}}" stepKey="clickOnClosePopup"/>
110+
<waitForElementNotVisible selector="{{AdminChooseAffectedAttributeSetPopup.closePopUp}}" stepKey="waitForDialogClosed"/>
111+
112+
<!--See that validation message is shown under the fields-->
113+
<scrollTo selector="{{AdminProductFormConfigurationsSection.currentVariationsSkuCells}}" stepKey="scrollTConfigurationTab"/>
114+
<see userInput="Please enter less or equal than 64 symbols." selector="{{AdminProductFormConfigurationsSection.confProductSkuMessage('0')}}" stepKey="seeValidationMessage"/>
115+
116+
<!--Edit "SKU" with valid quantity-->
117+
<fillField selector="{{AdminProductFormConfigurationsSection.confProductSku('0')}}" userInput="{{ApiConfigurableProduct.sku}}-thisIsShortName" stepKey="fillValidValue"/>
118+
119+
<!--Click on "Save"-->
120+
<waitForElementVisible selector="{{AdminProductFormActionSection.saveButton}}" stepKey="waitForSaveBtnVisible"/>
121+
<click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="saveProductAgain"/>
122+
123+
<!--Click on "Confirm". Product is saved, success message appears -->
124+
<waitForElementVisible selector="{{AdminChooseAffectedAttributeSetPopup.confirm}}" stepKey="waitPopUpVisible"/>
125+
<click selector="{{AdminChooseAffectedAttributeSetPopup.confirm}}" stepKey="clickOnConfirmPopup"/>
126+
<seeElement selector="{{AdminMessagesSection.success}}" stepKey="seeSaveProductMessage"/>
127+
</test>
128+
</tests>

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,11 @@ define([
383383
* Chose action for the form save button
384384
*/
385385
saveFormHandler: function () {
386-
this.serializeData();
386+
this.formElement().validate();
387+
388+
if (this.formElement().source.get('params.invalid') === false) {
389+
this.serializeData();
390+
}
387391

388392
if (this.checkForNewAttributes()) {
389393
this.formSaveParams = arguments;

0 commit comments

Comments
 (0)