Skip to content

Commit

Permalink
Merge pull request magento#3509 from magento-tsg/2.2-develop-pr60
Browse files Browse the repository at this point in the history
[TSG] Backporting for 2.2 (pr60) (2.2.8)
  • Loading branch information
Alexander Akimov authored Dec 5, 2018
2 parents 8c6000f + edd3a2f commit b4269c2
Show file tree
Hide file tree
Showing 31 changed files with 574 additions and 170 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?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">
<!--Login as any user-->
<actionGroup name="AdminLoginAsAnyUser">
<arguments>
<argument name="login" type="string" defaultValue="{{_ENV.MAGENTO_ADMIN_USERNAME}}"/>
<argument name="password" type="string" defaultValue="{{_ENV.MAGENTO_ADMIN_PASSWORD}}"/>
</arguments>
<amOnPage url="{{AdminLoginPage.url}}" stepKey="navigateToAdmin"/>
<fillField userInput="{{login}}" selector="{{AdminLoginFormSection.username}}" stepKey="fillUsername"/>
<fillField userInput="{{password}}" selector="{{AdminLoginFormSection.password}}" stepKey="fillPassword"/>
<click selector="{{AdminLoginFormSection.signIn}}" stepKey="clickLogin"/>
<closeAdminNotification stepKey="closeAdminNotification"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,23 @@
<waitForPageLoad stepKey="waitForPageLoad"/>
<dontSeeElement selector="{{AdminProductImagesSection.imageFile(image.filename)}}" stepKey="seeImage"/>
</actionGroup>
<actionGroup name="CreatedProductConnectToWebsite">
<arguments>
<argument name="website"/>
<argument name="product"/>
</arguments>
<amOnPage url="{{AdminProductIndexPage.url}}" stepKey="navigateToProductGridPage"/>
<conditionalClick selector="{{AdminProductGridFilterSection.clearFilters}}" dependentSelector="{{AdminProductGridFilterSection.clearFilters}}" visible="true" stepKey="clickClearFilters"/>
<click selector="{{AdminProductGridFilterSection.filters}}" stepKey="openProductFilters"/>
<fillField selector="{{AdminProductGridFilterSection.skuFilter}}" userInput="{{product.sku}}" stepKey="fillProductSkuFilter"/>
<click selector="{{AdminProductGridFilterSection.applyFilters}}" stepKey="clickApplyFilters"/>
<waitForElementNotVisible selector="{{AdminProductGridSection.loadingMask}}" stepKey="waitForFilteredGridLoad" time="30"/>
<click selector="{{AdminProductGridSection.firstRow}}" stepKey="openProduct"/>
<waitForPageLoad stepKey="waitForProductPage"/>
<scrollTo selector="{{ProductInWebsitesSection.sectionHeader}}" stepKey="scrollToWebsites"/>
<click selector="{{ProductInWebsitesSection.sectionHeader}}" stepKey="openWebsitesList"/>
<click selector="{{ProductInWebsitesSection.website(website.name)}}" stepKey="selectWebsite"/>
<click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="clickSaveProduct"/>
<see selector="{{AdminMessagesSection.success}}" userInput="You saved the product." stepKey="seeSaveConfirmation"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ public function __construct(
}

/**
* Initialize template for error message.
*
* @param array $templateCollection
* @return $this
*/
Expand Down Expand Up @@ -377,6 +379,8 @@ public function retrieveAttributeFromCache($attributeCode)
}

