Skip to content

Commit

Permalink
#30255:#30255: Fixed The coupon code has been accepted message
Browse files Browse the repository at this point in the history
Fixed Static test
Added MFTF Test to Verify Remove coupon code
  • Loading branch information
shikhamis11 committed Oct 13, 2020
1 parent 16e962d commit 9c09485
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/code/Magento/Sales/Controller/Adminhtml/Order/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,9 @@ protected function _processActionData($action = null)
$this->messageManager->addSuccessMessage(__('The coupon code has been accepted.'));
}
}
} else if (isset($data['coupon']['code']) && empty($couponCode)) {
$this->messageManager->addSuccessMessage(__('The coupon has been removed.'));
}
} elseif (isset($data['coupon']['code']) && empty($couponCode)) {
$this->messageManager->addSuccessMessage(__('The coupon code has been removed.'));
}

return $this;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="AdminRemoveCouponFromOrderActionGroup">
<click selector="{{AdminOrderFormItemsSection.removeCoupon}}" stepKey="removeCoupon"/>
<waitForPageLoad stepKey="waitForRemovingCoupon"/>
<see selector="{{AdminOrderDetailsMessagesSection.successMessage}}" userInput="The coupon code has been removed." stepKey="seeSuccessMessage"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@
<element name="configure" type="button" selector=".product-configure-block button.action-default.scalable" timeout="30"/>
<element name="couponCode" type="input" selector="#order-coupons input" timeout="30"/>
<element name="applyCoupon" type="button" selector="#order-coupons button"/>
<element name="removeCoupon" type="button" selector=".added-coupon-code .action-remove"/>
</section>
</sections>
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="AdminCreateOrderToVerifyApplyAndRemoveCouponCodeTest">
<annotations>
<stories value="Create Order with offline payment methods"/>
<title value="Create Order to verify apply and remove coupon code test"/>
<description value="Create Order to verify apply and remove coupon code test"/>
<severity value="CRITICAL"/>
<testCaseId value="MC-37386"/>
<group value="sales"/>
</annotations>
<before>
<!-- Login as admin -->
<actionGroup ref="AdminLoginActionGroup" stepKey="LoginAsAdmin"/>

<!-- Create customer -->
<createData entity="Simple_US_Customer" stepKey="createCustomer"/>

<!-- Create simple product -->
<createData entity="SimpleProduct2" stepKey="createSimpleProduct">
<field key="price">10</field>
</createData>

<!-- Create sales rule with coupon -->
<createData entity="SalesRuleSpecificCouponWithFixedDiscount" stepKey="createCartPriceRule"/>
<createData entity="SimpleSalesRuleCoupon" stepKey="createCouponForCartPriceRule">
<requiredEntity createDataKey="createCartPriceRule"/>
</createData>

<!-- Enable Bank Transfer payment -->
<magentoCLI command="config:set {{EnablePaymentBankTransferConfigData.path}} {{EnablePaymentBankTransferConfigData.value}}" stepKey="enableBankTransferPayment"/>

<!--Set default flat rate shipping method settings-->
<magentoCLI command="config:set {{EnableFlatRateConfigData.path}} {{EnableFlatRateConfigData.value}}" stepKey="enableFlatRate"/>
</before>
<after>
<!-- Disable Bank Transfer payment -->
<magentoCLI command="config:set {{DisablePaymentBankTransferConfigData.path}} {{DisablePaymentBankTransferConfigData.value}}" stepKey="disableBankTransferPayment"/>

<!-- Delete sales rule -->
<deleteData createDataKey="createCartPriceRule" stepKey="deleteCartPriceRule"/>

<!-- Delete customer -->
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>

<!-- Delete product -->
<deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/>

<!-- Log out -->
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
</after>

<!-- Create order -->
<actionGroup ref="NavigateToNewOrderPageExistingCustomerActionGroup" stepKey="goToCreateOrderPage">
<argument name="customer" value="$$createCustomer$$"/>
</actionGroup>

<!-- Add product to order -->
<actionGroup ref="AddSimpleProductToOrderActionGroup" stepKey="addProductToOrder">
<argument name="product" value="$$createSimpleProduct$$"/>
</actionGroup>

<!-- Apply coupon to the order -->
<actionGroup ref="AdminApplyCouponToOrderActionGroup" stepKey="applyCoupon">
<argument name="couponCode" value="$$createCouponForCartPriceRule.code$$"/>
</actionGroup>

<!-- Remove coupon from the order -->
<actionGroup ref="AdminRemoveCouponFromOrderActionGroup" stepKey="removeCoupon"/>

<!--Select FlatRate shipping method-->
<actionGroup ref="AdminSelectFlatRateShippingMethodActionGroup" stepKey="selectFlatRateShippingMethod"/>

<!-- Select bank Transfer payment method -->
<waitForElementVisible selector="{{AdminOrderFormPaymentSection.paymentBlock}}" stepKey="waitForPaymentOptions"/>
<conditionalClick selector="{{AdminOrderFormPaymentSection.bankTransferOption}}" dependentSelector="{{AdminOrderFormPaymentSection.bankTransferOption}}" visible="true" stepKey="checkBankTransferOption"/>

<!-- Submit order -->
<actionGroup ref="AdminSubmitOrderActionGroup" stepKey="submitOrder"/>

<!-- Grab order id -->
<grabTextFrom selector="|Order # (\d+)|" stepKey="getOrderId"/>

<!-- Open created order -->
<amOnPage url="{{AdminOrdersPage.url}}" stepKey="goToOrdersPage"/>
<waitForPageLoad stepKey="waitForOrdersPageLoad"/>
<actionGroup ref="FilterOrderGridByIdActionGroup" stepKey="filterOrdersGridById">
<argument name="orderId" value="$getOrderId"/>
</actionGroup>
<click selector="{{AdminDataGridTableSection.firstRow}}" stepKey="clickCreatedOrderInGrid"/>
</test>
</tests>

0 comments on commit 9c09485

Please sign in to comment.