Skip to content

Commit

Permalink
Merge pull request #62 from magento-tsg/MC-40541
Browse files Browse the repository at this point in the history
[Arrows] MC-40541: Admin Place Order not working as expected. MFTF test.
  • Loading branch information
zakdma authored Feb 5, 2021
2 parents 351b45c + b6b23ee commit 35e8e37
Show file tree
Hide file tree
Showing 2 changed files with 118 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?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="AdminCreateOrderWithMultipleAddressCustomerWithSimpleProductTest">
<annotations>
<stories value="Simple Product Single Stock."/>
<title value="Admin Create Order With Multiple Addresses Customer"/>
<description value="Verify admin able to create order for customer with multiple addresses on default stock."/>
<testCaseId value="MC-40634"/>
<useCaseId value="MC-40541"/>
<severity value="MAJOR"/>
<group value="msi"/>
<group value="single_mode"/>
</annotations>

<before>
<!--Create test data.-->
<createData entity="SimpleProduct2" stepKey="product"/>
<createData entity="Simple_US_Customer_With_Different_Billing_Shipping_Addresses" stepKey="customer"/>
<actionGroup ref="AdminLoginActionGroup" stepKey="loginToAdminArea"/>
<!--Assign Default Stock to Default Website.-->
<actionGroup ref="AssignWebsiteToStockActionGroup" stepKey="assignMainWebsiteToDefaultStock">
<argument name="stockName" value="{{_defaultStock.name}}"/>
<argument name="websiteName" value="{{_defaultWebsite.name}}"/>
</actionGroup>
<magentoCron stepKey="runCronIndex" groups="index"/>
</before>
<after>
<!--Delete test data.-->
<deleteData createDataKey="customer" stepKey="deleteCustomer"/>
<deleteData createDataKey="product" stepKey="deleteProduct"/>
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutFromAdminArea"/>
</after>

