Skip to content

Commit 175706d

Browse files
committed
Merge remote-tracking branch 'magento-l3/ACP2E-1609' into APR222023_PR_sarmistha
2 parents 39ec4fa + ef7e375 commit 175706d

File tree

6 files changed

+154
-3
lines changed

6 files changed

+154
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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="AdminFillAndSaveCustomerAddressWithoutRegionActionGroup" extends="AdminFillAndSaveCustomerAddressInformationActionGroup">
12+
<annotations>
13+
<description>Fill and save customer address information omitting the region.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="address" type="entity"/>
17+
</arguments>
18+
<remove keyForRemoval="fillRegion"/>
19+
<selectOption selector="{{AdminCustomerAddressesSection.state}}" userInput="{{address.state}}" stepKey="fillRegion" after="clickRegionToOpenListOfRegions"/>
20+
</actionGroup>
21+
</actionGroups>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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="AdminRemoveRegionFromCustomerAddressInformationActionGroup" >
12+
<annotations>
13+
<description>Remove region from customer address information.</description>
14+
</annotations>
15+
<selectOption selector="{{AdminCustomerAddressesSection.state}}" userInput="Please select a region, state or province." stepKey="removeState"/>
16+
<click selector="{{AdminCustomerAddressesSection.saveAddress}}" stepKey="clickSaveCustomerAfterRemovingRegion"/>
17+
<waitForPageLoad stepKey="waitForPageToBeSaved"/>
18+
</actionGroup>
19+
</actionGroups>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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="StorefrontRemoveRegionFromCustomerAddressFormActionGroup" >
12+
<annotations>
13+
<description>Remove region from customer address form.</description>
14+
</annotations>
15+
<selectOption selector="{{StorefrontCustomerAddressFormSection.state}}" userInput="Please select a region, state or province." stepKey="removeStateForStorefront"/>
16+
</actionGroup>
17+
</actionGroups>
18+
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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="VerifyCustomerAddressRegionFieldTest">
12+
<annotations>
13+
<features value="Customer"/>
14+
<stories value="The State-Region field should stay blank after it's cleared from the customer address and saved"/>
15+
<title value="The State-Region field should stay blank after it's cleared from the customer address and saved"/>
16+
<description value="When removing the state from the customer address details in the admin, the field must stay blank after save."/>
17+
<severity value="AVERAGE"/>
18+
<testCaseId value="AC-8302"/>
19+
<useCaseId value="ACP2E-1609"/>
20+
<group value="customer"/>
21+
</annotations>
22+
23+
<before>
24+
<createData entity="Simple_US_Customer" stepKey="createCustomer"/>
25+
<actionGroup ref="AdminLoginActionGroup" stepKey="login"/>
26+
</before>
27+
28+
<after>
29+
<deleteData createDataKey="createCustomer" stepKey="deleteCreateCustomer"/>
30+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
31+
</after>
32+
33+
<!--Open customer grid page and Navigate to customer edit page addresses tab for created customer-->
34+
<actionGroup ref="AdminOpenCustomersGridActionGroup" stepKey="openCustomersGridPage"/>
35+
<actionGroup ref="AdminNavigateCustomerEditPageAddressesTabActionGroup" stepKey="openEditCustomerPageWithAddresses">
36+
<argument name="customerId" value="$createCustomer.id$"/>
37+
</actionGroup>
38+
39+
<!--Click on edit default billing address and update the address-->
40+
<actionGroup ref="AdminClickEditLinkForDefaultBillingAddressActionGroup" stepKey="clickEditDefaultBillingAddress"/>
41+
<actionGroup ref="AdminFillAndSaveCustomerAddressWithoutRegionActionGroup" stepKey="fillAndSaveCustomerAddressInformation">
42+
<argument name="address" value="updateCustomerFranceAddress"/>
43+
</actionGroup>
44+
45+
<!--Verify state name in address details section-->
46+
<see selector="{{AdminCustomerAddressesDefaultBillingSection.addressDetails}}" userInput="{{updateCustomerFranceAddress.state}}" stepKey="seeStateInAddress"/>
47+
48+
<!--Click on edit link for default billing address , remove the region-->
49+
<actionGroup ref="AdminClickEditLinkForDefaultBillingAddressActionGroup" stepKey="clickEditDefaultBillingAddressAgain"/>
50+
<actionGroup ref="AdminRemoveRegionFromCustomerAddressInformationActionGroup" stepKey="removeState"/>
51+
52+
<!--Verify state name not visible under address details section-->
53+
<dontSee userInput="{{updateCustomerFranceAddress.state}}" selector="{{AdminCustomerAddressesDefaultBillingSection.addressDetails}}" stepKey="dontSeeStateInAddress"/>
54+
55+
<!--Log in to Storefront-->
56+
<actionGroup ref="LoginToStorefrontActionGroup" stepKey="loginCreateCustomer">
57+
<argument name="Customer" value="$createCustomer$"/>
58+
</actionGroup>
59+
60+
<!--Go to customer address book and click edit default shipping address for storefront-->
61+
<actionGroup ref="StorefrontGoToCustomerAddressesPageActionGroup" stepKey="goToCustomerAddressBook"/>
62+
<actionGroup ref="StoreFrontClickEditDefaultShippingAddressActionGroup" stepKey="clickEditDefaultShippingAddressForStorefront"/>
63+
64+
<!--Update the address-->
65+
<actionGroup ref="FillNewCustomerAddressRequiredFieldsActionGroup" stepKey="fillAddressForm">
66+
<argument name="address" value="updateCustomerFranceAddress"/>
67+
</actionGroup>
68+
<actionGroup ref="AdminSaveCustomerAddressActionGroup" stepKey="saveAddress"/>
69+
70+
<!--Verify state name in address details section-->
71+
<see selector="{{StorefrontCustomerAddressesSection.defaultShippingAddress}}" userInput="{{updateCustomerFranceAddress.state}}" stepKey="seeAssertCustomerDefaultShippingAddressState"/>
72+
73+
<!--Click on edit link for default shipping address , remove the region and click on save button-->
74+
<actionGroup ref="StoreFrontClickEditDefaultShippingAddressActionGroup" stepKey="clickEditDefaultShippingAddressForStorefrontAgain"/>
75+
<actionGroup ref="StorefrontRemoveRegionFromCustomerAddressFormActionGroup" stepKey="fillAddressFormWithoutRegion"/>
76+
<actionGroup ref="AdminSaveCustomerAddressActionGroup" stepKey="saveAddressAfterRemovingRegion"/>
77+
<waitForPageLoad stepKey="waitForPageToBeSavedAddressAfterRemovingRegion"/>
78+
79+
<!--Verify state name not visible under address details section-->
80+
<dontSee userInput="{{updateCustomerFranceAddress.state}}" selector="{{StorefrontCustomerAddressesSection.defaultShippingAddress}}" stepKey="dontSeeAssertCustomerDefaultShippingAddressState"/>
81+
</test>
82+
</tests>

