Skip to content

#30255: Fixed "The coupon code has been accepted." message remains after a Coupon Code was removed #30391

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Nov 13, 2020
2 changes: 2 additions & 0 deletions app/code/Magento/Sales/Controller/Adminhtml/Order/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,8 @@ protected function _processActionData($action = null)
$this->messageManager->addSuccessMessage(__('The coupon code has been accepted.'));
}
}
} 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,17 @@
<?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"/>
<dontSee selector="{{AdminOrderDetailsMessagesSection.successMessage}}" userInput="The coupon code has been accepted." stepKey="dontSeePreviousMessage"/>
<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,72 @@
<?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"/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shikhamis11 could you please update severity and testCaseId?
Thank you.

            <severity value="AVERAGE"/>
            <testCaseId value="MC-38919"/>

<group value="sales"/>
</annotations>
<before>
<actionGroup ref="AdminLoginActionGroup" stepKey="LoginAsAdmin"/>
<createData entity="Simple_US_Customer" stepKey="createCustomer"/>
<createData entity="SimpleProduct2" stepKey="createSimpleProduct">
<field key="price">10</field>
</createData>
<createData entity="SalesRuleSpecificCouponWithFixedDiscount" stepKey="createCartPriceRule"/>
<createData entity="SimpleSalesRuleCoupon" stepKey="createCouponForCartPriceRule">
<requiredEntity createDataKey="createCartPriceRule"/>
</createData>
<magentoCLI
command="config:set {{EnablePaymentBankTransferConfigData.path}} {{EnablePaymentBankTransferConfigData.value}}"
stepKey="enableBankTransferPayment"/>
<magentoCLI command="config:set {{EnableFlatRateConfigData.path}} {{EnableFlatRateConfigData.value}}"
stepKey="enableFlatRate"/>
</before>
<after>
<magentoCLI
command="config:set {{DisablePaymentBankTransferConfigData.path}} {{DisablePaymentBankTransferConfigData.value}}"
stepKey="disableBankTransferPayment"/>
<magentoCLI command="config:set {{DisableFlatRateConfigData.path}} {{DisableFlatRateConfigData.value}}"
stepKey="disableFlatRate"/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe flat rate is enabled by default, by disabling it we may have made other tests flaky. I guess you can keep the CLI to enable it, but remove this one.

<deleteData createDataKey="createCartPriceRule" stepKey="deleteCartPriceRule"/>
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
<deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/>
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
</after>
<actionGroup ref="NavigateToNewOrderPageExistingCustomerActionGroup" stepKey="goToCreateOrderPage">
<argument name="customer" value="$$createCustomer$$"/>
</actionGroup>
<actionGroup ref="AddSimpleProductToOrderActionGroup" stepKey="addProductToOrder">
<argument name="product" value="$$createSimpleProduct$$"/>
</actionGroup>
<actionGroup ref="AdminApplyCouponToOrderActionGroup" stepKey="applyCoupon">
<argument name="couponCode" value="$$createCouponForCartPriceRule.code$$"/>
</actionGroup>
<actionGroup ref="AdminRemoveCouponFromOrderActionGroup" stepKey="removeCoupon"/>
<actionGroup ref="AdminSelectFlatRateShippingMethodActionGroup" stepKey="selectFlatRateShippingMethod"/>
<waitForElementVisible selector="{{AdminOrderFormPaymentSection.paymentBlock}}"
stepKey="waitForPaymentOptions"/>
<conditionalClick selector="{{AdminOrderFormPaymentSection.bankTransferOption}}"
dependentSelector="{{AdminOrderFormPaymentSection.bankTransferOption}}" visible="true"
stepKey="checkBankTransferOption"/>
<actionGroup ref="AdminSubmitOrderActionGroup" stepKey="submitOrder"/>
<grabTextFrom selector="|Order # (\d+)|" stepKey="getOrderId"/>
<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>
1 change: 1 addition & 0 deletions app/code/Magento/Sales/i18n/en_US.csv
Original file line number Diff line number Diff line change
Expand Up @@ -803,3 +803,4 @@ If set YES Email field will be required during Admin order creation for new Cust
"Could not save the shipment tracking","Could not save the shipment tracking"
"Please enter a coupon code!","Please enter a coupon code!"
"Reorder is not available.","Reorder is not available."
"The coupon code has been removed.","The coupon code has been removed."