Skip to content

Commit f952fc1

Browse files
committed
MC-182: Customer should be able to sort by price with catalog rules applied to configurable product
1 parent 43240c3 commit f952fc1

File tree

5 files changed

+189
-1
lines changed

5 files changed

+189
-1
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<section name="StorefrontPropertiesSection">
2626
<element name="StoreFrontPropertiesTab" selector="#product_attribute_tabs_front" type="button"/>
2727
<element name="EnableWYSIWYG" type="select" selector="#enabled"/>
28+
<element name="useForPromoRuleConditions" type="select" selector="#is_used_for_promo_rules"/>
2829
</section>
2930
<section name="WYSIWYGProductAttributeSection">
3031
<element name="ShowHideBtn" type="button" selector="#toggledefault_value_texteditor"/>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<element name="GridFilterFrontEndLabel" type="input" selector="#attributeGrid_filter_frontend_label"/>
1515
<element name="Search" type="button" selector="button[data-action=grid-filter-apply]" timeout="30"/>
1616
<element name="ResetFilter" type="button" selector="button[data-action='grid-filter-reset']" timeout="30"/>
17-
<element name="FirstRow" type="button" selector="//*[@id='attributeGrid_table']/tbody/tr[1]"/>
17+
<element name="FirstRow" type="button" selector="//*[@id='attributeGrid_table']/tbody/tr[1]" timeout="30"/>
1818
<element name="FilterByAttributeCode" type="input" selector="#attributeGrid_filter_attribute_code"/>
1919
</section>
2020
</sections>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,7 @@
1212
<element name="gridMode" type="button" selector=".//*[@class='toolbar toolbar-products'][1]//*[@id='mode-grid']" timeout="30"/>
1313
<element name="listMode" type="button" selector=".//*[@class='toolbar toolbar-products'][1]//*[@id='mode-list']" timeout="30"/>
1414
<element name="sortByDropdown" type="select" selector=".//*[@class='toolbar toolbar-products'][1]//*[@id='sorter']" timeout="30"/>
15+
<element name="sortDirectionAsc" type="button" selector=".//*[@class='toolbar toolbar-products'][1]//a[contains(@class, 'sort-asc')]" timeout="30"/>
16+
<element name="sortDirectionDesc" type="button" selector=".//*[@class='toolbar toolbar-products'][1]//a[contains(@class, 'sort-desc')]" timeout="30"/>
1517
</section>
1618
</sections>

app/code/Magento/CatalogRule/Test/Mftf/Section/AdminNewCatalogPriceRuleSection.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@
3737
<element name="disregardRules" type="select" selector="[name='stop_rules_processing']"/>
3838
</section>
3939

