From 40ecf31888b211400d819081200bc0bc96753b56 Mon Sep 17 00:00:00 2001 From: engcom-Kilo Date: Tue, 26 Jan 2021 17:40:44 +0200 Subject: [PATCH 1/2] MC-40541: Magento 2. Admin Place Order not working as expected. MFTF test. --- ...leAddressCustomerWithSimpleProductTest.xml | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 InventoryAdminUi/Test/Mftf/Test/AdminCreateOrderWithMultipleAddressCustomerWithSimpleProductTest.xml diff --git a/InventoryAdminUi/Test/Mftf/Test/AdminCreateOrderWithMultipleAddressCustomerWithSimpleProductTest.xml b/InventoryAdminUi/Test/Mftf/Test/AdminCreateOrderWithMultipleAddressCustomerWithSimpleProductTest.xml new file mode 100644 index 000000000000..a8449a0f47da --- /dev/null +++ b/InventoryAdminUi/Test/Mftf/Test/AdminCreateOrderWithMultipleAddressCustomerWithSimpleProductTest.xml @@ -0,0 +1,71 @@ + + + + + + + + + <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="SimpleSubCategory" stepKey="category"/> + <createData entity="SimpleProduct" stepKey="product"> + <requiredEntity createDataKey="category"/> + </createData> + <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> + <actionGroup ref="AdminLogoutActionGroup" stepKey="logoutFromAdminArea"/> + <!--Delete test data.--> + <deleteData createDataKey="category" stepKey="deleteCategory"/> + <deleteData createDataKey="customer" stepKey="deleteCustomer"/> + <deleteData createDataKey="product" stepKey="deleteProduct"/> + </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> + <!--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> From 7b968b6cce731b07e4fc79b91760130eb8677d3a Mon Sep 17 00:00:00 2001 From: engcom-Kilo <grp-engcom-vendorworker-Kilo@adobe.com> Date: Wed, 27 Jan 2021 19:35:31 +0200 Subject: [PATCH 2/2] MC-40541: Magento 2. Admin Place Order not working as expected. --- ...leAddressCustomerWithSimpleProductTest.xml | 26 ++++++++--- .../web/order/create/scripts-mixin.js | 43 ++++++++++++++----- 2 files changed, 53 insertions(+), 16 deletions(-) diff --git a/InventoryAdminUi/Test/Mftf/Test/AdminCreateOrderWithMultipleAddressCustomerWithSimpleProductTest.xml b/InventoryAdminUi/Test/Mftf/Test/AdminCreateOrderWithMultipleAddressCustomerWithSimpleProductTest.xml index a8449a0f47da..105afc3c4bf4 100644 --- a/InventoryAdminUi/Test/Mftf/Test/AdminCreateOrderWithMultipleAddressCustomerWithSimpleProductTest.xml +++ b/InventoryAdminUi/Test/Mftf/Test/AdminCreateOrderWithMultipleAddressCustomerWithSimpleProductTest.xml @@ -21,10 +21,7 @@ <before> <!--Create test data.--> - <createData entity="SimpleSubCategory" stepKey="category"/> - <createData entity="SimpleProduct" stepKey="product"> - <requiredEntity createDataKey="category"/> - </createData> + <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.--> @@ -35,11 +32,10 @@ <magentoCron stepKey="runCronIndex" groups="index"/> </before> <after> - <actionGroup ref="AdminLogoutActionGroup" stepKey="logoutFromAdminArea"/> <!--Delete test data.--> - <deleteData createDataKey="category" stepKey="deleteCategory"/> <deleteData createDataKey="customer" stepKey="deleteCustomer"/> <deleteData createDataKey="product" stepKey="deleteProduct"/> + <actionGroup ref="AdminLogoutActionGroup" stepKey="logoutFromAdminArea"/> </after> <!--Create order with simple product quantity.--> @@ -55,6 +51,24 @@ <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"/> diff --git a/InventoryInStorePickupSalesAdminUi/view/adminhtml/web/order/create/scripts-mixin.js b/InventoryInStorePickupSalesAdminUi/view/adminhtml/web/order/create/scripts-mixin.js index ecba8aa7412f..03ebd2a996c1 100644 --- a/InventoryInStorePickupSalesAdminUi/view/adminhtml/web/order/create/scripts-mixin.js +++ b/InventoryInStorePickupSalesAdminUi/view/adminhtml/web/order/create/scripts-mixin.js @@ -20,7 +20,6 @@ define( IN_STORE_PICKUP_CHECKBOX_SELECTOR = '#s_method_instore_pickup'; /** - * Disable shipping address form elements; * Display sources dropdown field; * And vice-versa * @@ -28,14 +27,10 @@ define( */ 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; @@ -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 * @@ -54,7 +76,8 @@ define( areas = [ 'shipping_method', 'totals', - 'billing_method' + 'billing_method', + 'shipping_address' ]; data['order[shipping_method]'] = method; @@ -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; } @@ -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()); } }