Skip to content

Commit

Permalink
merge magento/2.4-develop into magento-mpi/MC-34091
Browse files Browse the repository at this point in the history
  • Loading branch information
magento-mts-svc authored Aug 24, 2020
2 parents 51827b3 + 7fbae46 commit dccbfe7
Show file tree
Hide file tree
Showing 39 changed files with 553 additions and 221 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?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="AdminNavigateToEmailToFriendSettingsActionGroup">
<amOnPage url="{{AdminConfigurationEmailToFriendPage.url}}" stepKey="navigateToPersistencePage"/>
<conditionalClick selector="{{AdminEmailToFriendSection.DefaultLayoutsTab}}" dependentSelector="{{AdminEmailToFriendSection.CheckIfTabExpand}}" visible="true" stepKey="clickTab"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?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="AssertAdminEmailToFriendOptionsAvailableActionGroup">
<seeElement stepKey="seeEmailTemplateInput" selector="{{AdminEmailToFriendSection.emailTemplate}}"/>
<seeElement stepKey="seeAllowForGuestsInput" selector="{{AdminEmailToFriendSection.allowForGuests}}"/>
<seeElement stepKey="seeMaxRecipientsInput" selector="{{AdminEmailToFriendSection.maxRecipients}}"/>
<seeElement stepKey="seeMaxPerHourInput" selector="{{AdminEmailToFriendSection.maxPerHour}}"/>
<seeElement stepKey="seeLimitSendingBy" selector="{{AdminEmailToFriendSection.limitSendingBy}}"/>
</actionGroup>
</actionGroups>
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.
*/
-->

<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd">
<page name="AdminConfigurationEmailToFriendPage" url="admin/system_config/edit/section/sendfriend/" module="Catalog" area="admin">
<section name="AdminEmailToFriendSection"/>
</page>
</pages>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="AdminCatalogEmailToFriendSettingsTest">
<annotations>
<features value="Backend"/>
<stories value="Enable Email To A Friend Functionality"/>
<title value="Admin should be able to manage settings of Email To A Friend Functionality"/>
<description value="Admin should be able to enable Email To A Friend functionality in Magento Admin backend and see additional options"/>
<group value="backend"/>
<severity value="MINOR"></severity>
<testCaseId value="MC-35895"/>
</annotations>

<before>
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
<magentoCLI stepKey="enableSendFriend" command="config:set sendfriend/email/enabled 1"/>
<magentoCLI stepKey="cacheClean" command="cache:clean config"/>
</before>
<after>
<magentoCLI stepKey="disableSendFriend" command="config:set sendfriend/email/enabled 0"/>
<magentoCLI stepKey="cacheClean" command="cache:clean config"/>
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
</after>

