Skip to content

Commit 8b02118

Browse files
committed
MC-75: Admin should be able to create a cart price rule for auto generated coupon codes
1 parent 609d1f1 commit 8b02118

File tree

2 files changed

+88
-0
lines changed

2 files changed

+88
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
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="saveAndContinue" type="button" selector="#save_and_continue" timeout="30"/>
1213
<element name="delete" type="button" selector="#delete" timeout="30"/>
1314
<element name="modalAcceptButton" type="button" selector="button.action-accept" timeout="30"/>
1415

@@ -19,11 +20,19 @@
1920
<element name="customerGroups" type="multiselect" selector="select[name='customer_group_ids']"/>
2021
<element name="coupon" type="select" selector="select[name='coupon_type']"/>
2122
<element name="couponCode" type="input" selector="input[name='coupon_code']"/>
23+
<element name="useAutoGeneration" type="checkbox" selector="input[name='use_auto_generation']"/>
2224

2325
<!-- Actions sub-form -->
2426
<element name="actionsHeader" type="button" selector="div[data-index='actions']" timeout="30"/>
2527
<element name="apply" type="select" selector="select[name='simple_action']"/>
2628
<element name="discountAmount" type="input" selector="input[name='discount_amount']"/>
2729
<element name="discountStep" type="input" selector="input[name='discount_step']"/>
30+
31+
<!-- Manage Coupon Codes sub-form -->
32+
<element name="manageCouponCodesHeader" type="button" selector="div[data-index='manage_coupon_codes']" timeout="30"/>
33+
<element name="successMessage" type="text" selector="div.message.message-success.success"/>
34+
<element name="couponQty" type="input" selector="#coupons_qty"/>
35+
<element name="generateCouponsButton" type="button" selector="#coupons_generate_button" timeout="30"/>
36+
<element name="generatedCouponByIndex" type="text" selector="#couponCodesGrid_table > tbody > tr:nth-child({{var}}) > td.col-code" parameterized="true"/>
2837
</section>
2938
</sections>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd">
11+
<test name="AdminCreateCartPriceRuleForGeneratedCouponTest">
12+
<annotations>
13+
<features value="SalesRule"/>
14+
<stories value="Create cart price rule"/>
15+
<title value="Admin should be able to create a cart price rule for auto generated coupon codes"/>
16+
<description value="Admin should be able to create a cart price rule for auto generated coupon codes"/>
17+
<severity value="AVERAGE"/>
18+
<testCaseId value="MC-75"/>
19+
<group value="SalesRule"/>
20+
</annotations>
21+
22+
<before>
23+
<createData entity="_defaultCategory" stepKey="createPreReqCategory"/>
24+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
25+
</before>
26+
27+
<after>
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>
32+
<deleteData createDataKey="createPreReqCategory" stepKey="deletePreReqCategory"/>
33+
<amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/>
34+
</after>
35+
36+
<!-- Create a cart price rule -->
37+
<amOnPage url="{{AdminCartPriceRulesPage.url}}" stepKey="amOnCartPriceList"/>
38+
<waitForPageLoad stepKey="waitForPriceList"/>
39+
<click selector="{{AdminCartPriceRulesSection.addNewRuleButton}}" stepKey="clickAddNewRule"/>
40+
<fillField selector="{{AdminCartPriceRulesFormSection.ruleName}}" userInput="{{_defaultCoupon.code}}" stepKey="fillRuleName"/>
41+
<selectOption selector="{{AdminCartPriceRulesFormSection.websites}}" userInput="Main Website" stepKey="selectWebsites"/>
42+
<selectOption selector="{{AdminCartPriceRulesFormSection.customerGroups}}" userInput="NOT LOGGED IN" stepKey="selectCustomerGroup"/>
43+
<selectOption selector="{{AdminCartPriceRulesFormSection.coupon}}" userInput="Specific Coupon" stepKey="selectCouponType"/>
44+
<checkOption selector="{{AdminCartPriceRulesFormSection.useAutoGeneration}}" stepKey="tickAutoGeneration"/>
45+
<click selector="{{AdminCartPriceRulesFormSection.actionsHeader}}" stepKey="clickToExpandActions"/>
46+
<selectOption selector="{{AdminCartPriceRulesFormSection.apply}}" userInput="Fixed amount discount for whole cart" stepKey="selectActionType"/>
47+
<fillField selector="{{AdminCartPriceRulesFormSection.discountAmount}}" userInput="0.99" stepKey="fillDiscountAmount"/>
48+
<click selector="{{AdminCartPriceRulesFormSection.saveAndContinue}}" stepKey="clickSaveAndContinueButton"/>
49+
50+
<!-- Generate some coupon codes -->
51+
<click selector="{{AdminCartPriceRulesFormSection.manageCouponCodesHeader}}" stepKey="expandCouponSection"/>
52+
<fillField selector="{{AdminCartPriceRulesFormSection.couponQty}}" userInput="10" stepKey="fillCouponQty"/>
53+
<click selector="{{AdminCartPriceRulesFormSection.generateCouponsButton}}" stepKey="clickGenerate"/>
54+
<see selector="{{AdminCartPriceRulesFormSection.successMessage}}" userInput="10 coupon(s) have been generated." stepKey="seeGenerationSuccess"/>
55+
56+
<!-- Grab a coupon code and hold on to it for later -->
57+
<grabTextFrom selector="{{AdminCartPriceRulesFormSection.generatedCouponByIndex('1')}}" stepKey="grabCouponCode"/>
58+
59+
<!-- Create a product to check the storefront -->
60+
<actionGroup ref="FillAdminSimpleProductForm" stepKey="fillProductFieldsInAdmin">
61+
<argument name="category" value="$$createPreReqCategory$$"/>
62+
<argument name="simpleProduct" value="_defaultProduct"/>
63+
</actionGroup>
64+
65+
<!-- Spot check the storefront -->
66+
<amOnPage url="{{_defaultProduct.urlKey}}.html" stepKey="goToProductPage"/>
67+
<waitForPageLoad stepKey="waitForProductPageLoad"/>
68+
<click selector="{{StorefrontProductActionSection.addToCart}}" stepKey="addProductToCart"/>
69+
<amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToCartPage"/>
70+
<waitForPageLoad stepKey="waitForCartPage"/>
71+
<conditionalClick selector="{{StorefrontSalesRuleCartCouponSection.couponHeader}}" dependentSelector="{{StorefrontSalesRuleCartCouponSection.discountBlockActive}}" visible="false" stepKey="clickCouponHeader"/>
72+
<waitForElementVisible selector="{{StorefrontSalesRuleCartCouponSection.couponField}}" stepKey="waitForCouponField" />
73+
<fillField selector="{{StorefrontSalesRuleCartCouponSection.couponField}}" userInput="{$grabCouponCode}" stepKey="fillCouponField"/>
74+
<click selector="{{StorefrontSalesRuleCartCouponSection.applyButton}}" stepKey="clickApplyButton"/>
75+
<waitForPageLoad stepKey="waitForProductPageLoad2"/>
76+
<waitForElementVisible selector="{{CheckoutCartSummarySection.discountAmount}}" stepKey="waitForDiscountElement"/>
77+
<see selector="{{CheckoutCartSummarySection.discountAmount}}" userInput="-$0.99" stepKey="seeDiscountTotal"/>
78+
</test>
79+
</tests>

0 commit comments

Comments
 (0)