Skip to content

Commit b07dfd8

Browse files
committed
MC-65: Admin should be able to create a catalog price rule applied as a percentage of original (for simple product)
- Includes MC-60, MC-69, and MC-93
1 parent 26cbef3 commit b07dfd8

File tree

8 files changed

+392
-4
lines changed

8 files changed

+392
-4
lines changed

dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Backend/Section/AdminSecondaryGridSection.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
<section name="AdminSecondaryGridSection">
1212
<element name="resetFilters" type="button" selector="[title='Reset Filter']"/>
1313
<element name="taxIdentifierSearch" type="input" selector=".col-code .admin__control-text"/>
14+
<element name="catalogRuleIdentifierSearch" type="input" selector=".col-name .admin__control-text"/>
1415
<element name="searchButton" type="input" selector=".admin__filter-actions [title='Search']"/>
1516
<element name="firstRow" type="block" selector="tr[data-role='row']"/>
1617
</section>
17-
</sections>
18+
</sections>

dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Section/StorefrontCategoryProductSection.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
<section name="StorefrontCategoryProductSection">
1212
<element name="ProductTitleByNumber" type="button" selector="//main//li[{{var1}}]//a[@class='product-item-link']" parameterized="true"/>
1313
<element name="ProductPriceByNumber" type="text" selector="//main//li[{{var1}}]//span[@class='price']" parameterized="true"/>
14+
<element name="ProductSpecialPriceByNumber" type="text" selector="//main//li[{{var1}}]//span[@class='special-price']//span[@class='price']" parameterized="true"/>
15+
<element name="ProductOldPriceByNumber" type="text" selector="//main//li[{{var1}}]//span[@class='old-price']//span[@class='price']" parameterized="true"/>
1416
<element name="ProductInfoByNumber" type="text" selector="//main//li[{{var1}}]//div[@class='product-item-info']" parameterized="true"/>
1517
<element name="ProductAddToCompareByNumber" type="text" selector="//main//li[{{var1}}]//a[contains(@class, 'tocompare')]" parameterized="true"/>
1618

dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Section/StorefrontProductInfoMainSection.xml

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

