Skip to content

Commit

Permalink
Merge pull request magento#5994 from magento-engcom/login-as-customer…
Browse files Browse the repository at this point in the history
…-150

[Login as Customer] Customers should be able to enable/disable Admin "remote shopping assistance"
  • Loading branch information
naydav authored Aug 12, 2020
2 parents 2c90cff + c5686f4 commit be26941
Show file tree
Hide file tree
Showing 75 changed files with 1,795 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
<operations xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataOperation.xsd">
<operation name="CreateCustomerExtensionAttribute" dataType="customer_extension_attribute" type="create">
<field key="assistance_allowed">integer</field>
<field key="is_subscribed">boolean</field>
<field key="extension_attribute">customer_nested_extension_attribute</field>
</operation>
<operation name="UpdateCustomerExtensionAttribute" dataType="customer_extension_attribute" type="update">
<field key="assistance_allowed">integer</field>
<field key="is_subscribed">boolean</field>
<field key="extension_attribute">customer_nested_extension_attribute</field>
</operation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ use Magento\Customer\Block\Widget\Name;
<span><?= $block->escapeHtml(__('Change Password')) ?></span>
</label>
</div>
<?= $block->getChildHtml('fieldset_edit_info_additional') ?>
</fieldset>

<fieldset class="fieldset password" data-container="change-email-password">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ $formData = $block->getFormData();
<?php if ($_gender->isEnabled()): ?>
<?= $_gender->setGender($formData->getGender())->toHtml() ?>
<?php endif ?>
<?= $block->getChildHtml('fieldset_create_info_additional') ?>
</fieldset>
<?php if ($block->getShowAddressFields()): ?>
<?php $cityValidationClass = $addressHelper->getAttributeValidationClass('city'); ?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Magento\LoginAsCustomer\Model\Resolver;

use Magento\LoginAsCustomer\Model\IsLoginAsCustomerEnabledForCustomerResultFactory;
use Magento\LoginAsCustomerApi\Api\Data\IsLoginAsCustomerEnabledForCustomerResultInterfaceFactory;
use Magento\LoginAsCustomerApi\Api\ConfigInterface;
use Magento\LoginAsCustomerApi\Api\Data\IsLoginAsCustomerEnabledForCustomerResultInterface;
use Magento\LoginAsCustomerApi\Api\IsLoginAsCustomerEnabledForCustomerInterface;
Expand All @@ -23,17 +23,17 @@ class IsLoginAsCustomerEnabledResolver implements IsLoginAsCustomerEnabledForCus
private $config;

/**
* @var IsLoginAsCustomerEnabledForCustomerResultFactory
* @var IsLoginAsCustomerEnabledForCustomerResultInterfaceFactory
*/
private $resultFactory;

