Skip to content

Commit 9c09485

Browse files
committed
#30255:#30255: Fixed The coupon code has been accepted message
Fixed Static test Added MFTF Test to Verify Remove coupon code
1 parent 16e962d commit 9c09485

File tree

4 files changed

+120
-3
lines changed

4 files changed

+120
-3
lines changed

app/code/Magento/Sales/Controller/Adminhtml/Order/Create.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,9 +344,9 @@ protected function _processActionData($action = null)
344344
$this->messageManager->addSuccessMessage(__('The coupon code has been accepted.'));
345345
}
346346
}
347-
} else if (isset($data['coupon']['code']) && empty($couponCode)) {
348-
$this->messageManager->addSuccessMessage(__('The coupon has been removed.'));
349-
}
347+
} elseif (isset($data['coupon']['code']) && empty($couponCode)) {
348+
$this->messageManager->addSuccessMessage(__('The coupon code has been removed.'));
349+
}
350350

351351
return $this;
352352
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AdminRemoveCouponFromOrderActionGroup">
12+
<click selector="{{AdminOrderFormItemsSection.removeCoupon}}" stepKey="removeCoupon"/>
13+
<waitForPageLoad stepKey="waitForRemovingCoupon"/>
14+
<see selector="{{AdminOrderDetailsMessagesSection.successMessage}}" userInput="The coupon code has been removed." stepKey="seeSuccessMessage"/>
15+
</actionGroup>
16+
</actionGroups>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,6 @@
3535
<element name="configure" type="button" selector=".product-configure-block button.action-default.scalable" timeout="30"/>
3636
<element name="couponCode" type="input" selector="#order-coupons input" timeout="30"/>
3737
<element name="applyCoupon" type="button" selector="#order-coupons button"/>
38+
<element name="removeCoupon" type="button" selector=".added-coupon-code .action-remove"/>
3839
</section>
3940
</sections>
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
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="AdminCreateOrderToVerifyApplyAndRemoveCouponCodeTest">
12+
<annotations>
13+
<stories value="Create Order with offline payment methods"/>
14+
<title value="Create Order to verify apply and remove coupon code test"/>
15+
<description value="Create Order to verify apply and remove coupon code test"/>
16+
<severity value="CRITICAL"/>
17+
<testCaseId value="MC-37386"/>
18+
<group value="sales"/>
19+
</annotations>
20+
<before>
21+
<!-- Login as admin -->
22+
<actionGroup ref="AdminLoginActionGroup" stepKey="LoginAsAdmin"/>
23+
24+
<!-- Create customer -->
25+
<createData entity="Simple_US_Customer" stepKey="createCustomer"/>
26+
27+
<!-- Create simple product -->
28+
<createData entity="SimpleProduct2" stepKey="createSimpleProduct">
29+
<field key="price">10</field>
30+
</createData>
31+
32+
<!-- Create sales rule with coupon -->
33+
<createData entity="SalesRuleSpecificCouponWithFixedDiscount" stepKey="createCartPriceRule"/>
34+
<createData entity="SimpleSalesRuleCoupon" stepKey="createCouponForCartPriceRule">
35+
<requiredEntity createDataKey="createCartPriceRule"/>
36+
</createData>
37+
38+
<!-- Enable Bank Transfer payment -->
39+
<magentoCLI command="config:set {{EnablePaymentBankTransferConfigData.path}} {{EnablePaymentBankTransferConfigData.value}}" stepKey="enableBankTransferPayment"/>
40+
41+
<!--Set default flat rate shipping method settings-->
42+
<magentoCLI command="config:set {{EnableFlatRateConfigData.path}} {{EnableFlatRateConfigData.value}}" stepKey="enableFlatRate"/>
43+
</before>
44+
<after>
45+
<!-- Disable Bank Transfer payment -->
46+
<magentoCLI command="config:set {{DisablePaymentBankTransferConfigData.path}} {{DisablePaymentBankTransferConfigData.value}}" stepKey="disableBankTransferPayment"/>
47+
48+
<!-- Delete sales rule -->
49+
<deleteData createDataKey="createCartPriceRule" stepKey="deleteCartPriceRule"/>
50+
51+
<!-- Delete customer -->
52+
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
53+
54+
<!-- Delete product -->
55+
<deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/>
56+
57+
<!-- Log out -->
58+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
59+
</after>
60+
61+
<!-- Create order -->
62+
<actionGroup ref="NavigateToNewOrderPageExistingCustomerActionGroup" stepKey="goToCreateOrderPage">
63+
<argument name="customer" value="$$createCustomer$$"/>
64+
</actionGroup>
65+
66+
<!-- Add product to order -->
67+
<actionGroup ref="AddSimpleProductToOrderActionGroup" stepKey="addProductToOrder">
68+
<argument name="product" value="$$createSimpleProduct$$"/>
69+
</actionGroup>
70+
71+
<!-- Apply coupon to the order -->
72+
<actionGroup ref="AdminApplyCouponToOrderActionGroup" stepKey="applyCoupon">
73+
<argument name="couponCode" value="$$createCouponForCartPriceRule.code$$"/>
74+
</actionGroup>
75+
76+
<!-- Remove coupon from the order -->
77+
<actionGroup ref="AdminRemoveCouponFromOrderActionGroup" stepKey="removeCoupon"/>
78+
79+
<!--Select FlatRate shipping method-->
80+
<actionGroup ref="AdminSelectFlatRateShippingMethodActionGroup" stepKey="selectFlatRateShippingMethod"/>
81+
82+
<!-- Select bank Transfer payment method -->
83+
<waitForElementVisible selector="{{AdminOrderFormPaymentSection.paymentBlock}}" stepKey="waitForPaymentOptions"/>
84+
<conditionalClick selector="{{AdminOrderFormPaymentSection.bankTransferOption}}" dependentSelector="{{AdminOrderFormPaymentSection.bankTransferOption}}" visible="true" stepKey="checkBankTransferOption"/>
85+
86+
<!-- Submit order -->
87+
<actionGroup ref="AdminSubmitOrderActionGroup" stepKey="submitOrder"/>
88+
89+
<!-- Grab order id -->
90+
<grabTextFrom selector="|Order # (\d+)|" stepKey="getOrderId"/>
91+
92+
<!-- Open created order -->
93+
<amOnPage url="{{AdminOrdersPage.url}}" stepKey="goToOrdersPage"/>
94+
<waitForPageLoad stepKey="waitForOrdersPageLoad"/>
95+
<actionGroup ref="FilterOrderGridByIdActionGroup" stepKey="filterOrdersGridById">
96+
<argument name="orderId" value="$getOrderId"/>
97+
</actionGroup>
98+
<click selector="{{AdminDataGridTableSection.firstRow}}" stepKey="clickCreatedOrderInGrid"/>
99+
</test>
100+
</tests>

0 commit comments

Comments
 (0)