Skip to content

Commit 9946235

Browse files
magento2-login-as-customer/issues/39: "Admin user directly login into customer account on custom website" test added.
1 parent be25d54 commit 9946235

File tree

2 files changed

+87
-6
lines changed

2 files changed

+87
-6
lines changed

app/code/Magento/LoginAsCustomer/Test/Mftf/Data/LoginAsCustomerConfigData.xml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,10 @@
1111
<entity name="LoginAsCustomerConfigDataEnabled">
1212
<data key="path">mfloginascustomer/general/enabled</data>
1313
</entity>
14-
<entity name="disablePageCache">
14+
<entity name="LoginAsCustomerDisablePageCache">
1515
<data key="path">mfloginascustomer/general/disable_page_cache</data>
1616
</entity>
17-
<!-- Should be removed after https://github.com/magento/magento2-login-as-customer/issues/34 -->
18-
<entity name="extensionsKeepGuestCart">
19-
<data key="path">mfloginascustomer/general/keep_guest_cart</data>
20-
</entity>
21-
<entity name="storeViewLogin">
17+
<entity name="LoginAsCustomerStoreViewLogin">
2218
<data key="path">mfloginascustomer/general/store_view_login</data>
2319
</entity>
2420
</entities>
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
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="AdminLoginAsCustomerDirectlyToCustomWebsiteTest">
12+
<annotations>
13+
<features value="Login As Customer"/>
14+
<stories value="Login As Customer into additional website"/>
15+
<title value="Admin user directly login into customer account on custom website"/>
16+
<description
17+
value="Verify admin user can directly login into customer account on custom website using 'Login as customer' functionality"/>
18+
<severity value="BLOCKER"/>
19+
<group value="login_as_customer"/>
20+
</annotations>
21+
<before>
22+
<magentoCLI command="config:set {{LoginAsCustomerConfigDataEnabled.path}} 1"
23+
stepKey="enableLoginAsCustomer"/>
24+
<magentoCLI command="config:set {{LoginAsCustomerStoreViewLogin.path}} 0"
25+
stepKey="enableLoginAsCustomerAutoDetection"/>
26+
<magentoCLI
27+
command="config:set {{StorefrontEnableAddStoreCodeToUrls.path}} {{StorefrontEnableAddStoreCodeToUrls.value}}"
28+
stepKey="enableAddStoreCodeToUrls"/>
29+
<magentoCLI command="cache:flush config" stepKey="flushCacheBeforeTestRun"/>
30+
<actionGroup ref="AdminLoginActionGroup" stepKey="adminLogin"/>
31+
<actionGroup ref="AdminCreateWebsiteActionGroup" stepKey="createCustomWebsite">
32+
<argument name="newWebsiteName" value="{{customWebsite.name}}"/>
33+
<argument name="websiteCode" value="{{customWebsite.code}}"/>
34+
</actionGroup>
35+
<actionGroup ref="CreateCustomStoreActionGroup" stepKey="createCustomStore">
36+
<argument name="website" value="{{customWebsite.name}}"/>
37+
<argument name="store" value="{{customStoreGroup.name}}"/>
38+
<argument name="rootCategory" value="Default Category"/>
39+
</actionGroup>
40+
<actionGroup ref="AdminCreateStoreViewActionGroup" stepKey="createCustomStoreView">
41+
<argument name="StoreGroup" value="customStoreGroup"/>
42+
<argument name="customStore" value="customStoreEN"/>
43+
</actionGroup>
44+
<actionGroup ref="AdminCreateCustomerWithWebSiteAndGroupActionGroup" stepKey="createCustomer">
45+
<argument name="customerData" value="Simple_US_Customer"/>
46+
<argument name="website" value="{{customWebsite.name}}"/>
47+
<argument name="storeView" value="{{customStoreEN.name}}"/>
48+
</actionGroup>
49+
</before>
50+
<after>
51+
<actionGroup ref="AdminDeleteCustomerActionGroup" stepKey="deleteCustomer">
52+
<argument name="customerEmail" value="Simple_US_Customer.email"/>
53+
</actionGroup>
54+
<actionGroup ref="AdminDeleteWebsiteActionGroup" stepKey="deleteWebsite">
55+
<argument name="websiteName" value="{{customWebsite.name}}"/>
56+
</actionGroup>
57+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
58+
<magentoCLI command="config:set {{LoginAsCustomerConfigDataEnabled.path}} 0"
59+
stepKey="disableLoginAsCustomer"/>
60+
<magentoCLI
61+
command="config:set {{StorefrontDisableAddStoreCodeToUrls.path}} {{StorefrontDisableAddStoreCodeToUrls.value}}"
62+
stepKey="disableAddStoreCodeToUrls"/>
63+
<magentoCLI command="cache:flush config" stepKey="flushCacheAfterTestRun"/>
64+
</after>
65+
66+
<!-- Login As Customer from Customer page -->
67+
<actionGroup ref="OpenEditCustomerFromAdminActionGroup" stepKey="OpenEditCustomerFrom">
68+
<argument name="customer" value="Simple_US_Customer"/>
69+
</actionGroup>
70+
<grabFromCurrentUrl regex="~id/(\d+)/~" stepKey="customerId" />
71+
<actionGroup ref="AdminLoginAsCustomerLoginFromCustomerPageActionGroup"
72+
stepKey="loginAsCustomerFromCustomerPage">
73+
<argument name="customerId" value="${customerId}"/>
74+
</actionGroup>
75+
76+
<!-- Assert Customer logged on Custom Website -->
77+
<actionGroup ref="StorefrontClickOnHeaderLogoActionGroup" stepKey="clickOnStorefrontHeaderLogo"/>
78+
<actionGroup ref="AssertStorefrontStoreCodeInUrlActionGroup" stepKey="seeStoreCodeInUrl">
79+
<argument name="storeCode" value="{{customStoreEN.code}}"/>
80+
</actionGroup>
81+
82+
<!-- Log out Customer and close tab -->
83+
<actionGroup ref="StorefrontSignOutAndCloseTabActionGroup" stepKey="signOutAndCloseTab"/>
84+
</test>
85+
</tests>

0 commit comments

Comments
 (0)