app/code/Magento/Customer/view/adminhtml/web/js/form/element/region.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,16 @@ define([
2121
setDifferedFromDefault: function (value) {
2222
this._super();
2323

24-
if (parseFloat(value)) {
25-
this.source.set(this.regionScope, this.indexedOptions[value].label);
26-
}
24+
const indexedOptionsArray = Object.values(this.indexedOptions),
25+
countryId = this.source.data.country_id,
26+
hasRegionList = indexedOptionsArray.some(option => option.country_id === countryId);
27+
28+
this.source.set(
29+
this.regionScope,
30+
hasRegionList
31+
? parseFloat(value) ? this.indexedOptions?.[value]?.label || '' : ''
32+
: this.source.data?.region || ''
33+
);
2734
}
2835
});
2936
});

app/code/Magento/Directory/view/frontend/web/js/region-updater.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ define([
4040
$(this.options.regionListId).on('change', $.proxy(function (e) {
4141
this.setOption = false;
4242
this.currentRegionOption = $(e.target).val();
43+
44+
if (!this.currentRegionOption) {
45+
$(this.options.regionListId).add(this.options.regionInputId).val('');
46+
}
4347
}, this));
4448

4549
$(this.options.regionInputId).on('focusout', $.proxy(function () {

0 commit comments

Comments
 (0)