Skip to content

Commit e8a22eb

Browse files
committed
ACP2E-1609: Region Field is not getting blank after selecting any region for a country
1 parent 587eb26 commit e8a22eb

File tree

2 files changed

+99
-3
lines changed

2 files changed

+99
-3
lines changed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
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="Region field is getting blank after selecting any region for a country"/>
15+
<title value="Region field is not getting blank after selecting any region for a country"/>
16+
<description value="After saving customer address details in the admin without state/region, it will disappered from the address section."/>
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_Multiple_Addresses" stepKey="firstCustomer"/>
25+
<actionGroup ref="AdminLoginActionGroup" stepKey="login"/>
26+
</before>
27+
28+
<after>
29+
<deleteData createDataKey="firstCustomer" stepKey="deleteFirstCustomer"/>
30+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
31+
</after>
32+
33+
<!--Open customer grid page,select created customer and click edit mode-->
34+
<actionGroup ref="AdminOpenCustomersGridActionGroup" stepKey="openCustomersGridPage"/>
35+
<actionGroup ref="OpenEditCustomerFromAdminActionGroup" stepKey="openEditCustomerPageWithAddresses">
36+
<argument name="customer" value="$$firstCustomer$$"/>
37+
</actionGroup>
38+
39+
<!--Select Addresses tab click on Edit link for Default Billing Address -->
40+
<click selector="{{AdminEditCustomerInformationSection.addresses}}" stepKey="openAddressesTabOfFirstCustomer"/>
41+
<waitForPageLoad stepKey="waitForAddressesOfFirstCustomer"/>
42+
<click selector="{{AdminCustomerAddressesDefaultBillingSection.editButton}}" stepKey="clickEditDefaultBillingAddress"/>
43+
<waitForPageLoad stepKey="waitForCustomerAddressAddUpdateFormLoad"/>
44+
45+
<!-- Select Country = Finland And Region =Ahvenanmaa , Click on Save Button-->
46+
<click selector="{{AdminCustomerAddressesSection.country}}" stepKey="clickCountryToOpenListOfCountries"/>
47+
<click selector="{{AdminCustomerAddressesSection.countryId(Finland_Address.country_id)}}" stepKey="fillCountry"/>
48+
<click selector="{{AdminCustomerAddressesSection.state}}" stepKey="clickRegionToOpenListOfRegions"/>
49+
<click selector="{{AdminCustomerAddressesSection.regionId(Finland_Address.state)}}" stepKey="fillRegion"/>
50+
<click selector="{{AdminCustomerAddressesSection.saveAddress}}" stepKey="clickSaveCustomer"/>
51+
<waitForPageLoad stepKey="waitForPageToBeSave"/>
52+
53+
<!--Verify state name in address details section-->
54+
<see selector="{{AdminCustomerAddressesDefaultBillingSection.addressDetails}}" userInput="{{Finland_Address.state}}" stepKey="SeeStateInAddress"/>
55+
56+
<!-- Click on edit link for default billing address , deselect region and click on save button-->
57+
<click selector="{{AdminCustomerAddressesDefaultBillingSection.editButton}}" stepKey="clickEditDefaultBillingAddressAgain"/>
58+
<waitForPageLoad stepKey="waitForCustomerAddressAddUpdateFormLoad2"/>
59+
<selectOption selector="{{AdminCustomerAddressesSection.state}}" userInput="Please select a region, state or province." stepKey="selectState"/>
60+
<click selector="{{AdminCustomerAddressesSection.saveAddress}}" stepKey="clickSaveCustomerAfterDeselectRegion"/>
61+
<waitForPageLoad stepKey="waitForPageToBeSaved"/>
62+
63+
<!--Verify state name not visible under address details section-->
64+
<dontSee userInput="{{Finland_Address.state}}" selector="{{AdminCustomerAddressesDefaultBillingSection.addressDetails}}" stepKey="dontSeeStateInAddress"/>
65+
66+
<!--Logout from admin-->
67+
<actionGroup ref="AdminClearCustomersFiltersActionGroup" stepKey="clearFilters"/>
68+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutFromAdmin"/>
69+
70+
<!--Log in to Storefront as First Customer -->
71+
<actionGroup ref="LoginToStorefrontActionGroup" stepKey="loginFirstCustomer">
72+
<argument name="Customer" value="$$firstCustomer$$"/>
73+
</actionGroup>
74+
75+
<!--Go to customer address book and click edit default billing address for storefront -->
76+
<actionGroup ref="StorefrontGoToCustomerAddressesPageActionGroup" stepKey="goToCustomerAddressBook"/>
77+
<click stepKey="ClickEditDefaultBillingAddressForStorefront" selector="{{StorefrontCustomerAddressesSection.editDefaultBillingAddress}}"/>
78+
<waitForPageLoad stepKey="waitForStorefrontSignInPageLoad"/>
79+
80+
<!-- Select Region =Ahvenanmaa and click on save button-->
81+
<selectOption selector="{{StorefrontCustomerAddressFormSection.state}}" userInput="{{Finland_Address.state}}" stepKey="selectStateForStorefront"/>
82+
<actionGroup ref="AdminSaveCustomerAddressActionGroup" stepKey="saveAddress"/>
83+
84+
<!--Verify state name in address details section-->
85+
<see selector="{{StorefrontCustomerAddressesSection.defaultShippingAddress}}" userInput="{{Finland_Address.state}}" stepKey="seeAssertCustomerDefaultShippingAddressState"/>
86+
87+
<!-- Click on edit link for default billing address , deselect region and click on save button-->
88+
<click stepKey="ClickEditDefaultBillingAddressForStorefrontAgain" selector="{{StorefrontCustomerAddressesSection.editDefaultBillingAddress}}"/>
89+
<waitForPageLoad stepKey="waitForStorefrontSignInPageLoad2"/>
90+
<selectOption selector="{{StorefrontCustomerAddressFormSection.state}}" userInput="Please select a region, state or province." stepKey="deselectStateForStorefront"/>
91+
<actionGroup ref="AdminSaveCustomerAddressActionGroup" stepKey="saveAddressAfterDeselectRegion"/>
92+
93+
<!--Verify state name not visible under address details section-->
94+
<dontSee userInput="{{Finland_Address.state}}" selector="{{StorefrontCustomerAddressesSection.defaultShippingAddress}}" stepKey="dontSeeAssertCustomerDefaultShippingAddressState"/>
95+
96+
</test>
97+
</tests>

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,8 @@ define([
4141
this.setOption = false;
4242
this.currentRegionOption = $(e.target).val();
4343

44-
if (this.currentRegionOption === '') {
45-
$(this.options.regionListId).val('');
46-
$(this.options.regionInputId).val('');
44+
if (!this.currentRegionOption) {
45+
$(this.options.regionListId).add(this.options.regionInputId).val('');
4746
}
4847
}, this));
4948

0 commit comments

Comments
 (0)