/**
* Adding attribute option.
*
* In case we've dynamically added new attribute option during import we need to add it to our cache
* in order to keep it up to date.
*
Expand Down Expand Up @@ -508,8 +512,10 @@ public function isSuitable()
}

/**
* Prepare attributes values for save: exclude non-existent, static or with empty values attributes;
* set default values if needed
* Adding default attribute to product before save.
*
* Prepare attributes values for save: exclude non-existent, static or with empty values attributes,
* set default values if needed.
*
* @param array $rowData
* @param bool $withDefaultValue
Expand Down Expand Up @@ -537,9 +543,9 @@ public function prepareAttributesWithDefaultValueForSave(array $rowData, $withDe
} else {
$resultAttrs[$attrCode] = $rowData[$attrCode];
}
} elseif (array_key_exists($attrCode, $rowData)) {
} elseif (array_key_exists($attrCode, $rowData) && empty($rowData['_store'])) {
$resultAttrs[$attrCode] = $rowData[$attrCode];
} elseif ($withDefaultValue && null !== $attrParams['default_value']) {
} elseif ($withDefaultValue && null !== $attrParams['default_value'] && empty($rowData['_store'])) {
$resultAttrs[$attrCode] = $attrParams['default_value'];
}
}
Expand Down Expand Up @@ -605,7 +611,8 @@ protected function getProductEntityLinkField()
}

/**
* Clean cached values
* Clean cached values.
*
* @since 100.2.0
*/
public function __destruct()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?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="AdminCreateCustomerWithWebsiteAndStoreViewActionGroup">
<arguments>
<argument name="customer"/>
<argument name="address"/>
<argument name="websiteName" type="string"/>
<argument name="storeViewName" type="string"/>
</arguments>
<amOnPage url="{{AdminCustomerPage.url}}" stepKey="goToCustomersPage"/>
<click selector="{{AdminCustomerGridMainActionsSection.addNewCustomer}}" stepKey="addNewCustomer"/>
<selectOption selector="{{AdminCustomerAccountInformationSection.associateToWebsite}}" userInput="{{websiteName}}" stepKey="selectWebSite"/>
<fillField selector="{{AdminCustomerAccountInformationSection.firstName}}" userInput="{{customer.firstname}}" stepKey="fillFirstName"/>
<fillField selector="{{AdminCustomerAccountInformationSection.lastName}}" userInput="{{customer.lastname}}" stepKey="fillLastName"/>
<fillField selector="{{AdminCustomerAccountInformationSection.email}}" userInput="{{customer.email}}" stepKey="fillEmail"/>
<selectOption selector="{{AdminCustomerAccountInformationSection.storeView}}" userInput="{{storeViewName}}" stepKey="selectStoreView"/>
<scrollToTopOfPage stepKey="scrollToTopOfThePage"/>
<click selector="{{AdminCustomerAccountInformationSection.addressesButton}}" stepKey="goToAddresses"/>
<waitForPageLoad stepKey="waitForAddresses"/>
<click selector="{{AdminCustomerEditAddressesSection.addNewAddress}}" stepKey="clickOnAddNewAddress"/>
<waitForPageLoad stepKey="waitForAddressFields"/>
<click selector="{{AdminCustomerEditAddressesSection.defaultBillingAddress}}" stepKey="tickBillingAddress"/>
<click selector="{{AdminCustomerEditAddressesSection.defaultShippingAddress}}" stepKey="tickShippingAddress"/>
<fillField selector="{{AdminCustomerEditAddressesSection.firstName}}" userInput="{{address.firstname}}" stepKey="fillFirstNameForAddress"/>
<fillField selector="{{AdminCustomerEditAddressesSection.lastName}}" userInput="{{address.lastname}}" stepKey="fillLastNameForAddress"/>
<fillField selector="{{AdminCustomerEditAddressesSection.streetAddress}}" userInput="{{address.street[0]}}" stepKey="fillStreetAddress"/>
<fillField selector="{{AdminCustomerEditAddressesSection.city}}" userInput="{{address.city}}" stepKey="fillCity"/>
<selectOption selector="{{AdminCustomerEditAddressesSection.country}}" userInput="{{address.country}}" stepKey="selectCountry"/>
<selectOption selector="{{AdminCustomerEditAddressesSection.state}}" userInput="{{address.state}}" stepKey="selectState"/>
<fillField selector="{{AdminCustomerEditAddressesSection.zip}}" userInput="{{address.postcode}}" stepKey="fillZip"/>
<fillField selector="{{AdminCustomerEditAddressesSection.phoneNumber}}" userInput="{{address.telephone}}" stepKey="fillPhoneNumber"/>
<click selector="{{AdminMainActionsSection.save}}" stepKey="save"/>
<see userInput="You saved the customer." stepKey="seeSuccessMessage"/>
</actionGroup>
</actionGroups>
1 change: 1 addition & 0 deletions app/code/Magento/Customer/Test/Mftf/Data/AddressData.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
<data key="default_billing">Yes</data>
<data key="default_shipping">Yes</data>
<requiredEntity type="region">RegionNY</requiredEntity>
<data key="country">United States</data>
</entity>
<entity name="UK_Default_Address" type="address">
<data key="firstname">Jane</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<section name="AdminCustomerAccountInformationSection">
<element name="accountInformationTitle" type="text" selector=".admin__page-nav-title"/>
<element name="accountInformationButton" type="text" selector="//a/span[text()='Account Information']"/>
<element name="addressesButton" type="select" selector="//a//span[contains(text(), 'Addresses')]"/>
<element name="firstName" type="input" selector="input[name='customer[firstname]']"/>
<element name="lastName" type="input" selector="input[name='customer[lastname]']"/>
<element name="email" type="input" selector="input[name='customer[email]']"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?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="AdminCustomerEditAddressesSection">
<element name="addNewAddress" type="button" selector="//span[text()='Add New Addresses']"/>
<element name="defaultBillingAddress" type="button" selector="//label[text()='Default Billing Address']"/>
<element name="defaultShippingAddress" type="button" selector="//label[text()='Default Shipping Address']"/>
<element name="firstName" type="button" selector="input[name*='address'][name*=firstname]"/>
<element name="lastName" type="button" selector="input[name*='address'][name*=lastname]"/>
<element name="streetAddress" type="button" selector="input[name*='address'][name*=street]"/>
<element name="city" type="input" selector="input[name*='address'][name*=city]"/>
<element name="country" type="select" selector="select[name*='address'][name*=country_id]"/>
<element name="state" type="select" selector="select[name*=address][name*=region_id]"/>
<element name="zip" type="input" selector="input[name*=address][name*=postcode]"/>
<element name="phoneNumber" type="input" selector="input[name*=address][name*=telephone]"/>
</section>
</sections>
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,7 @@ public function getBehavior()
$this->_parameters['behavior']
) ||
$this->_parameters['behavior'] != ImportExport::BEHAVIOR_APPEND &&
$this->_parameters['behavior'] != ImportExport::BEHAVIOR_ADD_UPDATE &&
$this->_parameters['behavior'] != ImportExport::BEHAVIOR_REPLACE &&
$this->_parameters['behavior'] != ImportExport::BEHAVIOR_DELETE
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ define([
return resultWrapper(null, false, false);
}

value = value.replace(/\-|\s/g, '');
value = value.replace(/|\s/g, '');

if (!/^\d*$/.test(value)) {
return resultWrapper(null, false, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
}(function ($, cvvValidator, creditCardNumberValidator, yearValidator, monthValidator, creditCardData) {
'use strict';

$('.payment-method-content input[type="number"]').on('keyup', function () {
if ($(this).val() < 0) {
$(this).val($(this).val().replace(/^-/, ''));
}
});

$.each({
'validate-card-type': [
function (number, item, allowedTypes) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?php
/**
*
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Persistent\Observer;

use Magento\Framework\Event\ObserverInterface;

/**
* Observer for a work with persistent data.
*/
class SetCheckoutSessionPersistentDataObserver implements ObserverInterface
{
/**
* Persistent session.
*
* @var \Magento\Persistent\Helper\Session
*/
private $persistentSession = null;

/**
* Customer session.
*
* @var \Magento\Customer\Model\Session
*/
private $customerSession;

/**
* Persistent data.
*
* @var \Magento\Persistent\Helper\Data
*/
private $persistentData = null;

/**
* Customer Repository.
*
* @var \Magento\Customer\Api\CustomerRepositoryInterface
*/
private $customerRepository = null;

/**
* @param \Magento\Persistent\Helper\Session $persistentSession
* @param \Magento\Customer\Model\Session $customerSession
* @param \Magento\Persistent\Helper\Data $persistentData
* @param \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository
*/
public function __construct(
\Magento\Persistent\Helper\Session $persistentSession,
\Magento\Customer\Model\Session $customerSession,
\Magento\Persistent\Helper\Data $persistentData,
\Magento\Customer\Api\CustomerRepositoryInterface $customerRepository
) {
$this->persistentSession = $persistentSession;
$this->customerSession = $customerSession;
$this->persistentData = $persistentData;
$this->customerRepository = $customerRepository;
}

/**
* Pass customer data from persistent session to checkout session and set quote to be loaded even if not active.
*
* @param \Magento\Framework\Event\Observer $observer
* @return void
*/
public function execute(\Magento\Framework\Event\Observer $observer)
{
/** @var $checkoutSession \Magento\Checkout\Model\Session */
$checkoutSession = $observer->getEvent()->getData('checkout_session');
if ($this->persistentData->isShoppingCartPersist() && $this->persistentSession->isPersistent()) {
$checkoutSession->setCustomerData(
$this->customerRepository->getById($this->persistentSession->getSession()->getCustomerId())
);
}
if (!(($this->persistentSession->isPersistent() && !$this->customerSession->isLoggedIn())
&& !$this->persistentData->isShoppingCartPersist()
)) {
return;
}
if ($checkoutSession) {
$checkoutSession->setLoadInactive();
}
}
}

This file was deleted.

Loading

0 comments on commit b4269c2

Please sign in to comment.