<actionGroup ref="AdminNavigateToEmailToFriendSettingsActionGroup" stepKey="navigateToSendFriendSettings"/>
<actionGroup ref="AssertAdminEmailToFriendOptionsAvailableActionGroup" stepKey="assertOptions"/>
</test>
</tests>
2 changes: 1 addition & 1 deletion app/code/Magento/Captcha/CustomerData/Captcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function __construct(
/**
* @inheritdoc
*/
public function getSectionData() :array
public function getSectionData(): array
{
$data = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@
<element name="storeViewDropdown" type="text" selector="//select[@name='store_id']/option[contains(.,'{{storeView}}')]" parameterized="true"/>
<element name="inputByCodeRangeFrom" type="input" selector="input.admin__control-text[name='{{code}}[from]']" parameterized="true"/>
<element name="inputByCodeRangeTo" type="input" selector="input.admin__control-text[name='{{code}}[to]']" parameterized="true"/>
<element name="storeViewOptions" type="text" selector=".admin__data-grid-outer-wrap select[name='store_id'] > option[value='{{value}}']" parameterized="true"/>
</section>
</sections>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?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="AdminEmailToFriendSection">
<element name="DefaultLayoutsTab" type="button" selector=".entry-edit-head-link"/>
<element name="CheckIfTabExpand" type="button" selector=".entry-edit-head-link:not(.open)"/>
<element name="emailTemplate" type="input" selector="#sendfriend_email_template"/>
<element name="allowForGuests" type="input" selector="#sendfriend_email_allow_guest"/>
<element name="maxRecipients" type="input" selector="#sendfriend_email_max_recipients"/>
<element name="maxPerHour" type="input" selector="#sendfriend_email_max_per_hour"/>
<element name="limitSendingBy" type="input" selector="#sendfriend_email_check_by"/>
</section>
</sections>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?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="AdminClickFirstRowEditLinkOnCustomerGridActionGroup">
<annotations>
<description>Click edit link for first row on the grid.</description>
</annotations>

<click selector="{{AdminCustomerGridSection.firstRowEditLink}}" stepKey="clickOnEditLink"/>
<waitForPageLoad stepKey="waitForPageLoading"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@
<see userInput="{{CustomerEntityOne.email}}" selector="{{AdminCustomerGridSection.customerGrid}}" stepKey="assertEmail"/>

<!--Assert Customer Form -->
<click selector="{{AdminCustomerGridSection.firstRowEditLink}}" stepKey="clickOnEditButton1"/>
<waitForPageLoad stepKey="waitForCustomerEditPageToLoad1"/>
<actionGroup ref="AdminClickFirstRowEditLinkOnCustomerGridActionGroup" stepKey="clickOnEditButton1"/>
<click selector="{{AdminCustomerAccountInformationSection.accountInformationButton}}" stepKey="clickOnAccountInformation"/>
<waitForPageLoad stepKey="waitForCustomerInformationPageToLoad"/>
<see selector="{{AdminCustomerAccountInformationSection.groupIdValue}}" userInput="Retailer" stepKey="seeCustomerGroup1"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
<actionGroup ref="AdminFilterCustomerByEmail" stepKey="filterTheCustomerByEmail">
<argument name="email" value="$$createCustomer.email$$"/>
</actionGroup>
<click selector="{{AdminCustomerGridSection.firstRowEditLink}}" stepKey="clickOnEditButton"/>
<waitForPageLoad stepKey="waitForCustomerEditPageToLoad"/>
<actionGroup ref="AdminClickFirstRowEditLinkOnCustomerGridActionGroup" stepKey="clickOnEditButton"/>

<!-- Add the Address -->
<click selector="{{AdminEditCustomerAddressesSection.addresses}}" stepKey="selectAddress"/>
Expand Down Expand Up @@ -67,8 +66,7 @@
<see userInput="{{PolandAddress.telephone}}" selector="{{AdminCustomerGridSection.customerGrid}}" stepKey="assertPhoneNumber"/>

<!--Assert Customer Form -->
<click selector="{{AdminCustomerGridSection.firstRowEditLink}}" stepKey="clickOnEditButton1"/>
<waitForPageLoad stepKey="waitForCustomerEditPageToLoad1"/>
<actionGroup ref="AdminClickFirstRowEditLinkOnCustomerGridActionGroup" stepKey="clickOnEditButton1"/>
<click selector="{{AdminCustomerAccountInformationSection.accountInformationButton}}" stepKey="clickOnAccountInformation"/>
<waitForPageLoad stepKey="waitForCustomerInformationPageToLoad"/>
<seeInField selector="{{AdminCustomerAccountInformationSection.firstName}}" userInput="$$createCustomer.firstname$$" stepKey="seeCustomerFirstName"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
<actionGroup ref="AdminFilterCustomerByEmail" stepKey="filterTheCustomerByEmail">
<argument name="email" value="$$createCustomer.email$$"/>
</actionGroup>
<click selector="{{AdminCustomerGridSection.firstRowEditLink}}" stepKey="clickOnEditButton"/>
<waitForPageLoad stepKey="waitForCustomerEditPageToLoad"/>
<actionGroup ref="AdminClickFirstRowEditLinkOnCustomerGridActionGroup" stepKey="clickOnEditButton"/>

<!-- Add the Address -->
<click selector="{{AdminEditCustomerAddressesSection.addresses}}" stepKey="selectAddress"/>
Expand Down Expand Up @@ -67,8 +66,7 @@
<see userInput="{{US_Address_CA.telephone}}" selector="{{AdminCustomerGridSection.customerGrid}}" stepKey="assertPhoneNumber"/>

<!--Assert Customer Form -->
<click selector="{{AdminCustomerGridSection.firstRowEditLink}}" stepKey="clickOnEditButton1"/>
<waitForPageLoad stepKey="waitForCustomerEditPageToLoad1"/>
<actionGroup ref="AdminClickFirstRowEditLinkOnCustomerGridActionGroup" stepKey="clickOnEditButton1"/>
<click selector="{{AdminCustomerAccountInformationSection.accountInformationButton}}" stepKey="clickOnAccountInformation"/>
<waitForPageLoad stepKey="waitForCustomerInformationPageToLoad"/>
<seeInField selector="{{AdminCustomerAccountInformationSection.firstName}}" userInput="$$createCustomer.firstname$$" stepKey="seeCustomerFirstName"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@
<see userInput="{{CustomerEntityOne.email}}" selector="{{AdminCustomerGridSection.customerGrid}}" stepKey="assertEmail"/>

<!--Assert Customer Form -->
<click selector="{{AdminCustomerGridSection.firstRowEditLink}}" stepKey="clickOnEditButton1"/>
<waitForPageLoad stepKey="waitForCustomerEditPageToLoad1"/>
<actionGroup ref="AdminClickFirstRowEditLinkOnCustomerGridActionGroup" stepKey="clickOnEditButton1"/>
<click selector="{{AdminCustomerAccountInformationSection.accountInformationButton}}" stepKey="clickOnAccountInformation"/>
<waitForPageLoad stepKey="waitForCustomerInformationPageToLoad"/>
<see selector="{{AdminCustomerAccountInformationSection.groupIdValue}}" userInput="$$customerGroup.code$$" stepKey="seeCustomerGroup1"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@
<see userInput="Male" selector="{{AdminCustomerGridSection.customerGrid}}" stepKey="assertGender"/>

<!--Assert Customer Form -->
<click selector="{{AdminCustomerGridSection.firstRowEditLink}}" stepKey="clickOnEditButton1"/>
<waitForPageLoad stepKey="waitForCustomerEditPageToLoad1"/>
<actionGroup ref="AdminClickFirstRowEditLinkOnCustomerGridActionGroup" stepKey="clickOnEditButton1"/>
<click selector="{{AdminCustomerAccountInformationSection.accountInformationButton}}" stepKey="clickOnAccountInformation"/>
<waitForPageLoad stepKey="waitForCustomerInformationPageToLoad"/>
<seeInField selector="{{AdminCustomerAccountInformationSection.namePrefix}}" userInput="{{CustomerEntityOne.prefix}}" stepKey="seeCustomerNamePrefix"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@
<see userInput="{{CustomerEntityOne.email}}" selector="{{AdminCustomerGridSection.customerGrid}}" stepKey="assertEmail"/>

<!--Assert Customer Form -->
<click selector="{{AdminCustomerGridSection.firstRowEditLink}}" stepKey="clickOnEditButton1"/>
<waitForPageLoad stepKey="waitForCustomerEditPageToLoad1"/>
<actionGroup ref="AdminClickFirstRowEditLinkOnCustomerGridActionGroup" stepKey="clickOnEditButton1"/>
<click selector="{{AdminCustomerAccountInformationSection.accountInformationButton}}" stepKey="clickOnAccountInformation"/>
<waitForPageLoad stepKey="waitForCustomerInformationPageToLoad"/>
<seeInField selector="{{AdminCustomerAccountInformationSection.firstName}}" userInput="{{CustomerEntityOne.firstname}}" stepKey="seeCustomerFirstName"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@
<see selector="{{AdminCustomerGridSection.customerGrid}}" userInput="{{CustomerEntityOne.email}}" stepKey="seeAssertCustomerEmailInGrid"/>

<!--Assert verify created new customer is subscribed to newsletter-->
<click selector="{{AdminCustomerGridSection.firstRowEditLink}}" stepKey="clickFirstRowEditLink"/>
<waitForPageLoad stepKey="waitForEditLinkLoad"/>
<actionGroup ref="AdminClickFirstRowEditLinkOnCustomerGridActionGroup" stepKey="clickFirstRowEditLink"/>
<click selector="{{AdminEditCustomerInformationSection.newsLetter}}" stepKey="clickNewsLetter"/>
<waitForPageLoad stepKey="waitForNewsletterTabToOpen"/>
<seeCheckboxIsChecked selector="{{AdminEditCustomerNewsletterSection.subscribedStatus('1')}}" stepKey="seeAssertSubscribedToNewsletterCheckboxIsChecked"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@
<argument name="email" value="{{CustomerEntityOne.email}}"/>
</actionGroup>
<waitForPageLoad stepKey="waitForPageToLoad"/>
<click selector="{{AdminCustomerGridSection.firstRowEditLink}}" stepKey="clickOnEditButton1"/>
<waitForPageLoad stepKey="waitForCustomerEditPageToLoad"/>
<actionGroup ref="AdminClickFirstRowEditLinkOnCustomerGridActionGroup" stepKey="clickOnEditButton1"/>

<!-- Assert Customer Title -->
<click selector="{{AdminCustomerAccountInformationSection.accountInformationButton}}" stepKey="clickOnAccountInformation"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@
<actionGroup ref="AdminFilterCustomerByEmail" stepKey="filterCustomerGrid">
<argument name="email" value="{{CustomerEntityOne.email}}"/>
</actionGroup>
<click selector="{{AdminCustomerGridSection.firstRowEditLink}}" stepKey="clickToEditCustomerPage"/>
<waitForPageLoad stepKey="waitForOpenCustomerPage"/>
<actionGroup ref="AdminClickFirstRowEditLinkOnCustomerGridActionGroup" stepKey="clickToEditCustomerPage"/>
<grabFromCurrentUrl regex="~(\d+)/~" stepKey="grabCustomerId"/>
<!-- Assert that created customer is subscribed to newsletter on the new Store View -->
<actionGroup ref="AdminAssertCustomerIsSubscribedToNewslettersAndSelectedStoreView" stepKey="assertSubscribedToNewsletter">
Expand Down
45 changes: 37 additions & 8 deletions app/code/Magento/Newsletter/Model/SubscriptionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,14 @@ private function saveSubscriber(
): bool {
$statusChanged = (int)$subscriber->getStatus() !== $status;
$emailChanged = $subscriber->getEmail() !== $customer->getEmail();
if ($subscriber->getId()
&& !$statusChanged
&& (int)$subscriber->getCustomerId() === (int)$customer->getId()
&& (int)$subscriber->getStoreId() === $storeId
&& !$emailChanged
) {
if ($this->dontNeedToSaveSubscriber(
$subscriber,
$customer,
$statusChanged,
$storeId,
$status,
$emailChanged
)) {
return false;
}

Expand All @@ -220,10 +222,37 @@ private function saveSubscriber(

/**
* If the subscriber is waiting to confirm from the customer
* and customer changed the email
* or customer changed the email
* than need to send confirmation letter to the new email
*/
return $status === Subscriber::STATUS_NOT_ACTIVE && $emailChanged;
return $status === Subscriber::STATUS_NOT_ACTIVE || $emailChanged;
}

/**
* Don't need to save subscriber model
*
* @param Subscriber $subscriber
* @param CustomerInterface $customer
* @param bool $statusChanged
* @param int $storeId
* @param int $status
* @param bool $emailChanged
* @return bool
*/
private function dontNeedToSaveSubscriber(
Subscriber $subscriber,
CustomerInterface $customer,
bool $statusChanged,
int $storeId,
int $status,
bool $emailChanged
): bool {
return $subscriber->getId()
&& !$statusChanged
&& (int)$subscriber->getCustomerId() === (int)$customer->getId()
&& (int)$subscriber->getStoreId() === $storeId
&& !$emailChanged
&& $status !== Subscriber::STATUS_NOT_ACTIVE;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ public function subscribeCustomerDataProvider(): array
'subscriber_status' => Subscriber::STATUS_SUBSCRIBED,
'subscriber_confirm_code' => '',
],
'needToSendEmail' => false,
'needToSendEmail' => true,
],
'Update subscription data: subscription confirm required ' => [
'subscriber_data' => [
Expand Down Expand Up @@ -618,7 +618,7 @@ public function unsubscribeCustomerDataProvider(): array
'subscriber_status' => Subscriber::STATUS_NOT_ACTIVE,
'subscriber_confirm_code' => '',
],
'needToSendEmail' => false,
'needToSendEmail' => true,
],
'Update subscription data' => [
'subscriber_data' => [
Expand All @@ -642,7 +642,7 @@ public function unsubscribeCustomerDataProvider(): array
'subscriber_status' => Subscriber::STATUS_UNSUBSCRIBED,
'subscriber_confirm_code' => '',
],
'needToSendEmail' => false,
'needToSendEmail' => true,
],
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@
<actionGroup ref="AdminFilterCustomerByEmail" stepKey="filterCreatedCustomer">
<argument name="email" value="$$createCustomer.email$$"/>
</actionGroup>
<click selector="{{AdminCustomerGridSection.firstRowEditLink}}" stepKey="clickEditButton"/>
<waitForPageLoad stepKey="waitForPageLoad"/>
<actionGroup ref="AdminClickFirstRowEditLinkOnCustomerGridActionGroup" stepKey="clickEditButton"/>

<!-- Click create order -->
<click selector="{{AdminCustomerMainActionsSection.createOrderBtn}}" stepKey="clickCreateOrder"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@
<actionGroup ref="AdminFilterCustomerByEmail" stepKey="filterCreatedCustomer">
<argument name="email" value="$$createCustomer.email$$"/>
</actionGroup>
<click selector="{{AdminCustomerGridSection.firstRowEditLink}}" stepKey="clickEditButton"/>
<waitForPageLoad stepKey="waitForPageLoad"/>
<actionGroup ref="AdminClickFirstRowEditLinkOnCustomerGridActionGroup" stepKey="clickEditButton"/>

<!-- Click create order -->
<click selector="{{AdminCustomerMainActionsSection.createOrderBtn}}" stepKey="clickCreateOrder"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@
<actionGroup ref="AdminFilterCustomerByEmail" stepKey="filterCreatedCustomer">
<argument name="email" value="$$createCustomer.email$$"/>
</actionGroup>
<click selector="{{AdminCustomerGridSection.firstRowEditLink}}" stepKey="clickEditButton"/>
<waitForPageLoad stepKey="waitForPageLoad"/>
<actionGroup ref="AdminClickFirstRowEditLinkOnCustomerGridActionGroup" stepKey="clickEditButton"/>

<!-- Click create order -->
<click selector="{{AdminCustomerMainActionsSection.createOrderBtn}}" stepKey="clickCreateOrder"/>
Expand Down
Loading

0 comments on commit dccbfe7

Please sign in to comment.