Skip to content

Commit 2c44df0

Browse files
committed
ACP2E-1551: Customer cannot use a distinct coupon code from the same Cart Price Rule.
1 parent 3b7c0e9 commit 2c44df0

File tree

1 file changed

+136
-0
lines changed

1 file changed

+136
-0
lines changed
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
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="AdminCartPriceRuleForAutoTypeUsesPerCouponTest">
12+
<annotations>
13+
<features value="SalesRule"/>
14+
<stories value="Create cart price rule"/>
15+
<title value="Customer cannot use a distinct coupon code from the same Cart Price Rule."/>
16+
<description value="Customer cannot use a distinct coupon code from the same Cart Price Rule."/>
17+
<severity value="CRITICAL"/>
18+
<testCaseId value="AC-7872"/>
19+
<useCaseId value="ACP2E-1551"/>
20+
<group value="SalesRule"/>
21+
</annotations>
22+
23+
<before>
24+
<!-- Create Customer with filled Shipping & Billing Address -->
25+
<createData entity="CustomerEntityOne" stepKey="createCustomer"/>
26+
<!--Create simple product-->
27+
<createData entity="SimpleProduct2" stepKey="createSimpleProduct"/>
28+
29+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
30+
</before>
31+
32+
<after>
33+
<!--Delete simple product created during the test-->
34+
<deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/>
35+
<!-- Delete the cart price rule we made during the test -->
36+
<actionGroup ref="DeleteCartPriceRuleByName" stepKey="cleanUpRule">
37+
<argument name="ruleName" value="{{_defaultCoupon.code}}"/>
38+
</actionGroup>
39+
<!--Delete customer created during test-->
40+
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
41+
42+
<actionGroup ref="AdminLogoutActionGroup" stepKey="adminLogout"/>
43+
</after>
44+
45+
<!-- Create a cart price rule -->
46+
<actionGroup ref="AdminOpenCartPriceRulesPageActionGroup" stepKey="amOnCartPriceList"/>
47+
<click selector="{{AdminCartPriceRulesSection.addNewRuleButton}}" stepKey="clickAddNewRule"/>
48+
<fillField selector="{{AdminCartPriceRulesFormSection.ruleName}}" userInput="{{_defaultCoupon.code}}" stepKey="fillRuleName"/>
49+
<selectOption selector="{{AdminCartPriceRulesFormSection.websites}}" userInput="Main Website" stepKey="selectWebsites"/>
50+
<!-- Select custom customer groups -->
51+
<click selector="{{CartPriceRuleSection.customerGroupsToggle}}" stepKey="clickCustomerGroupsToggle" after="selectWebsites"/>
52+
<click selector="{{CartPriceRuleSection.selectAll}}" stepKey="clickSelectAll" after="clickCustomerGroupsToggle"/>
53+
<click selector="{{CartPriceRuleSection.doneButton}}" stepKey="clickDoneButton" after="clickSelectAll"/>
54+
<!-- Choose coupon type auto -->
55+
<selectOption selector="{{AdminCartPriceRulesFormSection.coupon}}" userInput="Auto" stepKey="selectCouponType"/>
56+
<!-- Verify `Use Auto Generation` checkbox not visible while `Uses per Coupon` field there for coupon type auto-->
57+
<dontSeeCheckboxIsChecked selector="{{AdminCartPriceRulesFormSection.useAutoGeneration}}" stepKey="tickAutoGeneration"/>
58+
<fillField selector="{{AdminCartPriceRulesFormSection.userPerCoupon}}" userInput="1" stepKey="fillUsesPerCoupon"/>
59+
<!--Open Actions tabs, fill required field and save the cart price rule-->
60+
<click selector="{{AdminCartPriceRulesFormSection.actionsHeader}}" stepKey="clickToExpandActions"/>
61+
<selectOption selector="{{AdminCartPriceRulesFormSection.apply}}" userInput="{{CatPriceRule.apply}}" stepKey="selectActionType"/>
62+
<fillField selector="{{AdminCartPriceRulesFormSection.discountAmount}}" userInput="{{CatPriceRule.discountAmount}}" stepKey="fillDiscountAmount"/>
63+
<click selector="{{AdminCartPriceRulesFormSection.saveAndContinue}}" stepKey="clickSaveAndContinueButton"/>
64+
<see selector="{{AdminCartPriceRulesSection.messages}}" userInput="You saved the rule." stepKey="seeRuleSavedSuccessMessage"/>
65+
<waitForPageLoad stepKey="waitForPageToLoad"/>
66+
67+
<!-- Generate some coupon codes -->
68+
<click selector="{{AdminCartPriceRulesFormSection.manageCouponCodesHeader}}" stepKey="expandCouponSection"/>
69+
<fillField selector="{{AdminCartPriceRulesFormSection.couponQty}}" userInput="5" stepKey="fillCouponQty"/>
70+
<click selector="{{AdminCartPriceRulesFormSection.generateCouponsButton}}" stepKey="clickGenerate"/>
71+
<see selector="{{AdminCartPriceRulesFormSection.successMessage}}" userInput="Message is added to queue, wait to get your coupons soon" stepKey="seeGenerationSuccess"/>
72+
73+
<!--Start coupon code generator queue-->
74+
<actionGroup ref="CliConsumerStartActionGroup" stepKey="startMessageQueue">
75+
<argument name="consumerName" value="{{AdminCodeGeneratorMessageConsumerData.consumerName}}"/>
76+
<argument name="maxMessages" value="1"/>
77+
</actionGroup>
78+
79+
<!--Reload cart price rule page-->
80+
<actionGroup ref="ReloadPageActionGroup" stepKey="refreshPage"/>
81+
82+
<!--Open Manage Coupon Codes tab again to see generated coupon codes-->
83+
<click selector="{{AdminCartPriceRulesFormSection.manageCouponCodesHeader}}" stepKey="expandCouponSectionSecondTime"/>
84+
<scrollTo selector="{{AdminCartPriceRulesFormSection.couponGridUsedHeader}}" stepKey="scrollToCouponGridUsedHeader"/>
85+
<waitForElementVisible selector="{{AdminCartPriceRulesFormSection.couponGridUsedHeader}}" stepKey="waitForNewRule"/>
86+
87+
<!--Assert coupon codes grid header is correct -->
88+
<see selector="{{AdminCartPriceRulesFormSection.couponGridUsedHeader}}" userInput="Used" stepKey="seeCorrectUsedHeader"/>
89+
90+
<!--Grab two coupon codes and hold on to it for later use -->
91+
<grabTextFrom selector="{{AdminCartPriceRulesFormSection.generatedCouponByIndex('1')}}" stepKey="couponCode"/>
92+
<grabTextFrom selector="{{AdminCartPriceRulesFormSection.generatedCouponByIndex('2')}}" stepKey="couponCode2"/>
93+
94+
<!-- Login with created Customer -->
95+
<actionGroup ref="LoginToStorefrontActionGroup" stepKey="loginAsCustomer">
96+
<argument name="Customer" value="$$createCustomer$$"/>
97+
</actionGroup>
98+
99+
<!--Open the Product Page, add the product to Cart, go to Shopping Cart and Apply the first coupon code -->
100+
<amOnPage url="{{StorefrontProductPage.url($$createSimpleProduct.custom_attributes[url_key]$$)}}" stepKey="openProductPage"/>
101+
<actionGroup ref="ApplyCartRuleOnStorefrontActionGroup" stepKey="applyCartPriceRule">
102+
<argument name="product" value="$$createSimpleProduct$$"/>
103+
<argument name="couponCode" value="{$couponCode}"/>
104+
</actionGroup>
105+
<waitForText userInput='You used coupon code "{$couponCode}"' stepKey="waitForText"/>
106+
<see selector="{{StorefrontMessagesSection.success}}" userInput='You used coupon code "{$couponCode}"' stepKey="seeSuccessMessage"/>
107+
<waitForElementVisible selector="{{CheckoutCartSummarySection.discountAmount}}" time="30" stepKey="waitForElementDiscountVisible"/>
108+
109+
<!-- Go to Checkout and Click Place Order button -->
110+
<actionGroup ref="StorefrontClickProceedToCheckoutActionGroup" stepKey="clickProceedToCheckout"/>
111+
<click selector="{{CheckoutShippingMethodsSection.checkShippingMethodByName('Flat Rate')}}"
112+
stepKey="selectFlatShippingMethod"/>
113+
<waitForLoadingMaskToDisappear stepKey="waitForLoadingMask"/>
114+
<actionGroup ref="StorefrontCheckoutClickNextButtonActionGroup" stepKey="clickNext"/>
115+
<!-- Checkout select Check/Money Order payment -->
116+
<actionGroup ref="CheckoutSelectCheckMoneyOrderPaymentActionGroup" stepKey="selectCheckMoneyPayment"/>
117+
<actionGroup ref="ClickPlaceOrderActionGroup" stepKey="clickPlaceOrder"/>
118+
119+
<!-- Start the usage processing consumer -->
120+
<actionGroup ref="CliConsumerStartActionGroup" stepKey="startUsageProcessingMessageQueue1">
121+
<argument name="consumerName" value="{{SalesRuleConsumerData.consumerName}}"/>
122+
<argument name="maxMessages" value="{{SalesRuleConsumerData.messageLimit}}"/>
123+
</actionGroup>
124+
125+
<!-- Open the Product Page again, add the product to Cart, go to Shopping Cart and Apply the second coupon code -->
126+
<amOnPage url="{{StorefrontProductPage.url($$createSimpleProduct.custom_attributes[url_key]$$)}}" stepKey="openProductPage2"/>
127+
<waitForPageLoad stepKey="waitForPageLoad2"/>
128+
<actionGroup ref="ApplyCartRuleOnStorefrontActionGroup" stepKey="applyCartPriceRule2">
129+
<argument name="product" value="$$createSimpleProduct$$"/>
130+
<argument name="couponCode" value="{$couponCode2}"/>
131+
</actionGroup>
132+
<waitForText userInput='You used coupon code "{$couponCode2}"' stepKey="waitForText2"/>
133+
<see selector="{{StorefrontMessagesSection.success}}" userInput='You used coupon code "{$couponCode2}"' stepKey="seeSuccessMessage2"/>
134+
<waitForElementVisible selector="{{CheckoutCartSummarySection.discountAmount}}" time="30" stepKey="waitForElementDiscountVisible2"/>
135+
</test>
136+
</tests>

0 commit comments

Comments
 (0)