Skip to content

Commit e5b218d

Browse files
committed
MC-62: Admin should be able to create a cart price rule of type Fixed amount discount
- Made tests more robust - Clean up after better
1 parent a95ef1e commit e5b218d

File tree

5 files changed

+38
-1
lines changed

5 files changed

+38
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="DeleteCartPriceRuleByName">
11+
<arguments>
12+
<argument name="ruleName" type="string"/>
13+
</arguments>
14+
<amOnPage url="{{AdminCartPriceRulesPage.url}}" stepKey="amOnCartPriceList"/>
15+
<waitForPageLoad stepKey="waitForPriceList"/>
16+
<fillField selector="{{AdminCartPriceRulesSection.filterByNameInput}}" userInput="{{ruleName}}" stepKey="filterByName"/>
17+
<click selector="{{AdminCartPriceRulesSection.searchButton}}" stepKey="doFilter"/>
18+
<click selector="{{AdminCartPriceRulesSection.rowByIndex('1')}}" stepKey="goToEditRulePage"/>
19+
<click selector="{{AdminCartPriceRulesFormSection.delete}}" stepKey="clickDeleteButton"/>
20+
<click selector="{{AdminCartPriceRulesFormSection.modalAcceptButton}}" stepKey="confirmDelete"/>
21+
</actionGroup>
22+
</actionGroups>

dev/tests/acceptance/tests/functional/Magento/FunctionalTest/SalesRule/Section/AdminCartPriceRulesFormSection.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
1010
<section name="AdminCartPriceRulesFormSection">
1111
<element name="save" type="button" selector="#save" timeout="30"/>
12+
<element name="delete" type="button" selector="#delete" timeout="30"/>
13+
<element name="modalAcceptButton" type="button" selector="button.action-accept" timeout="30"/>
1214

1315
<!-- Rule Information (the main form on the page) -->
1416
<element name="ruleInformationHeader" type="button" selector="div[data-index='rule_information']" timeout="30"/>

dev/tests/acceptance/tests/functional/Magento/FunctionalTest/SalesRule/Section/AdminCartPriceRulesSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@
1414
<element name="searchButton" type="button" selector="#promo_quote_grid button[title='Search']" timeout="30"/>
1515
<element name="nameColumns" type="text" selector="td[data-column='name']"/>
1616
<element name="rowContainingText" type="text" selector="//*[@id='promo_quote_grid_table']/tbody/tr[td//text()[contains(., '{{var1}}')]]" parameterized="true" timeout="30"/>
17+
<element name="rowByIndex" type="text" selector="tr[data-role='row']:nth-of-type({{var1}})" parameterized="true" timeout="30"/>
1718
</section>
1819
</sections>

dev/tests/acceptance/tests/functional/Magento/FunctionalTest/SalesRule/Test/AdminCreateCartPriceRuleForCouponCodeTest.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,17 @@
2424
</before>
2525

2626
<after>
27+
<!-- Delete the cart price rule we made during the test -->
28+
<actionGroup ref="DeleteCartPriceRuleByName" stepKey="cleanUpRule">
29+
<argument name="ruleName" value="{{_defaultCoupon.code}}"/>
30+
</actionGroup>
31+
2732
<amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/>
2833
</after>
2934

3035
<!-- Create a cart price rule based on a coupon code -->
3136
<amOnPage url="{{AdminCartPriceRulesPage.url}}" stepKey="amOnCartPriceList"/>
37+
<waitForPageLoad stepKey="waitForPriceList"/>
3238
<click selector="{{AdminCartPriceRulesSection.addNewRuleButton}}" stepKey="clickAddNewRule"/>
3339
<fillField selector="{{AdminCartPriceRulesFormSection.ruleName}}" userInput="{{_defaultCoupon.code}}" stepKey="fillRuleName"/>
3440
<selectOption selector="{{AdminCartPriceRulesFormSection.websites}}" userInput="Main Website" stepKey="selectWebsites"/>

dev/tests/acceptance/tests/functional/Magento/FunctionalTest/SalesRule/Test/AdminCreateFixedAmountDiscountTest.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,17 @@
2525
</before>
2626

2727
<after>
28-
<amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/>
28+
<!-- Delete the cart price rule we made during the test -->
29+
<actionGroup ref="DeleteCartPriceRuleByName" stepKey="cleanUpRule">
30+
<argument name="ruleName" value="{{_defaultCoupon.code}}"/>
31+
</actionGroup>
2932
<deleteData createDataKey="createPreReqCategory" stepKey="deletePreReqCategory"/>
33+
<amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/>
3034
</after>
3135

3236
<!-- Create a cart price rule for $10 Fixed amount discount -->
3337
<amOnPage url="{{AdminCartPriceRulesPage.url}}" stepKey="amOnCartPriceList"/>
38+
<waitForPageLoad stepKey="waitForRulesPage"/>
3439
<click selector="{{AdminCartPriceRulesSection.addNewRuleButton}}" stepKey="clickAddNewRule"/>
3540
<fillField selector="{{AdminCartPriceRulesFormSection.ruleName}}" userInput="{{_defaultCoupon.code}}" stepKey="fillRuleName"/>
3641
<selectOption selector="{{AdminCartPriceRulesFormSection.websites}}" userInput="Main Website" stepKey="selectWebsites"/>
@@ -49,6 +54,7 @@
4954

5055
<!-- Spot check the storefront -->
5156
<amOnPage url="{{_defaultProduct.urlKey}}.html" stepKey="goToProductPage"/>
57+
<waitForPageLoad stepKey="waitForProductPageLoad"/>
5258
<click selector="{{StorefrontProductActionSection.addToCart}}" stepKey="addProductToCart"/>
5359
<amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToCartPage"/>
5460
<waitForPageLoad stepKey="waitForCartPage"/>

0 commit comments

Comments
 (0)