99
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10-
xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
10+
xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
1111
<section name="StorefrontProductInfoMainSection">
1212
<element name="stock" type="input" selector=".stock.available"/>
1313
<element name="productName" type="text" selector=".base"/>
1414
<element name="productSku" type="text" selector=".product.attribute.sku>.value"/>
1515
<element name="productPriceLabel" type="text" selector=".price-label"/>
1616
<element name="productPrice" type="text" selector="div.price-box.price-final_price"/>
1717
<element name="specialPrice" type="text" selector=".special-price"/>
18+
<element name="updatedPrice" type="text" selector="div.price-box.price-final_price [data-price-type='finalPrice'] .price"/>
1819
<element name="oldPrice" type="text" selector=".old-price"/>
20+
<element name="oldPriceTag" type="text" selector=".old-price .price-label"/>
21+
<element name="oldPriceAmount" type="text" selector=".old-price .price"/>
1922
<element name="productStockStatus" type="text" selector=".stock[title=Availability]>span"/>
2023
<element name="productImage" type="text" selector="//*[@id='maincontent']//div[@class='gallery-placeholder']//img[@class='fotorama__img']"/>
2124
<element name="productImageSrc" type="text" selector="//*[@id='maincontent']//div[@class='gallery-placeholder']//img[contains(@src, '{{src}}')]" parameterized="true"/>
@@ -31,7 +34,7 @@
3134
<!-- The 1st parameter is the nth custom option, the 2nd parameter is the nth value in the option -->
3235
<element name="nthCustomOptionInput" type="radio" selector="//*[@id='product-options-wrapper']/*[@class='fieldset']/*[contains(@class, 'field')][{{customOptionNum}}]//*[contains(@class, 'admin__field-option')][{{customOptionValueNum}}]//input" parameterized="true" />
3336
<element name="productOptionRadioButtonsCheckbox" type="checkbox" selector="//*[@id='product-options-wrapper']//div[@class='fieldset']//label[contains(.,'{{var1}}')]/../div[@class='control']//input[@price='{{var2}}']" parameterized="true"/>
34-
37+
3538
<element name="productOptionDataMonth" type="date" selector="//*[@id='product-options-wrapper']//div[@class='fieldset']//legend[contains(.,'{{var1}}')]/../div[@class='control']//select[@data-calendar-role='month']" parameterized="true"/>
3639
<element name="productOptionDataDay" type="date" selector="//*[@id='product-options-wrapper']//div[@class='fieldset']//legend[contains(.,'{{var1}}')]/../div[@class='control']//select[@data-calendar-role='day']" parameterized="true"/>
3740
<element name="productOptionDataYear" type="date" selector="//*[@id='product-options-wrapper']//div[@class='fieldset']//legend[contains(.,'{{var1}}')]/../div[@class='control']//select[@data-calendar-role='year']" parameterized="true"/>
@@ -61,4 +64,4 @@
6164
<element name="productOptionDropDownTitle" type="text" selector="//label[contains(.,'{{var1}}')]" parameterized="true"/>
6265
<element name="productOptionDropDownOptionTitle" type="text" selector="//label[contains(.,'{{var1}}')]/../div[@class='control']//select//option[contains(.,'{{var2}}')]" parameterized="true"/>
6366
</section>
64-
</sections>
67+
</sections>
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+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd">
11+
<!-- action group to create a new catalog price rule giving a catalogRule entity -->
12+
<actionGroup name="newCatalogPriceRuleByUI">
13+
<arguments>
14+
<argument name="catalogRule" defaultValue="_defaultCatalogRule"/>
15+
</arguments>
16+
<!-- Go to the admin Catalog rule grid and add a new one -->
17+
<amOnPage stepKey="goToPriceRulePage" url="{{CatalogRulePage.url}}"/>
18+
<waitForPageLoad stepKey="waitForPriceRulePage"/>
19+
<click stepKey="addNewRule" selector="{{AdminGridMainControls.add}}"/>
20+
21+
<!-- Fill the form according the the attributes of the entity -->
22+
<fillField stepKey="fillName" selector="{{AdminNewCatalogPriceRule.ruleName}}" userInput="{{catalogRule.name}}"/>
23+
<fillField stepKey="fillDescription" selector="{{AdminNewCatalogPriceRule.description}}" userInput="{{catalogRule.description}}"/>
24+
<selectOption stepKey="selectSite" selector="{{AdminNewCatalogPriceRule.websites}}" userInput="{{catalogRule.website_ids[0]}}"/>
25+
<selectOption stepKey="selectCustomerGroups" selector="{{AdminNewCatalogPriceRule.customerGroups}}" userInput="{{catalogRule.customer_group_ids[0]}}"/>
26+
<click stepKey="clickFromCalender" selector="{{AdminNewCatalogPriceRule.fromDateButton}}"/>
27+
<click stepKey="clickFromToday" selector="{{AdminNewCatalogPriceRule.todayDate}}"/>
28+
<click stepKey="clickToCalender" selector="{{AdminNewCatalogPriceRule.toDateButton}}"/>
29+
<click stepKey="clickToToday" selector="{{AdminNewCatalogPriceRule.todayDate}}"/>
30+
<click stepKey="openActionDropdown" selector="{{AdminNewCatalogPriceRule.actionsTab}}"/>
31+
<selectOption stepKey="discountType" selector="{{AdminNewCatalogPriceRuleActions.apply}}" userInput="{{catalogRule.simple_action}}"/>
32+
<fillField stepKey="fillDiscountValue" selector="{{AdminNewCatalogPriceRuleActions.discountAmount}}" userInput="{{catalogRule.discount_amount}}"/>
33+
34+
<!-- Scroll to top and either save or save and apply after the action group -->
35+
<scrollToTopOfPage stepKey="scrollToTop"/>
36+
</actionGroup>
37+
38+
<actionGroup name="applyCatalogPriceRules">
39+
<amOnPage stepKey="goToPriceRulePage" url="{{CatalogRulePage.url}}"/>
40+
<waitForPageLoad stepKey="waitForPriceRulePage"/>
41+
<click stepKey="applyRules" selector="{{AdminCatalogPriceRuleGrid.applyRules}}"/>
42+
<see stepKey="assertSuccess" selector="{{AdminCategoryMessagesSection.SuccessMessage}}" userInput="Updated rules applied."/>
43+
</actionGroup>
44+
</actionGroups>

