Skip to content

Commit 2828abf

Browse files
committed
ACQE-8526: Cart Price Rules with coupon and general percent discount can be applied in the same time for one cart
- Created test file
1 parent b28144a commit 2828abf

File tree

2 files changed

+120
-0
lines changed

2 files changed

+120
-0
lines changed

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

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,4 +721,63 @@
721721
<data key="defaultRuleLabelAllStoreViews">Total Items Quantity-Not Applied test</data>
722722
<data key="defaultStoreView">Total Items Quantity-Not Applied test</data>
723723
</entity>
724+
<entity name="AutoRule50Percent" type="SalesRule">
725+
<data key="name">AutoRule50%</data>
726+
<data key="description">Automatic 50% off</data>
727+
<array key="website_ids">
728+
<item>1</item>
729+
</array>
730+
<array key="customer_group_ids">
731+
<item>0</item>
732+
<item>1</item>
733+
<item>2</item>
734+
<item>3</item>
735+
</array>
736+
<data key="uses_per_customer">0</data>
737+
<data key="is_active">true</data>
738+
<data key="stop_rules_processing">false</data>
739+
<data key="is_advanced">true</data>
740+
<data key="sort_order">0</data>
741+
<data key="simple_action">by_percent</data>
742+
<data key="discount_amount">50</data>
743+
<data key="discount_qty">0</data>
744+
<data key="discount_step">0</data>
745+
<data key="apply_to_shipping">false</data>
746+
<data key="times_used">0</data>
747+
<data key="is_rss">false</data>
748+
<data key="coupon_type">NO_COUPON</data>
749+
<data key="use_auto_generation">false</data>
750+
<data key="uses_per_coupon">0</data>
751+
<data key="simple_free_shipping">1</data>
752+
</entity>
753+
<entity name="TenDollarDiscount" type="SalesRule">
754+
<data key="name" unique="suffix">10USD_coupon</data>
755+
<data key="description">Cart Price Rule with complex conditions</data>
756+
<data key="is_active">Yes</data>
757+
<array key="website_ids">
758+
<item>1</item>
759+
</array>
760+
<array key="customer_group_ids">
761+
<item>0</item>
762+
<item>1</item>
763+
<item>2</item>
764+
<item>3</item>
765+
</array>
766+
<data key="coupon_type">SPECIFIC_COUPON</data>
767+
<data key="use_auto_generation">false</data>
768+
<data key="coupon_code" unique="suffix">12345</data>
769+
<data key="sort_order">1</data>
770+
<data key="simple_action">by_fixed</data>
771+
<data key="discount_amount">10</data>
772+
<data key="uses_per_customer">15</data>
773+
<data key="stop_rules_processing">false</data>
774+
<data key="discount_qty">1</data>
775+
<data key="discount_step">0</data>
776+
<data key="apply_to_shipping">false</data>
777+
<data key="is_advanced">true</data>
778+
<data key="times_used">0</data>
779+
<data key="is_rss">false</data>
780+
<data key="uses_per_coupon">10</data>
781+
<data key="simple_free_shipping">1</data>
782+
</entity>
724783
</entities>
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright 2025 Adobe
5+
* All Rights Reserved.
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="StorefrontCartPriceRuleAutoAndCouponTest">
12+
<annotations>
13+
<features value="SalesRule"/>
14+
<title value="Verify auto and coupon cart price rules apply together in cart"/>
15+
<stories value="Verifies that both an automatic 50% discount and a $10 coupon discount are applied correctly in the shopping cart."/>
16+
<description value="Checks 50% auto discount, $10 off with '1234' coupon, correct totals, and 'Discount Subsequent Rules' disabled in Cart Price Rule settings."/>
17+
<testCaseId value="AC-5133"/>
18+
<severity value="MAJOR"/>
19+
<group value="SalesRule"/>
20+
</annotations>
21+
<before>
22+
<!-- Precondition1: Create simple product with price $100 -->
23+
<createData entity="SimpleProduct2" stepKey="createSimpleProduct">
24+
<field key="price">100</field>
25+
</createData>
26+
<!-- Precondition 2: Create two cart price rules -->
27+
<createData entity="TenDollarDiscount" stepKey="createCouponRule"/>
28+
<createData entity="ApiSalesRuleCoupon" stepKey="createCartPriceRuleCoupon">
29+
<requiredEntity createDataKey="createCouponRule"/>
30+
</createData>
31+
<createData entity="AutoRule50Percent" stepKey="createCouponRule2"/>
32+
</before>
33+
<after>
34+
<deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/>
35+
<deleteData createDataKey="createCouponRule" stepKey="deleteCartPriceRule"/>
36+
<deleteData createDataKey="createCouponRule2" stepKey="deleteCartPriceRule2"/>
37+
</after>
38+
<!-- Step 1 and Step 2: Go to storefront and add simple product to the cart -->
39+
<actionGroup ref="OpenStoreFrontProductPageActionGroup" stepKey="navigateToSimpleProductPage">
40+
<argument name="productUrlKey" value="$$createSimpleProduct.custom_attributes[url_key]$$"/>
41+
</actionGroup>
42+
<actionGroup ref="AddToCartFromStorefrontProductPageActionGroup" stepKey="addProductToCart">
43+
<argument name="productName" value="$$createSimpleProduct.name$$"/>
44+
<argument name="productCount" value="1"/>
45+
</actionGroup>
46+
<!-- Step 3: Go to shopping cart page -->
47+
<actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goToCartPage"/>
48+
<!-- Validate auto 50% discount is applied -->
49+
<waitForText selector="{{CheckoutCartSummarySection.subtotal}}" userInput="$100.00" stepKey="seeSubtotalBeforeCoupon"/>
50+
<waitForText selector="{{CheckoutCartSummarySection.discountAmount}}" userInput="-$50.00" stepKey="seeDiscountBeforeCoupon"/>
51+
<waitForText selector="{{CheckoutCartSummarySection.total}}" userInput="$50.00" stepKey="seeOrderTotalBeforeCoupon"/>
52+
<!-- Step 4: Apply discount code from second rule -->
53+
<actionGroup ref="StorefrontApplyCouponActionGroup" stepKey="applyCoupon">
54+
<argument name="coupon" value="$$createCartPriceRuleCoupon$$"/>
55+
</actionGroup>
56+
<!-- Validate both discounts are applied correctly -->
57+
<waitForText selector="{{CheckoutCartSummarySection.subtotal}}" userInput="$100.00" stepKey="seeSubtotalAfterCoupon"/>
58+
<waitForText selector="{{CheckoutCartSummarySection.discountAmount}}" userInput="-$60.00" stepKey="seeDiscountAfterCoupon"/>
59+
<waitForText selector="{{CheckoutCartSummarySection.total}}" userInput="$40.00" stepKey="seeOrderTotalAfterCoupon"/>
60+
</test>
61+
</tests>

0 commit comments

Comments
 (0)