40+
<section name="AdminNewCatalogPriceRuleConditions">
41+
<element name="newCondition" type="button" selector="span.rule-param-new-child"/>
42+
<element name="conditionSelect" type="select" selector="select#conditions__{{var}}__new_child" parameterized="true"/>
43+
<element name="targetEllipsis" type="button" selector="//li[{{var}}]//a[@class='label'][text() = '...']" parameterized="true"/>
44+
<element name="targetInput" type="input" selector="input#conditions__{{var1}}--{{var2}}__value" parameterized="true"/>
45+
<element name="applyButton" type="button" selector="#conditions__{{var1}}__children li:nth-of-type({{var2}}) a.rule-param-apply" parameterized="true"/>
46+
</section>
47+
4048
<section name="AdminCatalogPriceRuleGrid">
4149
<element name="applyRules" type="button" selector="#apply_rules" timeout="30"/>
4250
</section>
Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
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" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="StorefrontSortByPriceTest">
11+
<annotations>
12+
<features value="CatalogRule"/>
13+
<stories value="Apply catalog price rule"/>
14+
<title value="Customer should be able to sort by price with catalog rules applied to configurable product"/>
15+
<description value="Customer should be able to sort by price with catalog rules applied to configurable product"/>
16+
<severity value="CRITICAL"/>
17+
<testCaseId value="MC-182"/>
18+
<group value="CatalogRule"/>
19+
</annotations>
20+
<before>
21+
<!-- Create category and two simple products -->
22+
<createData entity="ApiCategory" stepKey="createCategory"/>
23+
<createData entity="ApiSimpleProduct" stepKey="createSimpleProduct5">
24+
<requiredEntity createDataKey="createCategory"/>
25+
<field key="price">5</field>
26+
</createData>
27+
<createData entity="ApiSimpleProduct" stepKey="createSimpleProduct10">
28+
<requiredEntity createDataKey="createCategory"/>
29+
<field key="price">10</field>
30+
</createData>
31+
32+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
33+
34+
<!-- Enable SKU for use in promo rule conditions -->
35+
<amOnPage url="{{AdminProductAttributeGridPage.url}}" stepKey="goToProductAttributes"/>
36+
<waitForPageLoad stepKey="waitForProductAttributes"/>
37+
<click selector="{{AdminProductAttributeGridSection.ResetFilter}}" stepKey="resetFiltersOnGrid"/>
38+
<fillField selector="{{AdminProductAttributeGridSection.GridFilterFrontEndLabel}}" userInput="SKU" stepKey="setAttributeLabel"/>
39+
<click selector="{{AdminProductAttributeGridSection.Search}}" stepKey="searchForAttributeFromGrid"/>
40+
<click selector="{{AdminProductAttributeGridSection.FirstRow}}" stepKey="clickOnAttributeRow"/>
41+
<click selector="{{StorefrontPropertiesSection.StoreFrontPropertiesTab}}" stepKey="goToStorefrontProperties"/>
42+
<selectOption selector="{{StorefrontPropertiesSection.useForPromoRuleConditions}}" userInput="Yes" stepKey="selectUseForPromoRuleCondition"/>
43+
<click selector="{{AttributePropertiesSection.Save}}" stepKey="clickSaveAttribute"/>
44+
45+
<!-- Create a configurable product -->
46+
<amOnPage url="{{AdminProductIndexPage.url}}" stepKey="amOnProductGridPage"/>
47+
<waitForPageLoad time="30" stepKey="waitForProductGrid"/>
48+
<click selector="{{AdminProductGridActionSection.addProductToggle}}" stepKey="clickOnAddProductToggle"/>
49+
<click selector="{{AdminProductGridActionSection.addConfigurableProduct}}" stepKey="clickOnAddConfigurableProduct"/>
50+
<fillField userInput="{{_defaultProduct.name}}" selector="{{AdminProductFormSection.productName}}" stepKey="fillName"/>
51+
<fillField userInput="{{_defaultProduct.sku}}" selector="{{AdminProductFormSection.productSku}}" stepKey="fillSKU"/>
52+
<fillField userInput="{{_defaultProduct.price}}" selector="{{AdminProductFormSection.productPrice}}" stepKey="fillPrice"/>
53+
<fillField userInput="{{_defaultProduct.quantity}}" selector="{{AdminProductFormSection.productQuantity}}" stepKey="fillQuantity"/>
54+
<searchAndMultiSelectOption selector="{{AdminProductFormSection.categoriesDropdown}}" parameterArray="[$$createCategory.name$$]" stepKey="fillCategory"/>
55+
<click selector="{{AdminProductSEOSection.sectionHeader}}" stepKey="openSeoSection"/>
56+
<fillField userInput="{{_defaultProduct.urlKey}}" selector="{{AdminProductSEOSection.urlKeyInput}}" stepKey="fillUrlKey"/>
57+
<click selector="{{AdminProductFormConfigurationsSection.createConfigurations}}" stepKey="clickOnCreateConfigurations"/>
58+
<click selector="{{AdminCreateProductConfigurationsPanel.createNewAttribute}}" stepKey="clickOnNewAttribute"/>
59+
<waitForPageLoad stepKey="waitForIFrame"/>
60+
<switchToIFrame selector="{{AdminNewAttributePanel.newAttributeIFrame}}" stepKey="switchToNewAttributeIFrame"/>
61+
<fillField selector="{{AdminNewAttributePanel.defaultLabel}}" userInput="{{colorProductAttribute.default_label}}" stepKey="fillDefaultLabel"/>
62+
<click selector="{{AdminNewAttributePanel.saveAttribute}}" stepKey="clickOnNewAttributePanel"/>
63+
<waitForPageLoad stepKey="waitForSaveAttribute"/>
64+
<switchToIFrame stepKey="switchOutOfIFrame"/>
65+
<waitForPageLoad stepKey="waitForFilters"/>
66+
<click selector="{{AdminCreateProductConfigurationsPanel.filters}}" stepKey="clickOnFilters"/>
67+
<fillField userInput="{{colorProductAttribute.default_label}}" selector="{{AdminCreateProductConfigurationsPanel.attributeCode}}" stepKey="fillFilterAttributeCodeField"/>
68+
<click selector="{{AdminCreateProductConfigurationsPanel.applyFilters}}" stepKey="clickApplyFiltersButton"/>
69+
<click selector="{{AdminCreateProductConfigurationsPanel.firstCheckbox}}" stepKey="clickOnFirstCheckbox"/>
70+
<click selector="{{AdminCreateProductConfigurationsPanel.next}}" stepKey="clickOnNextButton1"/>
71+
<click selector="{{AdminCreateProductConfigurationsPanel.createNewValue}}" stepKey="clickOnCreateNewValue1"/>
72+
<fillField userInput="{{colorProductAttribute1.name}}" selector="{{AdminCreateProductConfigurationsPanel.attributeName}}" stepKey="fillFieldForNewAttribute1"/>
73+
<click selector="{{AdminCreateProductConfigurationsPanel.saveAttribute}}" stepKey="clickOnSaveNewAttribute1"/>
74+
<click selector="{{AdminCreateProductConfigurationsPanel.createNewValue}}" stepKey="clickOnCreateNewValue2"/>
75+
<fillField userInput="{{colorProductAttribute2.name}}" selector="{{AdminCreateProductConfigurationsPanel.attributeName}}" stepKey="fillFieldForNewAttribute2"/>
76+
<click selector="{{AdminCreateProductConfigurationsPanel.saveAttribute}}" stepKey="clickOnSaveNewAttribute2"/>
77+
<click selector="{{AdminCreateProductConfigurationsPanel.createNewValue}}" stepKey="clickOnCreateNewValue3"/>
78+
<fillField userInput="{{colorProductAttribute3.name}}" selector="{{AdminCreateProductConfigurationsPanel.attributeName}}" stepKey="fillFieldForNewAttribute3"/>
79+
<click selector="{{AdminCreateProductConfigurationsPanel.saveAttribute}}" stepKey="clickOnSaveNewAttribute3"/>
80+
<click selector="{{AdminCreateProductConfigurationsPanel.selectAll}}" stepKey="clickOnSelectAll"/>
81+
<click selector="{{AdminCreateProductConfigurationsPanel.next}}" stepKey="clickOnNextButton2"/>
82+
<click selector="{{AdminCreateProductConfigurationsPanel.applyUniquePricesByAttributeToEachSku}}" stepKey="clickOnApplyUniquePricesByAttributeToEachSku"/>
83+
<selectOption selector="{{AdminCreateProductConfigurationsPanel.selectAttribute}}" userInput="{{colorProductAttribute.default_label}}" stepKey="selectAttributes"/>
84+
<fillField selector="{{AdminCreateProductConfigurationsPanel.attribute1}}" userInput="15" stepKey="fillAttributePrice1"/>
85+
<fillField selector="{{AdminCreateProductConfigurationsPanel.attribute2}}" userInput="20" stepKey="fillAttributePrice2"/>
86+
<fillField selector="{{AdminCreateProductConfigurationsPanel.attribute3}}" userInput="25" stepKey="fillAttributePrice3"/>
87+
<click selector="{{AdminCreateProductConfigurationsPanel.applySingleQuantityToEachSkus}}" stepKey="clickOnApplySingleQuantityToEachSku"/>
88+
<fillField selector="{{AdminCreateProductConfigurationsPanel.quantity}}" userInput="1" stepKey="enterAttributeQuantity"/>
89+
<click selector="{{AdminCreateProductConfigurationsPanel.next}}" stepKey="clickOnNextButton3"/>
90+
<click selector="{{AdminCreateProductConfigurationsPanel.next}}" stepKey="clickOnNextButton4"/>
91+
<click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="clickOnSaveButton2"/>
92+
<click selector="{{AdminChooseAffectedAttributeSetPopup.confirm}}" stepKey="clickOnConfirmInPopup"/>
93+
</before>
94+
<after>
95+
<!-- Delete category and two simple products -->
96+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
97+
<deleteData createDataKey="createSimpleProduct5" stepKey="deleteSimpleProduct5"/>
98+
<deleteData createDataKey="createSimpleProduct10" stepKey="deleteSimpleProduct10"/>
99+
100+
<!-- Delete the catalog price rule -->
101+
<amOnPage stepKey="goToPriceRulePage" url="{{CatalogRulePage.url}}"/>
102+
<actionGroup stepKey="deletePriceRule" ref="deleteEntitySecondaryGrid">
103+
<argument name="name" value="{{_defaultCatalogRule.name}}"/>
104+
<argument name="searchInput" value="{{AdminSecondaryGridSection.catalogRuleIdentifierSearch}}"/>
105+
</actionGroup>
106+
107+
<amOnPage url="{{AdminLogoutPage.url}}" stepKey="amOnLogoutPage"/>
108+
</after>
109+
110+
<!-- 1. Check category page price sorting BEFORE catalog rule is created -->
111+
<amOnPage url="$$createCategory.name$$.html" stepKey="goToCategory1"/>
112+
<selectOption selector="{{StorefrontCategoryTopToolbarSection.sortByDropdown}}" userInput="price" stepKey="sortByPrice1"/>
113+
<see selector="{{StorefrontCategoryProductSection.ProductInfoByNumber('1')}}" userInput="$$createSimpleProduct5.name$$" stepKey="seeOrder1"/>
114+
<see selector="{{StorefrontCategoryProductSection.ProductInfoByNumber('1')}}" userInput="$5.00" stepKey="seePrice1"/>
115+
<see selector="{{StorefrontCategoryProductSection.ProductInfoByNumber('2')}}" userInput="$$createSimpleProduct10.name$$" stepKey="seeOrder2"/>
116+
<see selector="{{StorefrontCategoryProductSection.ProductInfoByNumber('2')}}" userInput="$10.00" stepKey="seePrice2"/>
117+
<see selector="{{StorefrontCategoryProductSection.ProductInfoByNumber('3')}}" userInput="{{_defaultProduct.name}}" stepKey="seeOrder3"/>
118+
<see selector="{{StorefrontCategoryProductSection.ProductInfoByNumber('3')}}" userInput="$15.00" stepKey="seePrice3"/>
119+
<click selector="{{StorefrontCategoryTopToolbarSection.sortDirectionAsc}}" stepKey="clickSortByArrow1"/>
120+
<see selector="{{StorefrontCategoryProductSection.ProductInfoByNumber('1')}}" userInput="{{_defaultProduct.name}}" stepKey="seeOrder4"/>
121+
<see selector="{{StorefrontCategoryProductSection.ProductInfoByNumber('1')}}" userInput="$15.00" stepKey="seePrice4"/>
122+
<see selector="{{StorefrontCategoryProductSection.ProductInfoByNumber('2')}}" userInput="$$createSimpleProduct10.name$$" stepKey="seeOrder5"/>
123+
<see selector="{{StorefrontCategoryProductSection.ProductInfoByNumber('2')}}" userInput="$10.00" stepKey="seePrice5"/>
124+
<see selector="{{StorefrontCategoryProductSection.ProductInfoByNumber('3')}}" userInput="$$createSimpleProduct5.name$$" stepKey="seeOrder6"/>
125+
<see selector="{{StorefrontCategoryProductSection.ProductInfoByNumber('3')}}" userInput="$5.00" stepKey="seePrice6"/>
126+
127+
<!-- 2. Create a new catalog rule that adjusts one of the configurable products down to $1 -->
128+
<amOnPage url="{{CatalogRulePage.url}}" stepKey="goToPriceRulePage"/>
129+
<waitForPageLoad stepKey="waitForPriceRulePage"/>
130+
<click selector="{{AdminGridMainControls.add}}" stepKey="addNewRule"/>
131+
<waitForPageLoad stepKey="waitForIndividualRulePage"/>
132+
<fillField selector="{{AdminNewCatalogPriceRule.ruleName}}" userInput="{{_defaultCatalogRule.name}}" stepKey="fillName"/>
133+
<fillField selector="{{AdminNewCatalogPriceRule.description}}" userInput="{{_defaultCatalogRule.description}}" stepKey="fillDescription"/>
134+
<selectOption selector="{{AdminNewCatalogPriceRule.websites}}" userInput="{{_defaultCatalogRule.website_ids[0]}}" stepKey="selectSite"/>
135+
<click selector="{{AdminNewCatalogPriceRule.fromDateButton}}" stepKey="clickFromCalender"/>
136+
<click selector="{{AdminNewCatalogPriceRule.todayDate}}" stepKey="clickFromToday"/>
137+
<click selector="{{AdminNewCatalogPriceRule.toDateButton}}" stepKey="clickToCalender"/>
138+
<click selector="{{AdminNewCatalogPriceRule.todayDate}}" stepKey="clickToToday"/>
139+
<click selector="{{AdminNewCatalogPriceRule.conditionsTab}}" stepKey="openConditions"/>
140+
<click selector="{{AdminNewCatalogPriceRuleConditions.newCondition}}" stepKey="clickNewRule"/>
141+
<selectOption selector="{{AdminNewCatalogPriceRuleConditions.conditionSelect('1')}}" userInput="SKU" stepKey="selectSKU"/>
142+
<waitForPageLoad stepKey="waitForEllipsis"/>
143+
<click selector="{{AdminNewCatalogPriceRuleConditions.targetEllipsis('1')}}" stepKey="clickEllipsis"/>
144+
<waitForPageLoad stepKey="waitForInput"/>
145+
<fillField selector="{{AdminNewCatalogPriceRuleConditions.targetInput('1', '1')}}" userInput="{{_defaultProduct.sku}}-{{colorProductAttribute3.name}}" stepKey="fillSku"/>
146+
<click selector="{{AdminNewCatalogPriceRuleConditions.applyButton('1', '1')}}" stepKey="clickApply"/>
147+
<click selector="{{AdminNewCatalogPriceRule.actionsTab}}" stepKey="openActionDropdown"/>
148+
<selectOption selector="{{AdminNewCatalogPriceRuleActions.apply}}" userInput="{{_defaultCatalogRule.simple_action}}" stepKey="discountType"/>
149+
<fillField selector="{{AdminNewCatalogPriceRuleActions.discountAmount}}" userInput="96" stepKey="fillDiscountValue"/>
150+
<selectOption selector="{{AdminNewCatalogPriceRuleActions.disregardRules}}" userInput="Yes" stepKey="discardSubsequentRules"/>
151+
<scrollToTopOfPage stepKey="scrollToTop"/>
152+
<waitForPageLoad stepKey="waitForApplied"/>
153+
<actionGroup ref="selectNotLoggedInCustomerGroup" stepKey="selectNotLoggedInCustomerGroup"/>
154+
155+
<!-- 3. Save the catalog rule, reindex, and flush cache-->
156+
<click selector="{{AdminNewCatalogPriceRule.saveAndApply}}" stepKey="saveAndApply"/>
157+
<magentoCLI command="indexer:reindex" stepKey="reindex"/>
158+
<magentoCLI command="cache:flush" stepKey="flushCache"/>
159+
160+
<!-- 4. Check category page price sorting AFTER catalog rule is created -->
161+
<amOnPage url="$$createCategory.name$$.html" stepKey="goToCategory2"/>
162+
<selectOption selector="{{StorefrontCategoryTopToolbarSection.sortByDropdown}}" userInput="price" stepKey="sortByPrice2"/>
163+
<see selector="{{StorefrontCategoryProductSection.ProductInfoByNumber('1')}}" userInput="{{_defaultProduct.name}}" stepKey="seeOrder7"/>
164+
<see selector="{{StorefrontCategoryProductSection.ProductInfoByNumber('1')}}" userInput="$1.00" stepKey="seePrice7"/>
165+
<see selector="{{StorefrontCategoryProductSection.ProductInfoByNumber('2')}}" userInput="$$createSimpleProduct5.name$$" stepKey="seeOrder8"/>
166+
<see selector="{{StorefrontCategoryProductSection.ProductInfoByNumber('2')}}" userInput="$5.00" stepKey="seePrice8"/>
167+
<see selector="{{StorefrontCategoryProductSection.ProductInfoByNumber('3')}}" userInput="$$createSimpleProduct10.name$$" stepKey="seeOrder9"/>
168+
<see selector="{{StorefrontCategoryProductSection.ProductInfoByNumber('3')}}" userInput="$10.00" stepKey="seePrice9"/>
169+
<click selector="{{StorefrontCategoryTopToolbarSection.sortDirectionAsc}}" stepKey="clickSortByArrow2"/>
170+
<see selector="{{StorefrontCategoryProductSection.ProductInfoByNumber('1')}}" userInput="$$createSimpleProduct10.name$$" stepKey="seeOrder10"/>
171+
<see selector="{{StorefrontCategoryProductSection.ProductInfoByNumber('1')}}" userInput="$10.00" stepKey="seePrice10"/>
172+
<see selector="{{StorefrontCategoryProductSection.ProductInfoByNumber('2')}}" userInput="$$createSimpleProduct5.name$$" stepKey="seeOrder11"/>
173+
<see selector="{{StorefrontCategoryProductSection.ProductInfoByNumber('2')}}" userInput="$5.00" stepKey="seePrice11"/>
174+
<see selector="{{StorefrontCategoryProductSection.ProductInfoByNumber('3')}}" userInput="{{_defaultProduct.name}}" stepKey="seeOrder12"/>
175+
<see selector="{{StorefrontCategoryProductSection.ProductInfoByNumber('3')}}" userInput="$1.00" stepKey="seePrice12"/>
176+
</test>
177+
</tests>

0 commit comments

Comments
 (0)