Skip to content

Commit 1d94842

Browse files
MC-42612: Negative discount amount displays on order page in admin for product $0.00 price
- Add MFTF test coverage
1 parent f9c521f commit 1d94842

File tree

4 files changed

+115
-0
lines changed

4 files changed

+115
-0
lines changed

app/code/Magento/Sales/Test/Mftf/Section/AdminOrderTotalSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
1111
<section name="AdminOrderTotalSection">
1212
<element name="subTotal" type="text" selector=".order-subtotal-table tbody tr.col-0>td span.price"/>
13+
<element name="discount" type="text" selector=".order-subtotal-table tbody tr.col-1>td span.price"/>
1314
<element name="grandTotal" type="text" selector=".order-subtotal-table tfoot tr.col-0>td span.price"/>
1415
<element name="shippingDescription" type="text" selector="//table[contains(@class, 'order-subtotal-table')]//td[contains(text(), 'Shipping &amp; Handling')]"/>
1516
<element name="shippingAndHandling" type="text" selector="//table[contains(@class, 'order-subtotal-table')]//td[normalize-space(.)='Shipping &amp; Handling']/following-sibling::td//span[@class='price']"/>

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,4 +476,11 @@
476476
<data key="discountAmount">one</data>
477477
<data key="maximumQtyDiscount">one</data>
478478
</entity>
479+
480+
<entity name="SalesRuleSpecificCouponAndByPercent25" extends="SalesRuleSpecificCouponAndByPercent">
481+
<data key="discount_amount">25</data>
482+
<data key="discount_qty">0</data>
483+
<data key="discount_step">1</data>
484+
<data key="stop_rules_processing">true</data>
485+
</entity>
479486
</entities>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
11+
<section name="AdminOrderItemsOrderedSection">
12+
<element name="itemDiscountAmountByProductName" type="text" selector="//table[contains(@class,'edit-order-table')]//div[contains(text(),'{{productName}}')]/ancestor::tr//td[contains(@class, 'col-discont')]//span" parameterized="true"/>
13+
</section>
14+
</sections>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="StorefrontZeroPriceProductWithDiscountUsingCartPriceRuleTest">
11+
<annotations>
12+
<features value="SalesRule"/>
13+
<stories value="Create cart price rule"/>
14+
<title value="Zero price product should not have negative discount amount in order"/>
15+
<description value="Zero price product should not have negative discount amount in order"/>
16+
<severity value="MINOR"/>
17+
<testCaseId value="MC-42802"/>
18+
<useCaseId value="MC-42612"/>
19+
<group value="SalesRule"/>
20+
</annotations>
21+
<before>
22+
<!-- log in -->
23+
<actionGroup ref="AdminLoginActionGroup" stepKey="login"/>
24+
<!--Create 2 simple products-->
25+
<createData entity="SimpleProduct2" stepKey="simpleProduct1">
26+
<field key="price">33.50</field>
27+
</createData>
28+
<createData entity="SimpleProduct2" stepKey="simpleProduct2">
29+
<field key="price">0.00</field>
30+
</createData>
31+
<!--Create the sales rule-->
32+
<createData entity="SalesRuleSpecificCouponAndByPercent25" stepKey="createSalesRule"/>
33+
<createData entity="SimpleSalesRuleCoupon" stepKey="createCouponForCartPriceRule">
34+
<requiredEntity createDataKey="createSalesRule"/>
35+
</createData>
36+
</before>
37+
<after>
38+
<deleteData createDataKey="simpleProduct1" stepKey="DeleteSimpleProduct1" />
39+
<deleteData createDataKey="simpleProduct2" stepKey="DeleteSimpleProduct2" />
40+
<deleteData createDataKey="createSalesRule" stepKey="deleteSalesRule"/>
41+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
42+
</after>
43+
44+
<!-- Add the first product to the cart -->
45+
<actionGroup ref="StorefrontOpenProductEntityPageActionGroup" stepKey="goToProductPage1">
46+
<argument name="product" value="$$simpleProduct1$$"/>
47+
</actionGroup>
48+
<waitForPageLoad stepKey="waitForProductPageLoad1"/>
49+
<actionGroup ref="StorefrontClickAddToCartOnProductPageActionGroup" stepKey="addToCartFromStorefrontProductPage"/>
50+
51+
<!-- Add the second product to the cart -->
52+
<actionGroup ref="StorefrontOpenProductEntityPageActionGroup" stepKey="goToProductPage2">
53+
<argument name="product" value="$$simpleProduct2$$"/>
54+
</actionGroup>
55+
<waitForPageLoad stepKey="waitForProductPageLoad2"/>
56+
<actionGroup ref="StorefrontClickAddToCartOnProductPageActionGroup" stepKey="addToCartFromStorefrontProductPage2"/>
57+
58+
<!-- Go to cart and apply coupon -->
59+
<actionGroup ref="ClickViewAndEditCartFromMiniCartActionGroup" stepKey="clickMiniCart"/>
60+
<actionGroup ref="StorefrontApplyCouponActionGroup" stepKey="applyDiscount">
61+
<argument name="coupon" value="$$createCouponForCartPriceRule$$"/>
62+
</actionGroup>
63+
64+
<!-- Assert Discount amount in storefront-->
65+
<actionGroup ref="AssertStorefrontCartDiscountActionGroup" stepKey="seeDiscountTotal">
66+
<argument name="discount" value="8.38"/>
67+
</actionGroup>
68+
69+
<!-- Go to Checkout page -->
70+
<actionGroup ref="ClickViewAndEditCartFromMiniCartActionGroup" stepKey="goToShoppingCartFromMinicart"/>
71+
<actionGroup ref="StorefrontClickProceedToCheckoutActionGroup" stepKey="clickProceedToCheckout"/>
72+
73+
<!-- Fill email field and addresses form and go next -->
74+
<actionGroup ref="GuestCheckoutFillingShippingSectionActionGroup" stepKey="guestCheckoutFillingShipping">
75+
<argument name="shippingMethod" value="Flat Rate"/>
76+
</actionGroup>
77+
78+
<!-- Place Order -->
79+
<actionGroup ref="ClickPlaceOrderActionGroup" stepKey="clickOnPlaceOrder"/>
80+
<grabTextFrom selector="{{CheckoutSuccessMainSection.orderNumber}}" stepKey="grabOrderNumber"/>
81+
82+
<!-- Navigate to admin order details page -->
83+
<actionGroup ref="AdminOpenOrderByEntityIdActionGroup" stepKey="openOrderById">
84+
<argument name="entityId" value="$grabOrderNumber"/>
85+
</actionGroup>
86+
87+
<!-- Assert Discount amount in admin-->
88+
<see selector="{{AdminOrderItemsOrderedSection.itemDiscountAmountByProductName($simpleProduct1.name$)}}" userInput="$8.38" stepKey="seeProduct1DiscountAmount"/>
89+
<see selector="{{AdminOrderItemsOrderedSection.itemDiscountAmountByProductName($simpleProduct2.name$)}}" userInput="$0.00" stepKey="seeProduct2DiscountAmount"/>
90+
<see selector="{{AdminOrderTotalSection.discount}}" userInput="-$8.38" stepKey="seeDiscountAmount"/>
91+
92+
</test>
93+
</tests>

0 commit comments

Comments
 (0)