Skip to content

Commit 51c2712

Browse files
committed
MAGETWO-94347: Implement handling of large number of addresses on storefront Address book
1 parent 8b0b760 commit 51c2712

File tree

13 files changed

+411
-17
lines changed

13 files changed

+411
-17
lines changed

app/code/Magento/Customer/Block/Address/Grid.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public function getAddressEditUrl($addressId): string
106106
/**
107107
* Get current additional customer addresses
108108
*
109-
* Will return array of address interfaces if customer have additional addresses and false in other case.
109+
* Return array of address interfaces if customer has additional addresses and false in other cases
110110
*
111111
* @return \Magento\Customer\Api\Data\AddressInterface[]
112112
* @throws \Magento\Framework\Exception\LocalizedException
@@ -145,11 +145,12 @@ public function getCustomer(): \Magento\Customer\Api\Data\CustomerInterface
145145
/**
146146
* Get one string street address from "two fields" array or just returns string if it was passed in parameters
147147
*
148-
* @param string|array $street
148+
* @param \Magento\Customer\Api\Data\AddressInterface $address
149149
* @return string
150150
*/
151-
public function getStreetAddress($street): string
151+
public function getStreetAddress(\Magento\Customer\Api\Data\AddressInterface $address): string
152152
{
153+
$street = $address->getStreet();
153154
if (is_array($street)) {
154155
$street = implode(', ', $street);
155156
}
@@ -174,7 +175,7 @@ public function getCountryByCode($countryCode): string
174175
/**
175176
* Get default billing address
176177
*
177-
* Return address string if address found and null of not
178+
* Return address string if address found and null if not
178179
*
179180
* @return int
180181
* @throws \Magento\Framework\Exception\LocalizedException
@@ -189,7 +190,7 @@ private function getDefaultBilling(): int
189190
/**
190191
* Get default shipping address
191192
*
192-
* Return address string if address found and null of not
193+
* Return address string if address found and null if not
193194
*
194195
* @return int
195196
* @throws \Magento\Framework\Exception\LocalizedException
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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="StorefrontAddNewCustomerAddressActionGroup">
12+
<amOnPage url="customer/address/new/" stepKey="OpenCustomerAddNewAddress"/>
13+
<arguments>
14+
<argument name="Address"/>
15+
</arguments>
16+
<fillField stepKey="fillFirstName" userInput="{{Address.firstname}}" selector="{{StorefrontCustomerAddressFormSection.firstName}}"/>
17+
<fillField stepKey="fillLastName" userInput="{{Address.lastname}}" selector="{{StorefrontCustomerAddressFormSection.lastName}}"/>
18+
<fillField stepKey="fillCompanyName" userInput="{{Address.company}}" selector="{{StorefrontCustomerAddressFormSection.company}}"/>
19+
<fillField stepKey="fillPhoneNumber" userInput="{{Address.telephone}}" selector="{{StorefrontCustomerAddressFormSection.phoneNumber}}"/>
20+
<fillField stepKey="fillStreetAddress" userInput="{{Address.street[0]}}" selector="{{StorefrontCustomerAddressFormSection.streetAddress}}"/>
21+
<fillField stepKey="fillCity" userInput="{{Address.city}}" selector="{{StorefrontCustomerAddressFormSection.city}}"/>
22+
<selectOption stepKey="selectState" userInput="{{Address.state}}" selector="{{StorefrontCustomerAddressFormSection.state}}"/>
23+
<fillField stepKey="fillZip" userInput="{{Address.postcode}}" selector="{{StorefrontCustomerAddressFormSection.zip}}"/>
24+
<selectOption stepKey="selectCountry" userInput="{{Address.country}}" selector="{{StorefrontCustomerAddressFormSection.country}}"/>
25+
<click stepKey="saveCustomerAddress" selector="{{StorefrontCustomerAddressFormSection.saveAddress}}"/>
26+
<see userInput="You saved the address." stepKey="verifyAddressAdded"/>
27+
</actionGroup>
28+
<actionGroup name="StorefrontAddCustomerDefaultAddressActionGroup">
29+
<amOnPage url="customer/address/new/" stepKey="OpenCustomerAddNewAddress"/>
30+
<arguments>
31+
<argument name="Address"/>
32+
</arguments>
33+
<fillField stepKey="fillFirstName" userInput="{{Address.firstname}}" selector="{{StorefrontCustomerAddressFormSection.firstName}}"/>
34+
<fillField stepKey="fillLastName" userInput="{{Address.lastname}}" selector="{{StorefrontCustomerAddressFormSection.lastName}}"/>
35+
<fillField stepKey="fillCompanyName" userInput="{{Address.company}}" selector="{{StorefrontCustomerAddressFormSection.company}}"/>
36+
<fillField stepKey="fillPhoneNumber" userInput="{{Address.telephone}}" selector="{{StorefrontCustomerAddressFormSection.phoneNumber}}"/>
37+
<fillField stepKey="fillStreetAddress" userInput="{{Address.street[0]}}" selector="{{StorefrontCustomerAddressFormSection.streetAddress}}"/>
38+
<fillField stepKey="fillCity" userInput="{{Address.city}}" selector="{{StorefrontCustomerAddressFormSection.city}}"/>
39+
<selectOption stepKey="selectState" userInput="{{Address.state}}" selector="{{StorefrontCustomerAddressFormSection.state}}"/>
40+
<fillField stepKey="fillZip" userInput="{{Address.postcode}}" selector="{{StorefrontCustomerAddressFormSection.zip}}"/>
41+
<selectOption stepKey="selectCountry" userInput="{{Address.country}}" selector="{{StorefrontCustomerAddressFormSection.country}}"/>
42+
<click stepKey="checkUseAsDefaultBillingAddressCheckBox" selector="{{StorefrontCustomerAddressFormSection.useAsDefaultBillingAddressCheckBox}}"/>
43+
<click stepKey="checkUseAsDefaultShippingAddressCheckBox" selector="{{StorefrontCustomerAddressFormSection.useAsDefaultShippingAddressCheckBox}}"/>
44+
<click stepKey="saveCustomerAddress" selector="{{StorefrontCustomerAddressFormSection.saveAddress}}"/>
45+
<waitForPageLoad stepKey="waitForPageLoad"/>
46+
<see userInput="You saved the address." stepKey="verifyAddressAdded"/>
47+
</actionGroup>
48+
</actionGroups>

app/code/Magento/Customer/Test/Mftf/Data/AddressData.xml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,29 @@
4444
<data key="city">Austin</data>
4545
<data key="state">Texas</data>
4646
<data key="country_id">US</data>
47+
<data key="country">United States</data>
4748
<data key="postcode">78729</data>
4849
<data key="telephone">512-345-6789</data>
4950
<data key="default_billing">Yes</data>
5051
<data key="default_shipping">Yes</data>
5152
<requiredEntity type="region">RegionTX</requiredEntity>
5253
</entity>
54+
<entity name="US_Address_TX_Default_Billing" type="address">
55+
<data key="firstname">John</data>
56+
<data key="lastname">Doe</data>
57+
<data key="company">Magento</data>
58+
<array key="street">
59+
<item>7700 West Parmer Lane</item>
60+
</array>
61+
<data key="city">Austin</data>
62+
<data key="state">Texas</data>
63+
<data key="country_id">US</data>
64+
<data key="country">United States</data>
65+
<data key="postcode">78729</data>
66+
<data key="telephone">512-345-6789</data>
67+
<data key="default_billing">Yes</data>
68+
<requiredEntity type="region">RegionTX</requiredEntity>
69+
</entity>
5370
<entity name="US_Address_NY" type="address">
5471
<data key="firstname">John</data>
5572
<data key="lastname">Doe</data>
@@ -68,6 +85,23 @@
6885
<requiredEntity type="region">RegionNY</requiredEntity>
6986
<data key="country">United States</data>
7087
</entity>
88+
<entity name="US_Address_NY_Default_Shipping" type="address">
89+
<data key="firstname">John</data>
90+
<data key="lastname">Doe</data>
91+
<data key="company">368</data>
92+
<array key="street">
93+
<item>368 Broadway St.</item>
94+
<item>113</item>
95+
</array>
96+
<data key="city">New York</data>
97+
<data key="state">New York</data>
98+
<data key="country_id">US</data>
99+
<data key="postcode">10001</data>
100+
<data key="telephone">512-345-6789</data>
101+
<data key="default_shipping">Yes</data>
102+
<requiredEntity type="region">RegionNY</requiredEntity>
103+
<data key="country">United States</data>
104+
</entity>
71105
<entity name="US_Address_NY_Not_Default_Address" type="address">
72106
<data key="firstname">John</data>
73107
<data key="lastname">Doe</data>

app/code/Magento/Customer/Test/Mftf/Data/CustomerData.xml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@
4545
<data key="website_id">0</data>
4646
<requiredEntity type="address">US_Address_TX</requiredEntity>
4747
</entity>
48+
<entity name="Simple_Customer_Without_Address" type="customer">
49+
<data key="group_id">1</data>
50+
<data key="email" unique="prefix">[email protected]</data>
51+
<data key="firstname">John</data>
52+
<data key="lastname">Doe</data>
53+
<data key="fullname">John Doe</data>
54+
<data key="password">pwdTest123!</data>
55+
<data key="store_id">0</data>
56+
<data key="website_id">0</data>
57+
</entity>
4858
<entity name="Simple_US_Customer_Multiple_Addresses" type="customer">
4959
<data key="group_id">0</data>
5060
<data key="default_billing">true</data>
@@ -73,6 +83,20 @@
7383
<requiredEntity type="address">US_Address_NY_Not_Default_Address</requiredEntity>
7484
<requiredEntity type="address">UK_Not_Default_Address</requiredEntity>
7585
</entity>
86+
<entity name="Simple_US_Customer_With_Different_Billing_Shipping_Addresses" type="customer">
87+
<data key="group_id">0</data>
88+
<data key="default_billing">true</data>
89+
<data key="default_shipping">true</data>
90+
<data key="email" unique="prefix">[email protected]</data>
91+
<data key="firstname">John</data>
92+
<data key="lastname">Doe</data>
93+
<data key="fullname">John Doe</data>
94+
<data key="password">pwdTest123!</data>
95+
<data key="store_id">0</data>
96+
<data key="website_id">0</data>
97+
<requiredEntity type="address">US_Address_TX_Default_Billing</requiredEntity>
98+
<requiredEntity type="address">US_Address_NY_Default_Shipping</requiredEntity>
99+
</entity>
76100
<entity name="Simple_US_Customer_NY" type="customer">
77101
<data key="group_id">0</data>
78102
<data key="default_billing">true</data>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
11+
<section name="StorefrontCustomerAddressFormSection">
12+
<element name="firstName" type="input" selector="//form[@class='form-address-edit']//input[contains(@name, 'firstname')]"/>
13+
<element name="lastName" type="input" selector="//form[@class='form-address-edit']//input[contains(@name, 'lastname')]"/>
14+
<element name="company" type="input" selector="//form[@class='form-address-edit']//input[contains(@name, 'company')]"/>
15+
<element name="phoneNumber" type="input" selector="//form[@class='form-address-edit']//input[contains(@name, 'telephone')]"/>
16+
<element name="streetAddress" type="input" selector="//form[@class='form-address-edit']//input[contains(@name, 'street')]"/>
17+
<element name="city" type="input" selector="//form[@class='form-address-edit']//input[contains(@name, 'city')]"/>
18+
<element name="state" type="select" selector="//form[@class='form-address-edit']//select[contains(@name, 'region_id')]"/>
19+
<element name="zip" type="input" selector="//form[@class='form-address-edit']//input[contains(@name, 'postcode')]"/>
20+
<element name="country" type="select" selector="//form[@class='form-address-edit']//select[contains(@name, 'country_id')]"/>
21+
<element name="useAsDefaultBillingAddressCheckBox" type="input" selector="//form[@class='form-address-edit']//input[@name='default_billing']"/>
22+
<element name="useAsDefaultShippingAddressCheckBox" type="input" selector="//form[@class='form-address-edit']//input[@name='default_shipping']"/>
23+
<element name="saveAddress" type="button" selector="//button[@title='Save Address']" timeout="30"/>
24+
</section>
25+
</sections>

app/code/Magento/Customer/Test/Mftf/Section/StorefrontCustomerAddressesSection.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@
99
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1010
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
1111
<section name="StorefrontCustomerAddressesSection">
12+
<element name="defaultBillingAddress" type="text" selector=".box-address-billing" />
13+
<element name="editDefaultBillingAddress" type="text" selector="//div[@class='box-actions']//span[text()='Change Billing Address']" timeout="30"/>
14+
<element name="defaultShippingAddress" type="text" selector=".box-address-shipping" />
15+
<element name="editDefaultShippingAddress" type="text" selector="//div[@class='box-actions']//span[text()='Change Shipping Address']" timeout="30"/>
1216
<element name="addressesList" type="text" selector=".additional-addresses" />
1317
<element name="deleteAdditionalAddress" type="button" selector="//tbody//tr[{{var}}]//a[@class='action delete']" parameterized="true"/>
18+
<element name="editAdditionalAddress" type="button" selector="//tbody//tr[{{var}}]//a[@class='action edit']" parameterized="true" timeout="30"/>
19+
<element name="addNewAddress" type="button" selector="//span[text()='Add New Address']"/>
1420
</section>
1521
</sections>

0 commit comments

Comments
 (0)