Skip to content

Commit 69de6af

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-86624' into 2.2-develop-pr102
2 parents d818488 + f28c826 commit 69de6af

File tree

23 files changed

+544
-80
lines changed

23 files changed

+544
-80
lines changed

app/code/Magento/Backend/Test/Mftf/ActionGroup/ConfigurationActionGroup.xml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,7 @@
66
*/
77
-->
88

9-
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd">
10-
<actionGroup name="NavigateToConfigurationGeneralPage">
11-
<amOnPage url="{{AdminConfigGeneralPage.url}}" stepKey="navigateToConfigGeneralPage"/>
12-
<waitForPageLoad stepKey="waitForConfigPageLoad"/>
13-
</actionGroup>
14-
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
1510
<actionGroup name="SelectTopDestinationsCountry">
1611
<arguments>
1712
<argument name="countries"/>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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="AllowOnlyOneCountryActionGroup">
12+
<arguments>
13+
<argument name="country" type="string"/>
14+
</arguments>
15+
<conditionalClick selector="{{AdminConfigurationGeneralCountryOptionsSection.countryOptions}}" dependentSelector="{{AdminConfigurationGeneralCountryOptionsSection.countryOptionsOpen}}" visible="false" stepKey="openCountryOptionsTab"/>
16+
<waitForElementVisible selector="{{AdminConfigurationGeneralCountryOptionsSection.allowedCountries}}" stepKey="waitAllowedCountriesToBeVisible"/>
17+
<uncheckOption selector="{{AdminConfigurationGeneralCountryOptionsSection.generalCountryDefaultInherit}}" stepKey="uncheckDefaultCountryInheritCheckbox"/>
18+
<selectOption selector="{{AdminConfigurationGeneralCountryOptionsSection.generalCountryDefault}}" userInput="{{country}}" stepKey="chooseDefaultCountry"/>
19+
<uncheckOption selector="{{AdminConfigurationGeneralCountryOptionsSection.generalCountryAllowInherit}}" stepKey="uncheckAllowInheritCheckbox"/>
20+
<selectOption selector="{{AdminConfigurationGeneralCountryOptionsSection.allowedCountries}}" userInput="{{country}}" stepKey="chooseAllowedCountries"/>
21+
<click selector="{{AdminMainActionsSection.save}}" stepKey="saveConfig"/>
22+
<waitForElementVisible selector="{{AdminMessagesSection.successMessage}}" stepKey="waitForSuccessMessage"/>
23+
<see selector="{{AdminMessagesSection.successMessage}}" userInput="You saved the configuration." stepKey="seeSuccessMessage"/>
24+
</actionGroup>
25+
<actionGroup name="AllowAllCountriesExceptOneActionGroup" extends="AllowOnlyOneCountryActionGroup">
26+
<remove keyForRemoval="uncheckDefaultCountryInheritCheckbox"/>
27+
<remove keyForRemoval="chooseDefaultCountry"/>
28+
<remove keyForRemoval="chooseAllowedCountries"/>
29+
<unselectOption selector="{{AdminConfigurationGeneralCountryOptionsSection.allowedCountries}}" userInput="{{country}}" after="uncheckAllowInheritCheckbox" stepKey="unselectCountry"/>
30+
</actionGroup>
31+
<actionGroup name="SetWebsiteCountryOptionsToDefaultActionGroup">
32+
<conditionalClick selector="{{AdminConfigurationGeneralCountryOptionsSection.countryOptions}}" dependentSelector="{{AdminConfigurationGeneralCountryOptionsSection.countryOptionsOpen}}" visible="false" stepKey="openCountryOptionsTab"/>
33+
<waitForElementVisible selector="{{AdminConfigurationGeneralCountryOptionsSection.topDestinations}}" stepKey="waitCheckboxToBeVisible"/>
34+
<checkOption selector="{{AdminConfigurationGeneralCountryOptionsSection.generalCountryAllowInherit}}" stepKey="setAllowInheritToDefault"/>
35+
<checkOption selector="{{AdminConfigurationGeneralCountryOptionsSection.generalCountryDefaultInherit}}" stepKey="setDefaultCountryInheritToDefault"/>
36+
<click selector="{{AdminMainActionsSection.save}}" stepKey="saveConfig"/>
37+
<waitForElementVisible selector="{{AdminMessagesSection.successMessage}}" stepKey="waitForSuccessMessage"/>
38+
<see selector="{{AdminMessagesSection.successMessage}}" userInput="You saved the configuration." stepKey="seeSuccessMessage"/>
39+
</actionGroup>
40+
</actionGroups>

app/code/Magento/Config/Test/Mftf/Page/AdminConfigPage.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* See COPYING.txt for license details.
66
*/
77
-->
8-
<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/PageObject.xsd">
8+
<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd">
99
<page name="AdminConfigPage" url="admin/system_config/" area="admin" module="Magento_Config">
1010
<section name="AdminConfigSection"/>
1111
</page>

app/code/Magento/Config/Test/Mftf/Section/GeneralSection.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
-->
88