/**
* @param ConfigInterface $config
* @param IsLoginAsCustomerEnabledForCustomerResultFactory $resultFactory
* @param IsLoginAsCustomerEnabledForCustomerResultInterfaceFactory $resultFactory
*/
public function __construct(
ConfigInterface $config,
IsLoginAsCustomerEnabledForCustomerResultFactory $resultFactory
IsLoginAsCustomerEnabledForCustomerResultInterfaceFactory $resultFactory
) {
$this->config = $config;
$this->resultFactory = $resultFactory;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="AdminCreateCustomerWithWebSiteAndGroupActionGroup">
<conditionalClick selector="{{AdminCustomerAccountInformationSection.assistanceAllowed}}" dependentSelector="{{AdminCustomerAccountInformationSection.assistanceAllowed}}" visible="true" stepKey="clickAllowAssistance" after="FillEmail"/>
</actionGroup>
</actionGroups>
17 changes: 17 additions & 0 deletions app/code/Magento/LoginAsCustomer/Test/Mftf/Data/CustomerData.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
<entity name="Simple_US_Customer_Assistance_Allowed" type="customer" extends="Simple_US_Customer">
<requiredEntity type="customer_extension_attribute">AssistanceAllowed</requiredEntity>
</entity>
<entity name="Simple_US_CA_Customer_Assistance_Allowed" type="customer" extends="Simple_US_CA_Customer">
<requiredEntity type="customer_extension_attribute">AssistanceAllowed</requiredEntity>
</entity>
</entities>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
<entity name="AssistanceDisallowed" type="customer_extension_attribute">
<data key="assistance_allowed">1</data>
</entity>
<entity name="AssistanceAllowed" type="customer_extension_attribute">
<data key="assistance_allowed">2</data>
</entity>
</entities>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
<section name="AdminCustomerAccountInformationSection">
<element name="assistanceAllowed" type="button" selector="//input[@name='customer[extension_attributes][assistance_allowed]']/../label"/>
</section>
</sections>
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<magentoCLI command="config:set {{LoginAsCustomerStoreViewLogin.path}} 0"
stepKey="enableLoginAsCustomerAutoDetection"/>
<magentoCLI command="cache:flush config" stepKey="flushCacheBeforeTestRun"/>
<createData entity="Simple_US_Customer" stepKey="createCustomer"/>
<createData entity="Simple_US_Customer_Assistance_Allowed" stepKey="createCustomer"/>
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsDefaultAdminUserBefore"/>

<!--Create New Role-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<createData entity="SimpleProduct" stepKey="createSimpleProduct">
<requiredEntity createDataKey="createCategory"/>
</createData>
<createData entity="Simple_US_Customer" stepKey="createCustomer"/>
<createData entity="Simple_US_Customer_Assistance_Allowed" stepKey="createCustomer"/>
<actionGroup ref="AdminLoginActionGroup" stepKey="login"/>
</before>
<after>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<group value="login_as_customer"/>
</annotations>
<before>
<createData entity="Simple_US_Customer" stepKey="createCustomer"/>
<createData entity="Simple_US_Customer_Assistance_Allowed" stepKey="createCustomer"/>
<magentoCLI command="config:set {{LoginAsCustomerConfigDataEnabled.path}} 1"
stepKey="enableLoginAsCustomer"/>
<magentoCLI command="config:set {{LoginAsCustomerStoreViewLogin.path}} 0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@
<argument name="customStore" value="customStoreEN"/>
</actionGroup>
<actionGroup ref="AdminCreateCustomerWithWebSiteAndGroupActionGroup" stepKey="createCustomer">
<argument name="customerData" value="Simple_US_Customer"/>
<argument name="customerData" value="Simple_US_Customer_Assistance_Allowed"/>
<argument name="website" value="{{customWebsite.name}}"/>
<argument name="storeView" value="{{customStoreEN.name}}"/>
</actionGroup>
</before>
<after>
<actionGroup ref="AdminDeleteCustomerActionGroup" stepKey="deleteCustomer">
<argument name="customerEmail" value="Simple_US_Customer.email"/>
<argument name="customerEmail" value="Simple_US_Customer_Assistance_Allowed.email"/>
</actionGroup>
<actionGroup ref="AdminDeleteWebsiteActionGroup" stepKey="deleteWebsite">
<argument name="websiteName" value="{{customWebsite.name}}"/>
Expand All @@ -65,7 +65,7 @@

<!-- Login as Customer from Customer page -->
<actionGroup ref="OpenEditCustomerFromAdminActionGroup" stepKey="OpenEditCustomerFrom">
<argument name="customer" value="Simple_US_Customer"/>
<argument name="customer" value="Simple_US_Customer_Assistance_Allowed"/>
</actionGroup>
<grabFromCurrentUrl regex="~id/(\d+)/~" stepKey="customerId" />
<actionGroup ref="AdminLoginAsCustomerLoginFromCustomerPageActionGroup"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<magentoCLI command="config:set {{LoginAsCustomerStoreViewLogin.path}} 0"
stepKey="enableLoginAsCustomerAutoDetection"/>
<magentoCLI command="cache:flush config" stepKey="flushCacheBeforeTestRun"/>
<createData entity="Simple_US_Customer" stepKey="createCustomer"/>
<createData entity="Simple_US_Customer_Assistance_Allowed" stepKey="createCustomer"/>
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAdmin"/>
</before>
<after>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
stepKey="enableLoginAsCustomerAutoDetection"/>
<magentoCLI command="cache:flush config" stepKey="flushCacheBeforeTestRun"/>
<createData entity="NewAdminUser" stepKey="createNewAdmin"/>
<createData entity="Simple_US_Customer" stepKey="createFirstCustomer"/>
<createData entity="Simple_US_CA_Customer" stepKey="createSecondCustomer"/>
<createData entity="Simple_US_Customer_Assistance_Allowed" stepKey="createFirstCustomer"/>
<createData entity="Simple_US_CA_Customer_Assistance_Allowed" stepKey="createSecondCustomer"/>
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsDefaultUser"/>
</before>
<after>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</skip>
</annotations>
<before>
<createData entity="Simple_US_Customer" stepKey="createCustomer"/>
<createData entity="Simple_US_Customer_Assistance_Allowed" stepKey="createCustomer"/>
<magentoCLI command="config:set {{LoginAsCustomerConfigDataEnabled.path}} 1"
stepKey="enableLoginAsCustomer"/>
<magentoCLI command="config:set {{LoginAsCustomerStoreViewLogin.path}} 1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<magentoCLI command="cache:flush config" stepKey="flushCacheBeforeTestRun"/>
<createData entity="SimpleProduct2" stepKey="createProduct1"/>
<createData entity="SimpleProduct2" stepKey="createProduct2"/>
<createData entity="Simple_US_Customer_Two_Addresses" stepKey="createCustomer"/>
<createData entity="Simple_US_Customer_Assistance_Allowed_Two_Addresses" stepKey="createCustomer"/>
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
</before>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<createData entity="SimpleProduct" stepKey="createProduct">
<requiredEntity createDataKey="createCategory"/>
</createData>
<createData entity="Simple_US_Customer" stepKey="createCustomer"/>
<createData entity="Simple_US_Customer_Assistance_Allowed" stepKey="createCustomer"/>

<!-- Create new User -->
<actionGroup ref="AdminLoginActionGroup" stepKey="adminLogin"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<createData entity="SimpleProduct" stepKey="createProduct">
<requiredEntity createDataKey="createCategory"/>
</createData>
<createData entity="Simple_US_Customer" stepKey="createCustomer"/>
<createData entity="Simple_US_Customer_Assistance_Allowed" stepKey="createCustomer"/>

<!-- Create new User -->
<actionGroup ref="AdminLoginActionGroup" stepKey="adminLogin"/>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<magentoCLI command="config:set {{LoginAsCustomerStoreViewLogin.path}} 0"
stepKey="enableLoginAsCustomerAutoDetection"/>
<magentoCLI command="cache:flush config" stepKey="flushCacheBeforeTestRun"/>
<createData entity="Simple_US_Customer" stepKey="createCustomer"/>
<createData entity="Simple_US_Customer_Assistance_Allowed" stepKey="createCustomer"/>
<actionGroup ref="AdminLoginActionGroup" stepKey="login"/>
</before>
<after>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<magentoCLI command="config:set {{LoginAsCustomerStoreViewLogin.path}} 0"
stepKey="enableLoginAsCustomerAutoDetection"/>
<magentoCLI command="cache:flush config" stepKey="flushCacheBeforeTestRun"/>
<createData entity="Simple_US_Customer" stepKey="createCustomer"/>
<createData entity="Simple_US_Customer_Assistance_Allowed" stepKey="createCustomer"/>
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsDefaultUser"/>
</before>
<after>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,14 @@
value="Verify Admin users can have only one 'Login as Customer' session at a time"/>
<severity value="MAJOR"/>
<group value="login_as_customer"/>
<skip>
<issueId value="https://github.com/magento/magento2-login-as-customer/pull/193"/>
</skip>
</annotations>
<before>
<magentoCLI command="config:set {{LoginAsCustomerConfigDataEnabled.path}} 1" stepKey="enableLoginAsCustomer"/>
<magentoCLI command="config:set {{LoginAsCustomerStoreViewLogin.path}} 0"
stepKey="enableLoginAsCustomerAutoDetection"/>
<magentoCLI command="cache:flush config" stepKey="flushCacheBeforeTestRun"/>
<createData entity="Simple_US_Customer" stepKey="createFirstCustomer"/>
<createData entity="Simple_US_CA_Customer" stepKey="createSecondCustomer"/>
<createData entity="Simple_US_Customer_Assistance_Allowed" stepKey="createFirstCustomer"/>
<createData entity="Simple_US_CA_Customer_Assistance_Allowed" stepKey="createSecondCustomer"/>
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsDefaultUser"/>
</before>
<after>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<createData entity="SimpleProduct" stepKey="createSimpleProduct">
<requiredEntity createDataKey="createCategory"/>
</createData>
<createData entity="Simple_US_Customer" stepKey="createCustomer"/>
<createData entity="Simple_US_Customer_Assistance_Allowed" stepKey="createCustomer"/>
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsDefaultAdminUserBefore"/>

<!--Create New Role-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<createData entity="SimpleProduct" stepKey="createSimpleProduct">
<requiredEntity createDataKey="createCategory"/>
</createData>
<createData entity="Simple_US_Customer" stepKey="createCustomer"/>
<createData entity="Simple_US_Customer_Assistance_Allowed" stepKey="createCustomer"/>
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsDefaultAdminUserBefore"/>

<!--Create New Role-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<createData entity="SimpleProduct" stepKey="createSimpleProduct">
<requiredEntity createDataKey="createCategory"/>
</createData>
<createData entity="Simple_US_Customer" stepKey="createCustomer"/>
<createData entity="Simple_US_Customer_Assistance_Allowed" stepKey="createCustomer"/>
<actionGroup ref="AdminLoginActionGroup" stepKey="login"/>
</before>
<after>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<createData entity="SimpleProduct" stepKey="createSimpleProduct">
<requiredEntity createDataKey="createCategory"/>
</createData>
<createData entity="Simple_US_Customer" stepKey="createCustomer"/>
<createData entity="Simple_US_Customer_Assistance_Allowed" stepKey="createCustomer"/>
<actionGroup ref="AdminLoginActionGroup" stepKey="login"/>
</before>
<after>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<createData entity="SimpleProduct" stepKey="createSimpleProduct">
<requiredEntity createDataKey="createCategory"/>
</createData>
<createData entity="Simple_US_Customer" stepKey="createCustomer"/>
<createData entity="Simple_US_Customer_Assistance_Allowed" stepKey="createCustomer"/>
<actionGroup ref="AdminLoginActionGroup" stepKey="login"/>
</before>
<after>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<group value="login_as_customer"/>
</annotations>
<before>
<createData entity="Simple_US_Customer" stepKey="createCustomer"/>
<createData entity="Simple_US_Customer_Assistance_Allowed" stepKey="createCustomer"/>
<magentoCLI command="config:set {{LoginAsCustomerConfigDataEnabled.path}} 1"
stepKey="enableLoginAsCustomer"/>
<magentoCLI command="config:set {{LoginAsCustomerStoreViewLogin.path}} 0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<requiredEntity createDataKey="createCategory"/>
<field key="price">10</field>
</createData>
<createData entity="Simple_US_Customer" stepKey="createCustomer">
<createData entity="Simple_US_Customer_Assistance_Allowed" stepKey="createCustomer">
<field key="group_id">3</field>
</createData>
<actionGroup ref="AdminLoginActionGroup" stepKey="login"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<createData entity="SimpleProduct" stepKey="createSimpleProduct">
<requiredEntity createDataKey="createCategory"/>
</createData>
<createData entity="Simple_US_Customer" stepKey="createCustomer"/>
<createData entity="Simple_US_Customer_Assistance_Allowed" stepKey="createCustomer"/>
<actionGroup ref="AdminLoginActionGroup" stepKey="login"/>
</before>
<after>
Expand Down
Loading

0 comments on commit be26941

Please sign in to comment.