Skip to content

Commit 0902e4f

Browse files
author
Davit_Zakharyan
committed
MAGETWO-91523: [2.3] Allowed countries restriction for a default website is applied to backend customer grid
- Added automated test script.
1 parent f9653a5 commit 0902e4f

File tree

6 files changed

+167
-0
lines changed

6 files changed

+167
-0
lines changed
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="SetAccountSharingOptionActionGroup">
12+
<arguments>
13+
<argument name="option" defaultValue="Per Website" type="string"/>
14+
</arguments>
15+
<amOnPage url="{{AdminStoresCustomerConfigurationPage.url}}" stepKey="goToCustomerConfigurationPage"/>
16+
<conditionalClick selector="{{AdminStoresCustomerConfigurationSection.accountSharingOptionsTab}}" dependentSelector="{{AdminStoresCustomerConfigurationSection.shareCustomerAccountInherit}}" visible="false" stepKey="expandAccountSharingOptionsTab"/>
17+
<waitForElementVisible selector="{{AdminStoresCustomerConfigurationSection.shareCustomerAccountInherit}}" stepKey="waitSystemValueCheckboxToBeVisible"/>
18+
<uncheckOption selector="{{AdminStoresCustomerConfigurationSection.shareCustomerAccountInherit}}" stepKey="uncheck"/>
19+
<selectOption selector="{{AdminStoresCustomerConfigurationSection.shareCustomerAccount}}" userInput="{{option}}" stepKey="setAccountSharingOption"/>
20+
<click selector="{{AdminStoresCustomerConfigurationSection.accountSharingOptionsTab}}" stepKey="collapseTab"/>
21+
<click selector="{{ContentManagementSection.Save}}" stepKey="clickSaveConfig"/>
22+
<waitForPageLoad stepKey="waitConfigToBeSaved"/>
23+
<seeElement selector="{{AdminMessagesSection.success}}" stepKey="seeSuccessMessage"/>
24+
</actionGroup>
25+
</actionGroups>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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="SetMainWebsiteCountryOptionsToDefaultActionGroup">
12+
<conditionalClick selector="{{CountryOptionsSection.countryOptions}}" dependentSelector="{{CountryOptionsSection.countryOptionsOpen}}" visible="false" stepKey="clickOnStoreInformation3"/>
13+
<waitForElementVisible selector="{{CountryOptionsSection.topDestinations}}" stepKey="waitCheckboxToBeVisible3"/>
14+
<checkOption selector="{{CountryOptionsSection.generalCountryAllowInherit}}" stepKey="setToDefault1"/>
15+
<checkOption selector="{{CountryOptionsSection.generalCountryDefaultInherit}}" stepKey="setToDefault2"/>
16+
<click selector="{{ContentManagementSection.Save}}" stepKey="saveDefaultConfig"/>
17+
<waitForPageLoad stepKey="waitForSavingSystemConfiguration"/>
18+
<see userInput="You saved the configuration." stepKey="seeSuccessMessage"/>
19+
</actionGroup>
20+
</actionGroups>

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,8 @@
1010
<element name="createNewAccOpt" type="button" selector="#customer_create_account-head"/>
1111
<element name="enableAutoAssignCustomerGroup" type="button" selector="#customer_create_account_auto_group_assign"/>
1212
<element name="groupForValidVATIdIntraUnion" type="select" selector="#customer_create_account_viv_intra_union_group"/>
13+
<element name="accountSharingOptionsTab" type="button" selector="#customer_account_share-head"/>
14+
<element name="shareCustomerAccountInherit" type="checkbox" selector="#customer_account_share_scope_inherit"/>
15+
<element name="shareCustomerAccount" type="select" selector="#customer_account_share_scope"/>
1316
</section>
1417
</sections>

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@
3838
<element name="countryOptions" type="button" selector="#general_country-head"/>
3939
<element name="countryOptionsOpen" type="button" selector="#general_country-head.open"/>
4040
<element name="topDestinations" type="select" selector="#general_country_destinations"/>
41+
<element name="allowedCountries" type="select" selector="#general_country_allow"/>
42+
<element name="notAllowedCountry" type="button" selector="#general_country_allow option:not([selected])"/>
43+
<element name="generalCountryAllowInherit" type="checkbox" selector="#general_country_allow_inherit"/>
44+
<element name="generalCountryDefaultInherit" type="checkbox" selector="#general_country_default_inherit"/>
45+
<element name="generalCountryDefault" type="select" selector="#general_country_default"/>
4146
</section>
4247
<section name="StateOptionsSection">
4348
<element name="stateOptions" type="button" selector="#general_region-head"/>
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
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="Module/ Customer"/>
15+
<severity value="MAJOR"/>
16+
<testCaseId value="MC-6441"/>
17+
<useCaseId value="MAGETWO-91523"/>
18+
<group value="customer"/>
19+
</annotations>
20+
<before>
21+
<createData entity="ApiCategory" stepKey="createCategory"/>
22+
<createData entity="SimpleProduct" stepKey="createSimpleProduct">
23+
<requiredEntity createDataKey="createCategory"/>
24+
</createData>
25+
<actionGroup ref="LoginActionGroup" stepKey="login"/>
26+
27+
<!--Create new website,store and store view-->
28+
<amOnPage url="{{AdminSystemStorePage.url}}" stepKey="goToAdminSystemStorePage"/>
29+
<actionGroup ref="AdminCreateWebsite" stepKey="AdminCreateNewWebsite">
30+
<argument name="newWebsiteName" value="{{NewWebSiteData.name}}"/>
31+
<argument name="websiteCode" value="{{NewWebSiteData.code}}"/>
32+
</actionGroup>
33+
<actionGroup ref="AdminCreateNewStore" stepKey="AdminCreateNewStore">
34+
<argument name="website" value="{{NewWebSiteData.name}}"/>
35+
<argument name="storeGroupName" value="{{NewStoreData.name}}"/>
36+
<argument name="storeGroupCode" value="{{NewStoreData.code}}"/>
37+
</actionGroup>
38+
<actionGroup ref="AdminCreateStoreView" stepKey="AdminCreateNewStoreView">
39+
<argument name="StoreGroup" value="NewStoreData"/>
40+
</actionGroup>
41+
<!--Set account sharing option - Default value is 'Per Website'-->
42+
<actionGroup ref="SetAccountSharingOptionActionGroup" stepKey="setAccountSharingOptionToDefault"/>
43+
<magentoCLI command="indexer:reindex" stepKey="reindex"/>
44+
</before>
45+
<after>
46+
<!--delete all created data and set main website country options to default-->
47+
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
48+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
49+
<deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/>
50+
<actionGroup ref="AdminDeleteWebsiteActionGroup" stepKey="deleteTestWebsite">
51+
<argument name="websiteName" value="{{NewWebSiteData.name}}"/>
52+
</actionGroup>
53+
<actionGroup ref="NavigateToConfigurationGeneralPage" stepKey="navigateToConfigGeneralPage2"/>
54+
<actionGroup ref="AdminSwitchWebsiteActionGroup" stepKey="adminSwitchWebsiteActionGroup">
55+
<argument name="website" value="_defaultWebsite"/>
56+
</actionGroup>
57+
<actionGroup ref="SetMainWebsiteCountryOptionsToDefaultActionGroup" stepKey="setCountryOptionsToDefault"/>
58+
<actionGroup ref="logout" stepKey="logout"/>
59+
</after>
60+
<!--Check that all countries are allowed initially and get amount-->
61+
<actionGroup ref="NavigateToConfigurationGeneralPage" stepKey="navigateToConfigGeneralPage"/>
62+
<conditionalClick selector="{{CountryOptionsSection.countryOptions}}" dependentSelector="{{CountryOptionsSection.countryOptionsOpen}}" visible="false" stepKey="clickOnStoreInformation"/>
63+
<waitForElementVisible selector="{{CountryOptionsSection.allowedCountries}}" stepKey="waitTabToExpand"/>
64+
<executeJS function="return document.querySelectorAll('{{CountryOptionsSection.allowedCountries}} option').length" stepKey="CountriesAmount"/>
65+
<checkOption selector="{{CountryOptionsSection.generalCountryAllowInherit}}" stepKey="markAllCountriesAsAvailable"/>
66+
<click selector="{{CountryOptionsSection.countryOptions}}" stepKey="collapseTab"/>
67+
<click selector="{{ContentManagementSection.Save}}" stepKey="saveConfig"/>
68+
<waitForPageLoad stepKey="waitForSavingSystemConfiguration"/>
69+
<see userInput="You saved the configuration." stepKey="seeSuccessMessage"/>
70+
<!-- Create customer for US -->
71+
<createData entity="Simple_US_CA_Customer" stepKey="createCustomer"/>
72+
<!-- Switch to first website, allow only Canada and set Canada as default country-->
73+
<actionGroup ref="AdminSwitchWebsiteActionGroup" stepKey="adminSwitchWebsiteActionGroup">
74+
<argument name="website" value="_defaultWebsite"/>
75+
</actionGroup>
76+
<conditionalClick selector="{{CountryOptionsSection.countryOptions}}" dependentSelector="{{CountryOptionsSection.countryOptionsOpen}}" visible="false" stepKey="clickOnStoreInformation2"/>
77+
<waitForElementVisible selector="{{CountryOptionsSection.allowedCountries}}" stepKey="waitAllowedCountriesToBeVisible"/>
78+
<uncheckOption selector="{{CountryOptionsSection.generalCountryDefaultInherit}}" stepKey="uncheckCheckbox1"/>
79+
<selectOption selector="{{CountryOptionsSection.generalCountryDefault}}" userInput="Canada" stepKey="chooseCanada1"/>
80+
<uncheckOption selector="{{CountryOptionsSection.generalCountryAllowInherit}}" stepKey="uncheckCheckbox2"/>
81+
<selectOption selector="{{CountryOptionsSection.allowedCountries}}" userInput="Canada" stepKey="chooseCanada2"/>
82+
<click selector="{{ContentManagementSection.Save}}" stepKey="saveConfig2"/>
83+
<waitForPageLoad stepKey="waitForSavingSystemConfiguration2"/>
84+
<!--Switch to second website and allow all countries except Canada-->
85+
<actionGroup ref="AdminSwitchWebsiteActionGroup" stepKey="adminSwitchWebsiteActionGroup2">
86+
<argument name="website" value="NewWebSiteData"/>
87+
</actionGroup>
88+
<conditionalClick selector="{{CountryOptionsSection.countryOptions}}" dependentSelector="{{CountryOptionsSection.countryOptionsOpen}}" visible="false" stepKey="clickOnStoreInformation3"/>
89+
<waitForElementVisible selector="{{CountryOptionsSection.allowedCountries}}" stepKey="waitAllowedCountriesToBeVisible2"/>
90+
<uncheckOption selector="{{CountryOptionsSection.generalCountryAllowInherit}}" stepKey="uncheckCheckbox3"/>
91+
<unselectOption selector="{{CountryOptionsSection.allowedCountries}}" userInput="Canada" stepKey="unselectCanada"/>
92+
<click selector="{{ContentManagementSection.Save}}" stepKey="saveConfig3"/>
93+
<waitForPageLoad stepKey="waitForSavingSystemConfiguration3"/>
94+
<amOnPage url="{{AdminEditCustomerPage.url($$createCustomer.id$$)}}" stepKey="goToCustomerEditPage"/>
95+
<waitForPageLoad stepKey="waitPageToLoad"/>
96+
<!--Open created customer details page and change US address to Canada address-->
97+
<actionGroup ref="OpenEditCustomerAddressFromAdminActionGroup" stepKey="editCustomerAddress">
98+
<argument name="address" value="US_Address_CA"/>
99+
</actionGroup>
100+
<selectOption selector="{{AdminEditCustomerAddressesSection.country}}" userInput="Canada" stepKey="selectCountry"/>
101+
<selectOption selector="{{AdminEditCustomerAddressesSection.state}}" userInput="Quebec" stepKey="selectState"/>
102+
<click selector="{{AdminEditCustomerAddressesSection.save}}" stepKey="saveAddress"/>
103+
<waitForPageLoad stepKey="waitForAddressSaved"/>
104+
<click stepKey="saveCustomer" selector="{{AdminCustomerAccountInformationSection.saveCustomerAndContinueEdit}}"/>
105+
<waitForPageLoad stepKey="waitForCustomersPage"/>
106+
<!--Go to Customers grid and check that filter countries amount is the same as initial allowed countries amount-->
107+
<amOnPage url="{{AdminCustomerPage.url}}" stepKey="goToCustomersGrid"/>
108+
<waitForPageLoad stepKey="waitForCustomersGrid"/>
109+
<click selector="{{AdminDataGridHeaderSection.filters}}" stepKey="openFiltersSectionOnCustomersGrid"/>
110+
<executeJS function="var len = document.querySelectorAll('{{AdminDataGridHeaderSection.countryOptions}}').length; return len-1;" stepKey="CountriesAmount2"/>
111+
<assertEquals expected='($CountriesAmount)' expectedType="integer" actual="($CountriesAmount2)" stepKey="assertCountryAmounts"/>
112+
</test>
113+
</tests>

app/code/Magento/Ui/Test/Mftf/Section/AdminDataGridHeaderSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<element name="filters" type="button" selector="button[data-action='grid-filter-expand']" timeout="30"/>
1717
<element name="filterFieldInput" type="input" selector=".admin__data-grid-filters input[name='{{name}}']" parameterized="true"/>
1818
<element name="filterFieldSelect" type="select" selector=".admin__data-grid-filters select[name='{{name}}']" parameterized="true"/>
19+
<element name="countryOptions" type="button" selector=".admin__data-grid-filters select[name=billing_country_id] option"/>
1920
<element name="cancelFilters" type="button" selector="button[data-action='grid-filter-cancel']" timeout="30"/>
2021
<element name="applyFilters" type="button" selector="button[data-action='grid-filter-apply']" timeout="30"/>
2122
<element name="clearFilters" type="button" selector=".admin__data-grid-header [data-action='grid-filter-reset']" timeout="30"/>

0 commit comments

Comments
 (0)