99
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10-
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
1111
<section name="ContentManagementSection">
1212
<element name="WYSIWYGOptions" type="button" selector="#cms_wysiwyg-head"/>
1313
<element name="CheckIfTabExpand" type="button" selector="#cms_wysiwyg-head:not(.open)"/>

app/code/Magento/Customer/Model/Customer/DataProvider.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
use Magento\Framework\View\Element\UiComponent\DataProvider\FilterPool;
2828
use Magento\Ui\Component\Form\Field;
2929
use Magento\Ui\DataProvider\EavValidationRules;
30+
use Magento\Ui\Component\Form\Element\Multiline;
3031

3132
/**
3233
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -568,8 +569,14 @@ protected function prepareAddressData($addressId, array &$addresses, array $cust
568569
) {
569570
$addresses[$addressId]['default_shipping'] = $customer['default_shipping'];
570571
}
571-
if (isset($addresses[$addressId]['street']) && !is_array($addresses[$addressId]['street'])) {
572-
$addresses[$addressId]['street'] = explode("\n", $addresses[$addressId]['street']);
572+
573+
foreach ($this->meta['address']['children'] as $attributeName => $attributeMeta) {
574+
if ($attributeMeta['arguments']['data']['config']['dataType'] === Multiline::NAME
575+
&& isset($addresses[$addressId][$attributeName])
576+
&& !\is_array($addresses[$addressId][$attributeName])
577+
) {
578+
$addresses[$addressId][$attributeName] = explode("\n", $addresses[$addressId][$attributeName]);
579+
}
573580
}
574581
}
575582

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,17 @@
113113
<data key="default_billing">true</data>
114114
<data key="default_shipping">false</data>
115115
</entity>
116+
<entity name="Canada_Address">
117+
<data key="firstname">Robert</data>
118+
<data key="lastname">Roe</data>
119+
<array key="street">
120+
<item>3197 rue Parc</item>
121+
</array>
122+
<data key="city">Sherbrooke</data>
123+
<data key="state">Quebec</data>
124+
<data key="postcode">J1L 1C9</data>
125+
<data key="country_id">CA</data>
126+
<data key="country">Canada</data>
127+
<data key="telephone">999-99-99-99</data>
128+
</entity>
116129
</entities>

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,11 @@
2121
<entity name="GlobalCustomerAccountSharing" type="account_share_scope_value">
2222
<data key="value">0</data>
2323
</entity>
24-
</entities>
24+
25+
<entity name="CustomerAccountSharingSystemValue" type="customer_account_sharing_config">
26+
<requiredEntity type="account_share_scope_value">CustomerAccountSharingInherit</requiredEntity>
27+
</entity>
28+
<entity name="CustomerAccountSharingInherit" type="account_share_scope_value">
29+
<data key="inherit">true</data>
30+
</entity>
31+
</entities>

app/code/Magento/Customer/Test/Mftf/Metadata/customer_config_account_sharing-meta.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313
<object key="fields" dataType="customer_account_sharing_config">
1414
<object key="scope" dataType="account_share_scope_value">
1515
<field key="value">string</field>
16+
<field key="inherit">boolean</field>
1617
</object>
1718
</object>
1819
</object>
1920
</object>
2021
</operation>
21-
</operations>
22+
</operations>

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@
77
-->
88

99
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10-
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
1111
<section name="AdminCustomerFiltersSection">
1212
<element name="filtersButton" type="button" selector="#container > div > div.admin__data-grid-header > div:nth-child(1) > div.data-grid-filters-actions-wrap > div > button" timeout="30"/>
1313
<element name="nameInput" type="input" selector="input[name=name]"/>
1414
<element name="emailInput" type="input" selector="input[name=email]"/>
1515
<element name="apply" type="button" selector="button[data-action=grid-filter-apply]" timeout="30"/>
1616
<element name="clearFilters" type="button" selector=".admin__data-grid-header button[data-action='grid-filter-reset']" timeout="30"/>
1717
<element name="viewDropdown" type="button" selector=".admin__data-grid-action-bookmarks button.admin__action-dropdown"/>
18+
<element name="countryOptions" type="button" selector=".admin__data-grid-filters select[name=billing_country_id] option"/>
19+
<element name="countryOptionsWithoutEmptyOption" type="button" selector=".admin__data-grid-filters select[name=billing_country_id] option:not([value=''])"/>
1820
</section>
1921
</sections>
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
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" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="AllowedCountriesRestrictionApplyOnBackendTest">
11+
<annotations>
12+
<title value="Country filter on Customers page when allowed countries restriction for a default website is applied"/>
13+
<description value="Country filter on Customers page when allowed countries restriction for a default website is applied"/>
14+
<features value="Customer"/>
15+
<stories value="Admin Customer Grid"/>
16+
<severity value="MAJOR"/>
17+
<testCaseId value="MC-17282"/>
18+
<useCaseId value="MAGETWO-86624"/>
19+
<group value="customer"/>
20+
</annotations>
21+
<before>
22+
<createData entity="CustomerAccountSharingDefault" stepKey="setCustomerAccountSharingToDefault"/>
23+
<createData entity="Simple_Customer_Without_Address" stepKey="createCustomer"/>
24+
<actionGroup ref="LoginActionGroup" stepKey="loginToAdmin"/>
25+
26+
<!--Create new website,store and store view-->
27+
<actionGroup ref="AdminCreateWebsiteActionGroup" stepKey="adminCreateNewWebsite">
28+
<argument name="newWebsiteName" value="{{CustomWebSite.name}}"/>
29+
<argument name="websiteCode" value="{{CustomWebSite.code}}"/>
30+
</actionGroup>
31+
<actionGroup ref="AdminCreateNewStoreGroupActionGroup" stepKey="adminCreateNewStore">
32+
<argument name="website" value="{{CustomWebSite.name}}"/>
33+
<argument name="storeGroupName" value="{{customStore.name}}"/>
34+
<argument name="storeGroupCode" value="{{customStore.code}}"/>
35+
</actionGroup>
36+
<actionGroup ref="AdminCreateStoreViewActionGroup" stepKey="adminCreateNewStoreView">
37+
<argument name="storeGroup" value="customStore"/>
38+
</actionGroup>
39+
</before>
40+
<after>
41+
<!--Delete all created data and set main website country options to default-->
42+
<comment userInput="Delete all created data and set main website country options to default" stepKey="resetConfigToDefault"/>
43+
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
44+
<createData entity="CustomerAccountSharingSystemValue" stepKey="setAccountSharingToSystemValue"/>
45+
<actionGroup ref="AdminDeleteWebsiteActionGroup" stepKey="deleteWebsite">
46+
<argument name="websiteName" value="{{CustomWebSite.name}}"/>
47+
</actionGroup>
48+
<amOnPage url="{{AdminConfigurationGeneralSectionPage.url('#general_country-link')}}" stepKey="goToConfigurationSectionPage"/>
49+
<actionGroup ref="AdminSwitchWebsiteActionGroup" stepKey="adminSwitchWebsiteActionGroup">
50+
<argument name="scopeName" value="_defaultWebsite.name"/>
51+
</actionGroup>
52+
<actionGroup ref="SetWebsiteCountryOptionsToDefaultActionGroup" stepKey="setCountryOptionsToDefault"/>
53+
<actionGroup ref="logout" stepKey="logoutFromAdmin"/>
54+
</after>
55+
56+
<!--Check that all countries are allowed initially and get amount-->
57+
<amOnPage url="{{AdminConfigurationGeneralSectionPage.url('#general_country-link')}}" stepKey="goToCountryConfigurationSectionPage"/>
58+
<executeJS function="return document.querySelectorAll('{{AdminConfigurationGeneralCountryOptionsSection.allowedCountriesOptions}}').length" stepKey="countriesAmount"/>
59+
60+
<!-- Switch to first website, allow only Canada and set Canada as default country -->
61+
<actionGroup ref="AdminSwitchWebsiteActionGroup" stepKey="adminSwitchWebsite">
62+
<argument name="scopeName" value="_defaultWebsite.name"/>
63+
</actionGroup>
64+
<actionGroup ref="AllowOnlyOneCountryActionGroup" stepKey="allowCanadaCountry">
65+
<argument name="country" value="Canada"/>
66+
</actionGroup>
67+
68+
<!--Switch to second website and allow all countries except Canada-->
69+
<actionGroup ref="AdminSwitchWebsiteActionGroup" stepKey="adminSwitchToSecondWebsite">
70+
<argument name="scopeName" value="CustomWebSite.name"/>
71+
</actionGroup>
72+
<actionGroup ref="AllowAllCountriesExceptOneActionGroup" stepKey="allowAllCountriesExceptCanada">
73+
<argument name="country" value="Canada"/>
74+
</actionGroup>
75+
76+
<!--Open created customer details page and add Canada address-->
77+
<amOnPage url="{{AdminEditCustomerPage.url($$createCustomer.id$$)}}" stepKey="goToCustomerEditPage"/>
78+
<actionGroup ref="AdminAddCustomerAddressWithRegionTypeSelectActionGroup" stepKey="addAddressForCustomer">
79+
<argument name="customerAddress" value="Canada_Address"/>
80+
</actionGroup>
81+
82+
<!--Go to Customers grid and check that filter countries amount is the same as initial allowed countries amount-->
83+
<amOnPage url="{{AdminCustomerPage.url}}" stepKey="goToCustomersGrid"/>
84+
<click selector="{{AdminDataGridHeaderSection.filters}}" stepKey="openFiltersSectionOnCustomersGrid"/>
85+
<seeNumberOfElements userInput="$countriesAmount" selector="{{AdminCustomerFiltersSection.countryOptionsWithoutEmptyOption}}" stepKey="assertCountryAmounts"/>
86+
</test>
87+
</tests>

0 commit comments

Comments
 (0)