<!--Create order with simple product quantity.-->
<actionGroup ref="NavigateToNewOrderPageExistingCustomerActionGroup" stepKey="createNewOrderForCustomer">
<argument name="customer" value="$customer$"/>
</actionGroup>
<actionGroup ref="AddSimpleProductToOrderActionGroup" stepKey="addProductToOrder">
<argument name="product" value="$product$"/>
<argument name="productQty" value="{{defaultProductQty.value}}"/>
</actionGroup>
<!--Change customer billing address.-->
<actionGroup ref="FillOrderCustomerInformationActionGroup" stepKey="changeBillingAddress">
<argument name="customer" value="$customer$"/>
<argument name="address" value="US_Address_TX"/>
</actionGroup>
<!--Verify shipping address didn't change.-->
<actionGroup ref="AssertAdminCreateOrderFormShippingAddressActionGroup" stepKey="verifyShippingAddress">
<argument name="prefix" value=""/>
<argument name="firstname" value="$customer.firstname$"/>
<argument name="middleName" value=""/>
<argument name="lastname" value="$customer.lastname$"/>
<argument name="suffix" value=""/>
<argument name="company" value="{{US_Address_NY_Default_Shipping.company}}"/>
<argument name="streetLine1" value="{{US_Address_NY_Default_Shipping.street[0]}}"/>
<argument name="streetLine2" value="{{US_Address_NY_Default_Shipping.street[1]}}"/>
<argument name="city" value="{{US_Address_NY_Default_Shipping.city}}"/>
<argument name="country_id" value="{{US_Address_NY_Default_Shipping.country_id}}"/>
<argument name="state" value="{{US_Address_NY_Default_Shipping.state}}"/>
<argument name="postcode" value="{{US_Address_NY_Default_Shipping.postcode}}"/>
<argument name="telephone" value="{{US_Address_NY_Default_Shipping.telephone}}"/>
<argument name="fax" value=""/>
<argument name="vatNumber" value=""/>
</actionGroup>
<!--Place order.-->
<actionGroup ref="OrderSelectFlatRateShippingActionGroup" stepKey="selectFlatRateShipping"/>
<actionGroup ref="SelectCheckMoneyPaymentMethodActionGroup" stepKey="selectCheckMoneyPayment"/>
<actionGroup ref="AdminSubmitOrderActionGroup" stepKey="submitOrder"/>
<actionGroup ref="VerifyCreatedOrderInformationActionGroup" stepKey="verifyCreatedOrderInformation"/>
<!--Verify addresses are different.-->
<actionGroup ref="AssertOrderAddressInformationActionGroup" stepKey="verifyAddressInformation">
<argument name="customer" value="$customer$"/>
<argument name="shippingAddress" value="US_Address_NY_Default_Shipping"/>
<argument name="billingAddress" value="US_Address_TX"/>
<argument name="customerGroup" value=""/>
</actionGroup>
</test>
</tests>
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,17 @@ define(
IN_STORE_PICKUP_CHECKBOX_SELECTOR = '#s_method_instore_pickup';

/**
* Disable shipping address form elements;
* Display sources dropdown field;
* And vice-versa
*
* @param {Boolean} isStorePickup
*/
function setStorePickupMethod(isStorePickup) {
var sourcesInput = jQuery(SOURCES_FIELD_SELECTOR),
theSameAsBillingCheckBox = jQuery(SAME_AS_BILLING_SELECTOR),
customerShippingAddressId = jQuery(CUSTOMER_SHIPPING_ADDRESS_ID_SELECTOR),
customerShippingAddressSaveInAddressBook = jQuery(CUSTOMER_ADDRESS_SAVE_IN_ADDRESS_BOOK_SELECTOR);
shippingAddressSaveInAddressBook = jQuery(CUSTOMER_ADDRESS_SAVE_IN_ADDRESS_BOOK_SELECTOR);

if (isStorePickup) {
theSameAsBillingCheckBox.prop('disabled', true);
customerShippingAddressId.prop('disabled', true);
customerShippingAddressSaveInAddressBook.prop('disabled', true);
shippingAddressSaveInAddressBook.removeAttr('checked');
sourcesInput.show();

return;
Expand All @@ -44,6 +39,33 @@ define(
sourcesInput.hide();
}

/**
* Verify is store pickup delivery method is checked.
*/
function isStorePickupSelected() {
var storePickupCheckbox = jQuery(IN_STORE_PICKUP_CHECKBOX_SELECTOR);

return storePickupCheckbox.length && storePickupCheckbox.prop('checked');
}

/**
* Always disable unwanted shipping address fields in case store pickup is selected.
*/
window.AdminOrder.prototype.disableShippingAddress =
window.AdminOrder.prototype.disableShippingAddress.wrap(function (proceed, flag) {
var shippingAddressId = jQuery(CUSTOMER_SHIPPING_ADDRESS_ID_SELECTOR),
theSameAsBillingCheckBox = jQuery(SAME_AS_BILLING_SELECTOR),
shippingAddressSaveInAddressBook = jQuery(CUSTOMER_ADDRESS_SAVE_IN_ADDRESS_BOOK_SELECTOR);

proceed(flag);

if (isStorePickupSelected()) {
shippingAddressId.prop('disabled', true);
theSameAsBillingCheckBox.prop('disabled', true);
shippingAddressSaveInAddressBook.prop('disabled', true);
}
});

/**
* Set shipping method override
*
Expand All @@ -54,7 +76,8 @@ define(
areas = [
'shipping_method',
'totals',
'billing_method'
'billing_method',
'shipping_address'
];

data['order[shipping_method]'] = method;
Expand All @@ -64,7 +87,6 @@ define(
data['order[shipping_method]'] = method;
data['shipping_as_billing'] = 0;
data['save_in_address_book'] = 0;
areas.push('shipping_address');
this.shippingAsBilling = 0;
this.saveInAddressBook = 0;
}
Expand All @@ -84,9 +106,10 @@ define(
var storePickupCheckbox = jQuery(IN_STORE_PICKUP_CHECKBOX_SELECTOR);

if (!this.isOnlyVirtualProduct) {
/* eslint-disable no-undef */
$(this.getAreaId('shipping_method')).update(this.shippingTemplate);

if (storePickupCheckbox.length && storePickupCheckbox.prop('checked')) {
if (isStorePickupSelected()) {
window.order.setShippingMethod(storePickupCheckbox.val());
}
}
Expand Down

0 comments on commit 35e8e37

Please sign in to comment.