dev/tests/acceptance/tests/functional/Magento/FunctionalTest/CatalogRule/Data/CatalogRuleData.xml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,46 @@
2121
<data key="simple_action">by_percent</data>
2222
<data key="discount_amount">10</data>
2323
</entity>
24+
25+
<entity name="CatalogRuleByFixed" type="catalogRule">
26+
<data key="name" unique="suffix">CatalogPriceRule</data>
27+
<data key="description">Catalog Price Rule Description</data>
28+
<data key="is_active">1</data>
29+
<array key="customer_group_ids">
30+
<item>0</item>
31+
</array>
32+
<array key="website_ids">
33+
<item>1</item>
34+
</array>
35+
<data key="simple_action">by_fixed</data>
36+
<data key="discount_amount">10</data>
37+
</entity>
38+
39+
<entity name="CatalogRuleToPercent" type="catalogRule">
40+
<data key="name" unique="suffix">CatalogPriceRule</data>
41+
<data key="description">Catalog Price Rule Description</data>
42+
<data key="is_active">1</data>
43+
<array key="customer_group_ids">
44+
<item>0</item>
45+
</array>
46+
<array key="website_ids">
47+
<item>1</item>
48+
</array>
49+
<data key="simple_action">to_percent</data>
50+
<data key="discount_amount">90</data>
51+
</entity>
52+
53+
<entity name="CatalogRuleToFixed" type="catalogRule">
54+
<data key="name" unique="suffix">CatalogPriceRule</data>
55+
<data key="description">Catalog Price Rule Description</data>
56+
<data key="is_active">1</data>
57+
<array key="customer_group_ids">
58+
<item>0</item>
59+
</array>
60+
<array key="website_ids">
61+
<item>1</item>
62+
</array>
63+
<data key="simple_action">to_fixed</data>
64+
<data key="discount_amount">100</data>
65+
</entity>
2466
</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="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/PageObject.xsd">
11+
<page name="CatalogRulePage" url="catalog_rule/promo_catalog/" module="Magento_CatalogRule" area="admin">
12+
<section name="AdminSecondaryGridSection"/>
13+
</page>
14+
</pages>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
11+
<section name="AdminNewCatalogPriceRule">
12+
<element name="saveAndApply" type="button" selector="#save_and_apply" timeout="30"/>
13+
<element name="save" type="button" selector="#save" timeout="30"/>
14+
<element name="delete" type="button" selector="#delete" timeout="30"/>
15+
16+
<element name="ruleName" type="input" selector="[name='name']"/>
17+
<element name="description" type="textarea" selector="[name='description']"/>
18+
<element name="status" type="select" selector="[name='is_active']"/>
19+
20+
<element name="websites" type="select" selector="[name='website_ids']"/>
21+
<element name="websitesOptions" type="select" selector="[name='website_ids'] option"/>
22+
<element name="customerGroups" type="select" selector="[name='customer_group_ids']"/>
23+
<element name="customerGroupsOptions" type="select" selector="[name='customer_group_ids'] option"/>
24+
25+
<element name="fromDateButton" type="button" selector="[name='from_date'] + button" timeout="15"/>
26+
<element name="toDateButton" type="button" selector="[name='to_date'] + button" timeout="15"/>
27+
<element name="todayDate" type="button" selector="#ui-datepicker-div [data-handler='today']"/>
28+
<element name="priority" type="input" selector="[name='sort_order']"/>
29+
<element name="conditionsTab" type="block" selector="[data-index='block_promo_catalog_edit_tab_conditions']"/>
30+
<element name="actionsTab" type="block" selector="[data-index='actions']"/>
31+
</section>
32+
33+
<section name="AdminNewCatalogPriceRuleActions">
34+
<element name="apply" type="select" selector="[name='simple_action']"/>
35+
<element name="discountAmount" type="input" selector="[name='discount_amount']"/>
36+
<element name="disgardRules" type="select" selector="[name='stop_rules_processing']"/>
37+
</section>
38+
39+
<section name="AdminCatalogPriceRuleGrid">
40+
<element name="applyRules" type="button" selector="#apply_rules" timeout="30"/>
41+
</section>
42+
</sections>

0 commit comments

Comments
 (0)