Skip to content

Commit b78c229

Browse files
Lusine-PapyanAliaksei Yakimovich2
authored andcommitted
MAGETWO-70232: Import customizable options adds it to another product if same SKU is filled
- Add automated test script
1 parent c289f5d commit b78c229

File tree

3 files changed

+147
-1
lines changed

3 files changed

+147
-1
lines changed

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

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,56 @@
5252
<selectOption selector="{{AdminProductCustomizableOptionsSection.optionPriceType('0')}}" userInput="{{option.price_type}}" stepKey="selectPriceType"/>
5353
<fillField selector="{{AdminProductCustomizableOptionsSection.optionFileExtensions('0')}}" userInput="{{option.file_extension}}" stepKey="fillCompatibleExtensions"/>
5454
</actionGroup>
55+
56+
<actionGroup name="AddProductCustomOptionField">
57+
<arguments>
58+
<argument name="option" defaultValue="ProductOptionField"/>
59+
<argiment name="optionIndex" type="string"/>
60+
</arguments>
61+
<conditionalClick selector="{{AdminProductCustomizableOptionsSection.customizableOptions}}" dependentSelector="{{AdminProductCustomizableOptionsSection.addOptionBtn}}" visible="false" stepKey="openCustomOptionSection"/>
62+
<click selector="{{AdminProductCustomizableOptionsSection.addOptionBtn}}" stepKey="clickAddOption"/>
63+
<waitForElementVisible selector="{{AdminProductCustomizableOptionsSection.lastOptionTitle}}" stepKey="waitForOption"/>
64+
<fillField selector="{{AdminProductCustomizableOptionsSection.lastOptionTitle}}" userInput="{{option.title}}" stepKey="fillTitle"/>
65+
<click selector="{{AdminProductCustomizableOptionsSection.lastOptionTypeParent}}" stepKey="openTypeSelect"/>
66+
<click selector="{{AdminProductCustomizableOptionsSection.optionType('Field')}}" stepKey="selectTypeFile"/>
67+
<waitForElementVisible selector="{{AdminProductCustomizableOptionsSection.optionPrice(optionIndex)}}" stepKey="waitForElements"/>
68+
<fillField selector="{{AdminProductCustomizableOptionsSection.optionPrice(optionIndex)}}" userInput="{{option.price}}" stepKey="fillPrice"/>
69+
<selectOption selector="{{AdminProductCustomizableOptionsSection.optionPriceType(optionIndex)}}" userInput="{{option.price_type}}" stepKey="selectPriceType"/>
70+
<fillField selector="{{AdminProductCustomizableOptionsSection.optionSku(optionIndex)}}" userInput="{{option.title}}" stepKey="fillSku"/>
71+
</actionGroup>
72+
73+
<actionGroup name="importProductCustomizableOptions">
74+
<arguments>
75+
<argument name="productName" type="string"/>
76+
</arguments>
77+
<click selector="{{AdminProductCustomizableOptionsSection.importOptions}}" stepKey="clickImportOptions"/>
78+
<waitForElementVisible selector="{{AdminProductImportOptionsSection.selectProductTitle}}" stepKey="waitForTitleVisible"/>
79+
<conditionalClick selector="{{AdminProductImportOptionsSection.resetFiltersButton}}" dependentSelector="{{AdminProductImportOptionsSection.resetFiltersButton}}" visible="true" stepKey="clickResetFilters"/>
80+
<click selector="{{AdminProductImportOptionsSection.filterButton}}" stepKey="clickFilterButton"/>
81+
<waitForElementVisible selector="{{AdminProductImportOptionsSection.nameField}}" stepKey="waitForNameField"/>
82+
<fillField selector="{{AdminProductImportOptionsSection.nameField}}" userInput="{{productName}}" stepKey="fillProductName"/>
83+
<click selector="{{AdminProductImportOptionsSection.applyFiltersButton}}" stepKey="clickApplyFilters"/>
84+
<checkOption selector="{{AdminProductImportOptionsSection.firstRowItemCheckbox}}" stepKey="checkProductCheckbox"/>
85+
<click selector="{{AdminProductImportOptionsSection.importButton}}" stepKey="clickImport"/>
86+
</actionGroup>
87+
88+
<actionGroup name="resetImportOptionFilter">
89+
<conditionalClick selector="{{AdminProductCustomizableOptionsSection.customizableOptions}}" dependentSelector="{{AdminProductCustomizableOptionsSection.addOptionBtn}}" visible="false" stepKey="openCustomOptionSection"/>
90+
<click selector="{{AdminProductCustomizableOptionsSection.importOptions}}" stepKey="clickImportOptions"/>
91+
<click selector="{{AdminProductImportOptionsSection.resetFiltersButton}}" stepKey="clickResetFilterButton"/>
92+
</actionGroup>
93+
94+
<actionGroup name="checkCustomizableOptionImport">
95+
<arguments>
96+
<argument name="option" defaultValue="ProductOptionField"/>
97+
<argiment name="optionIndex" type="string"/>
98+
</arguments>
99+
<grabValueFrom selector="{{AdminProductCustomizableOptionsSection.optionTitleInput(optionIndex)}}" stepKey="grabOptionTitle"/>
100+
<grabValueFrom selector="{{AdminProductCustomizableOptionsSection.optionPrice(optionIndex)}}" stepKey="grabOptionPrice"/>
101+
<grabValueFrom selector="{{AdminProductCustomizableOptionsSection.optionSku(optionIndex)}}" stepKey="grabOptionSku"/>
102+
103+
<assertEquals expected="{{option.title}}" expectedType="string" actual="$grabOptionTitle" stepKey="assertOptionTitle"/>
104+
<assertEquals expected="{{option.price}}" expectedType="string" actual="$grabOptionPrice" stepKey="assertOptionPrice"/>
105+
<assertEquals expected="{{option.title}}" expectedType="string" actual="$grabOptionSku" stepKey="assertOptionSku"/>
106+
</actionGroup>
55107
</actionGroups>

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,15 @@
4545
<element name="optionPriceType" type="select" selector="//*[@data-index='custom_options']//*[@data-index='options']/tbody/tr//*[@name='product[options][{{var}}][price_type]']" parameterized="true"/>
4646
<element name="optionSku" type="input" selector="//*[@data-index='custom_options']//*[@data-index='options']/tbody/tr//*[@name='product[options][{{index}}][sku]']" parameterized="true"/>
4747
<element name="optionFileExtensions" type="input" selector="//*[@data-index='custom_options']//*[@data-index='options']/tbody/tr//*[@name='product[options][{{index}}][file_extension]']" parameterized="true"/>
48+
<element name="importOptions" type="button" selector="//button[@data-index='button_import']" timeout="30"/>
4849
</section>
49-
</sections>
50+
<section name="AdminProductImportOptionsSection">
51+
<element name="selectProductTitle" type="text" selector="//h1[contains(text(), 'Select Product')]" timeout="30"/>
52+
<element name="filterButton" type="button" selector="//button[@data-action='grid-filter-expand']" timeout="30"/>
53+
<element name="nameField" type="input" selector="//input[@name='name']" timeout="30"/>
54+
<element name="applyFiltersButton" type="button" selector="//button[@data-action='grid-filter-apply']" timeout="30"/>
55+
<element name="resetFiltersButton" type="button" selector="//button[@data-action='grid-filter-reset']" timeout="30"/>
56+
<element name="firstRowItemCheckbox" type="input" selector="//input[@data-action='select-row']" timeout="30"/>
57+
<element name="importButton" type="button" selector="//button[@class='action-primary']/span[contains(text(), 'Import')]" timeout="30"/>
58+
</section>
59+
</sections>
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
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="AdminImportCustomizableOptionToProductWithSKUTest">
12+
<annotations>
13+
<features value="Catalog"/>
14+
<title value="Check that 'trie price' block not available for simple product from options without 'trie price'"/>
15+
<description value="Check that 'trie price' block not available for simple product from options without 'trie price'"/>
16+
<severity value="MAJOR"/>
17+
<testCaseId value="MAGETWO-98211"/>
18+
<useCaseId value="MAGETWO-70232"/>
19+
<group value="catalog"/>
20+
</annotations>
21+
<before>
22+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
23+
24+
<!--Create category-->
25+
<createData entity="ApiCategory" stepKey="createCategory"/>
26+
27+
<!-- Create two product -->
28+
<createData entity="SimpleProduct2" stepKey="createFirstProduct"/>
29+
<createData entity="ApiSimpleProduct" stepKey="createSecondProduct">
30+
<requiredEntity createDataKey="createCategory"/>
31+
</createData>
32+
33+
</before>
34+
<after>
35+
36+
<!--Delete second product with changed sku-->
37+
<actionGroup ref="deleteProductBySku" stepKey="deleteSecondProduct">
38+
<argument name="sku" value="$$createFirstProduct.sku$$-1"/>
39+
</actionGroup>
40+
41+
<!--Delete created data-->
42+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
43+
<deleteData createDataKey="createFirstProduct" stepKey="deleteFirstProduct"/>
44+
45+
<actionGroup ref="logout" stepKey="logoutOfAdmin"/>
46+
</after>
47+
48+
<!--Go to product page -->
49+
<amOnPage url="{{AdminProductEditPage.url($$createFirstProduct.id$$)}}" stepKey="goToProductEditPage"/>
50+
<waitForPageLoad stepKey="waitForProductEditPageLoad"/>
51+
<actionGroup ref="AddProductCustomOptionField" stepKey="addCutomOption1">
52+
<argument name="option" value="ProductOptionField"/>
53+
<argument name="optionIndex" value="0"/>
54+
</actionGroup>
55+
<actionGroup ref="AddProductCustomOptionField" stepKey="addCutomOption2">
56+
<argument name="option" value="ProductOptionField2"/>
57+
<argument name="optionIndex" value="1"/>
58+
</actionGroup>
59+
<actionGroup ref="saveProductForm" stepKey="saveProduct"/>
60+
61+
<!--Change second product sku to first product sku-->
62+
<amOnPage url="{{AdminProductEditPage.url($$createSecondProduct.id$$)}}" stepKey="goToProductEditPage1"/>
63+
<waitForPageLoad stepKey="waitForProductEditPageLoad1"/>
64+
<fillField selector="{{AdminProductFormSection.productSku}}" userInput="$$createFirstProduct.sku$$" stepKey="fillProductSku1"/>
65+
66+
<!--Import customizable options and check-->
67+
<conditionalClick selector="{{AdminProductCustomizableOptionsSection.customizableOptions}}" dependentSelector="{{AdminProductCustomizableOptionsSection.addOptionBtn}}" visible="false" stepKey="openCustomOptionSection"/>
68+
<actionGroup ref="importProductCustomizableOptions" stepKey="importOptions">
69+
<argument name="productName" value="$$createFirstProduct.name$$"/>
70+
</actionGroup>
71+
<actionGroup ref="checkCustomizableOptionImport" stepKey="checkFirstOptionImport">
72+
<argument name="option" value="ProductOptionField"/>
73+
<argument name="optionIndex" value="0"/>
74+
</actionGroup>
75+
<actionGroup ref="checkCustomizableOptionImport" stepKey="checkSecondOptionImport">
76+
<argument name="option" value="ProductOptionField2"/>
77+
<argument name="optionIndex" value="1"/>
78+
</actionGroup>
79+
80+
<!--SAve product and check sku changed message-->
81+
<actionGroup ref="saveProductForm" stepKey="saveProduct1"/>
82+
<see userInput="SKU for product $$createSecondProduct.name$$ has been changed to $$createFirstProduct.sku$$-1." stepKey="seeSkuChangedMessage"/>
83+
</test>
84+
</tests>

0 commit comments

Comments
 (0)