Skip to content

Commit 665baf8

Browse files
committed
ACP2E-1609: Region Field is not getting blank after selecting any region for a country
1 parent f6407f2 commit 665baf8

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

app/code/Magento/Customer/Test/Mftf/Test/AdminVerifyCustomerAddressRegionFieldTest.xml

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,28 +47,34 @@
4747
<click selector="{{AdminCustomerAddressesDefaultBillingSection.editButton}}" stepKey="clickEditDefaultBillingAddress"/>
4848
<waitForPageLoad stepKey="waitForCustomerAddressAddUpdateFormLoad"/>
4949

50-
<!-- Select Country = Finland And Region =Ahvenanmaa , Click on Save Button -->
50+
<!-- Select Country = Finland And Region =Ahvenanmaa , Click on Save Button-->
5151
<click selector="{{AdminCustomerAddressesSection.country}}" stepKey="clickCountryToOpenListOfCountries"/>
5252
<click selector="{{AdminCustomerAddressesSection.countryId(Finland_Address.country_id)}}" stepKey="fillCountry"/>
5353
<click selector="{{AdminCustomerAddressesSection.state}}" stepKey="clickRegionToOpenListOfRegions"/>
5454
<click selector="{{AdminCustomerAddressesSection.regionId(Finland_Address.state)}}" stepKey="fillRegion"/>
5555
<click selector="{{AdminCustomerAddressesSection.saveAddress}}" stepKey="clickSaveCustomer"/>
56+
<waitForPageLoad stepKey="waitForPageToBeSave"/>
5657

5758
<!--Verify state name in address details section-->
58-
<see userInput="{{Finland_Address.state}}" selector="{{AdminCustomerAddressesSection.regionId(Finland_Address.state)}}" stepKey="seeStateInAddress"/>
59+
<grabTextFrom selector="{{AdminCustomerAddressesDefaultBillingSection.addressDetails}}" stepKey="grabAddress"/>
60+
<assertStringContainsString stepKey="SeeStateInAddress">
61+
<expectedResult type="string">{{Finland_Address.state}}</expectedResult>
62+
<actualResult type="string">{$grabAddress}</actualResult>
63+
</assertStringContainsString>
5964

6065
<!-- Click on edit link for default billing address , deselect region and click on save button-->
6166
<click selector="{{AdminCustomerAddressesDefaultBillingSection.editButton}}" stepKey="clickEditDefaultBillingAddressAgain"/>
6267
<waitForPageLoad stepKey="waitForCustomerAddressAddUpdateFormLoad2"/>
6368
<selectOption selector="{{AdminCustomerAddressesSection.state}}" userInput="Please select a region, state or province." stepKey="selectState"/>
64-
<click selector="{{AdminCustomerAddressesSection.saveAddress}}" stepKey="clickSaveCustomerAgain"/>
65-
66-
<!--Open/Reload customer details page-->
67-
<actionGroup ref="AdminOpenCustomerEditPageActionGroup" stepKey="openCustomerEditPageAgain">
68-
<argument name="customerId" value="$firstCustomer.id$"/>
69-
</actionGroup>
69+
<click selector="{{AdminCustomerAddressesSection.saveAddress}}" stepKey="clickSaveCustomerAfterDeselectRegion"/>
70+
<waitForPageLoad stepKey="waitForPageToBeSaved"/>
7071

7172
<!--Verify state name not visible under address details section-->
72-
<dontSee userInput="{{Finland_Address.state}}" selector="{{AdminCustomerAddressesDefaultBillingSection.addressDetails}}" stepKey="dontSeeStateInAddress"/>
73-
</test>
74-
</tests>
73+
<grabTextFrom selector="{{AdminCustomerAddressesDefaultBillingSection.addressDetails}}" stepKey="grabAddressAgain"/>
74+
<assertStringNotContainsString stepKey="dontSeeStateInAddress">
75+
<expectedResult type="string">{{Finland_Address.state}}</expectedResult>
76+
<actualResult type="string">{$grabAddressAgain}</actualResult>
77+
</assertStringNotContainsString>
78+
79+
</test>
80+
</tests>

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,8 @@ define([
2121
setDifferedFromDefault: function (value) {
2222
this._super();
2323

24-
if (parseFloat(value)) {
25-
this.source.set(this.regionScope, this.indexedOptions[value].label);
26-
} else if (value === undefined) {
27-
this.source.set(this.regionScope,'');
28-
}
24+
var label = parseFloat(value) ? this.indexedOptions[value].label : '';
25+
this.source.set(this.regionScope,label);
2926
}
3027
});
3128
});

0 commit comments

Comments
 (0)