Skip to content

Commit ec229a9

Browse files
MC-42288: Coupon codes for existing cart price rule are not generated
- Add MFTF test
1 parent 1eb5b9f commit ec229a9

File tree

3 files changed

+79
-0
lines changed

3 files changed

+79
-0
lines changed

app/code/Magento/SalesRule/Test/Mftf/Data/SalesRuleData.xml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,4 +476,30 @@
476476
<data key="discountAmount">one</data>
477477
<data key="maximumQtyDiscount">one</data>
478478
</entity>
479+
480+
<entity name="SalesRuleNoCoupon" type="SalesRule">
481+
<data key="name" unique="suffix">SalesRuleNoCoupon</data>
482+
<data key="description">Sales Rule with No Coupon</data>
483+
<data key="is_active">true</data>
484+
<array key="website_ids">
485+
<item>1</item>
486+
</array>
487+
<array key="customer_group_ids">
488+
<item>0</item>
489+
</array>
490+
<data key="coupon_type">NO_COUPON</data>
491+
<data key="uses_per_customer">0</data>
492+
<data key="stop_rules_processing">false</data>
493+
<data key="sort_order">0</data>
494+
<data key="simple_action">by_percent</data>
495+
<data key="discount_amount">0</data>
496+
<data key="discount_qty">0</data>
497+
<data key="discount_step">0</data>
498+
<data key="apply_to_shipping">false</data>
499+
<data key="times_used">0</data>
500+
<data key="is_rss">false</data>
501+
<data key="use_auto_generation">false</data>
502+
<data key="uses_per_coupon">0</data>
503+
<data key="simple_free_shipping">0</data>
504+
</entity>
479505
</entities>

app/code/Magento/SalesRule/Test/Mftf/Section/AdminCartPriceRulesFormSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,5 +104,6 @@
104104
<element name="generatedCouponByIndex" type="text" selector="#couponCodesGrid_table > tbody > tr:nth-child({{var}}) > td.col-code" parameterized="true"/>
105105
<element name="couponGridUsedHeader" type="text" selector="#couponCodesGrid thead th[data-sort='used']"/>
106106
<element name="fieldError" type="text" selector="//input[@name='{{fieldName}}']/following-sibling::label[@class='admin__field-error']" parameterized="true"/>
107+
<element name="modalMessage" type="text" selector="aside.modal-popup div.modal-content div"/>
107108
</section>
108109
</sections>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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="AdminBlockCouponGenerateUntilRuleIsSavedWithAutoOptionTest">
12+
<annotations>
13+
<features value="SalesRule"/>
14+
<stories value="Create cart price rule"/>
15+
<title value="Block the coupon generates until cart price rule is saved with auto generate option enabled"/>
16+
<description
17+
value="Block the coupon generates until cart price rule is saved with auto generate option enabled"/>
18+
<testCaseId value="MC-42288"/>
19+
<group value="salesRule"/>
20+
</annotations>
21+
22+
<before>
23+
<createData entity="SalesRuleNoCoupon" stepKey="createSalesRule"/>
24+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
25+
</before>
26+
27+
<after>
28+
<deleteData createDataKey="createSalesRule" stepKey="deleteSalesRule"/>
29+
<actionGroup ref="AdminLogoutActionGroup" stepKey="adminLogout"/>
30+
</after>
31+
32+
<!-- Search Cart Price Rule and go to edit Cart Price Rule -->
33+
<actionGroup ref="AdminOpenCartPriceRulesPageActionGroup" stepKey="amOnCartPriceList"/>
34+
<fillField selector="{{AdminCartPriceRulesSection.filterByNameInput}}" userInput="$$createSalesRule.name$$"
35+
stepKey="fillFieldFilterByName"/>
36+
<click selector="{{AdminCartPriceRulesSection.searchButton}}" stepKey="clickSearchButton"/>
37+
<see selector="{{AdminCartPriceRulesSection.nameColumns}}" userInput="$$createSalesRule.name$$"
38+
stepKey="seeRuleName"/>
39+
<click selector="{{AdminCartPriceRulesSection.rowContainingText($$createSalesRule.name$$)}}"
40+
stepKey="goToEditRule"/>
41+
42+
<!-- Choose coupon type auto and generate coupon without saving the rule -->
43+
<selectOption selector="{{AdminCartPriceRulesFormSection.coupon}}" userInput="Auto" stepKey="selectCouponType"/>
44+
<conditionalClick selector="{{AdminCartPriceRulesFormSection.manageCouponCodesHeader}}"
45+
dependentSelector="{{AdminCartPriceRulesFormSection.manageCouponCodesHeader}}" visible="true"
46+
stepKey="clickManageCouponCodes"/>
47+
<fillField selector="{{AdminCartPriceRulesFormSection.couponQty}}" userInput="1" stepKey="fillFieldCouponQty"/>
48+
<click selector="{{AdminCartPriceRulesFormSection.generateCouponsButton}}" stepKey="clickGenerateCoupon"/>
49+
<see selector="{{AdminCartPriceRulesFormSection.modalMessage}}" userInput="Rule is not saved with auto generate option enabled. Please save the rule and try again."
50+
stepKey="seeModalMessage"/>
51+
</test>
52+
</tests>

0 commit comments

Comments
 (0)