Skip to content

Commit

Permalink
Merge pull request #389 from magento-south/BUGS
Browse files Browse the repository at this point in the history
[SOUTH] Bugs
  • Loading branch information
vpelipenko committed Jun 30, 2015
2 parents 0d9ecaa + 4ffe4e1 commit d0e08a2
Show file tree
Hide file tree
Showing 15 changed files with 239 additions and 130 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,8 @@ public function beforeSave($object)
);
}

if ($this->string->substr(
$password,
0,
1
) == ' ' || $this->string->substr(
$password,
$length - 1,
1
) == ' '
) {
throw new LocalizedException(__('The password can\'t begin or end with a space.'));
if (trim($password) != $password) {
throw new LocalizedException(__('The password can not begin or end with a space.'));
}

$object->setPasswordHash($object->hashPassword($password));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,9 @@
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
</item>
<item name="imports" xsi:type="array">
<item name="default" xsi:type="string">${ $.provider }:data.customer.firstname</item>
</item>
</item>
</argument>
</field>
Expand All @@ -325,6 +328,9 @@
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
</item>
<item name="imports" xsi:type="array">
<item name="default" xsi:type="string">${ $.provider }:data.customer.lastname</item>
</item>
</item>
</argument>
</field>
Expand Down
39 changes: 33 additions & 6 deletions app/code/Magento/Wishlist/view/frontend/web/js/add-to-wishlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,31 @@ define([
this._on(events);
},
_updateWishlistData: function(event) {
var dataToAdd = {};
var dataToAdd = {},
isFileUploaded = false;
if (event.handleObj.selector == this.options.qtyInfo) {
this._updateAddToWishlistButton({});
event.stopPropagation();
return;
}
var self = this;
$(event.handleObj.selector).each(function(index, element){
if ($(element).attr('type') == 'text') {
if ($(element).is('input[type=text]')
|| $(element).is('input[type=checkbox]:checked')
|| $(element).is('input[type=radio]:checked')
|| $('#' + element.id + ' option:selected').length
|| $(element).is('textarea')
) {
dataToAdd = $.extend({}, dataToAdd, self._getElementData(element));
return;
}
if ($(element).is(':checked') || $(element).find(':checked').length) {
dataToAdd = $.extend({}, dataToAdd, self._getElementData(element));
if ($(element).is('input[type=file]') && $(element).val()) {
isFileUploaded = true;
}
});

if (isFileUploaded) {
this.bindFormSubmit();
}
this._updateAddToWishlistButton(dataToAdd);
event.stopPropagation();
},
Expand Down Expand Up @@ -90,7 +98,9 @@ define([
data[elementName + '[' + option + ']'] = option;
});
} else {
data[elementName] = elementValue;
if (elementValue) {
data[elementName] = elementValue;
}
}
return data;
},
Expand All @@ -99,6 +109,23 @@ define([
$.each(dataToRemove, function(key, value) {
delete params.data[key];
});
},
bindFormSubmit: function() {
var self = this;
$('[data-action="add-to-wishlist"]').on('click', function(event) {
event.stopPropagation();
event.preventDefault();

var element = $('input[type=file]' + self.options.customOptionsInfo),
params = $(event.currentTarget).data('post'),
form = $(element).closest('form'),
action = params.action;
if (params.data.uenc) {
action += 'uenc/' + params.data.uenc;
}

$(form).attr('action', action).submit();
});
}
});

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\GiftMessage\Test\Block\Cart;

use Magento\GiftMessage\Test\Fixture\GiftMessage;
use Magento\Mtf\Block\Form;

/**
* Class GiftOptions
* Add gift options on checkout cart order level
*/
class GiftOptions extends Form
{
/**
* Selector for gift message on order form
*
* @var string
*/
protected $giftMessageOrderForm = ".gift-message fieldset";

/**
* Allow gift message on order level
*
* @var string
*/
protected $allowGiftOptions = '.title';

/**
* Selector for apply Gift Message button on item
*
* @var string
*/
protected $giftMessageOrderButton = ".action-update";

/**
* Selector for Gift Message Summary
*
* @var string
*/
protected $giftMessageSummary = ".gift-message-summary";

/**
* Fill gift message form on order level
*
* @param GiftMessage $giftMessage
* @return void
*/
public function fillGiftMessageOrder(GiftMessage $giftMessage)
{
/** @var \Magento\GiftMessage\Test\Block\Cart\GiftOptions\GiftMessageForm $giftMessageForm */
if ($giftMessage->getAllowGiftMessagesForOrder() === 'Yes') {
$this->_rootElement->find($this->allowGiftOptions)->click();
$giftMessageForm = $this->blockFactory->create(
'Magento\GiftMessage\Test\Block\Cart\GiftOptions\GiftMessageForm',
['element' => $this->_rootElement->find($this->giftMessageOrderForm)]
);
$giftMessageForm->fill($giftMessage);
$this->_rootElement->find($this->giftMessageOrderButton)->click();
$this->waitForElementVisible($this->giftMessageSummary);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* See COPYING.txt for license details.
*/

namespace Magento\GiftMessage\Test\Block\Message\Inline;
namespace Magento\GiftMessage\Test\Block\Cart\GiftOptions;

use Magento\Mtf\Block\Form;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
<mapping strict="0">
<fields>
<sender>
<selector>[id^='gift-message'][name$='[from]']</selector>
<selector>[id='gift-message-whole-from']</selector>
</sender>
<recipient>
<selector>[id^='gift-message'][name$='[to]']</selector>
<selector>[id='gift-message-whole-to']</selector>
</recipient>
<message>
<selector>[id^='gift-message'][name$='[message]']</selector>
<selector>[id='gift-message-whole-message']</selector>
</message>
</fields>
</mapping>
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\GiftMessage\Test\Block\Cart\Item;

use Magento\GiftMessage\Test\Fixture\GiftMessage;
use Magento\Mtf\Block\Form;
use Magento\Mtf\Client\Locator;

/**
* Add gift options on checkout cart item level
*/
class GiftOptions extends Form
{
/**
* Selector for gift message on item form
*
* @var string
*/
protected $giftMessageItemForm = '//div[@class="gift-message"]//fieldset[ancestor::tbody[contains(.,"%s")]]';

/**
* Allow Gift Options for items
*
* @var string
*/
protected $allowGiftOptions = '//a[contains(@class,"action-gift")][ancestor::tbody[contains(.,"%s")]]';

/**
* Selector for apply Gift Message button on order
*
* @var string
*/
protected $giftMessageItemButton = ".action-update";

/**
* Selector for Gift Message Summary
*
* @var string
*/
protected $giftMessageSummary = '//div[@class="gift-message-summary"][ancestor::tbody[contains(.,"%s")]]';

/**
* Fill gift message form on item level
*
* @param GiftMessage $giftMessage
* @param array $products
* @return void
*/
public function fillGiftMessageItem(GiftMessage $giftMessage, $products = [])
{
/** @var \Magento\GiftMessage\Test\Block\Cart\GiftOptions\GiftMessageForm $giftMessageForm */
if ($giftMessage->getAllowGiftOptionsForItems() === 'Yes') {
foreach ($products as $product) {
if ($product->getIsVirtual() !== 'Yes') {
$this->_rootElement->find(
sprintf($this->allowGiftOptions, $product->getName()),
Locator::SELECTOR_XPATH
)->click();
$giftMessageForm = $this->blockFactory->create(
'Magento\GiftMessage\Test\Block\Cart\GiftOptions\GiftMessageForm',
[
'element' => $this->_rootElement->find(
sprintf($this->giftMessageItemForm, $product->getName()),
Locator::SELECTOR_XPATH
)
]
);
$giftMessageForm->fill($giftMessage);
$this->_rootElement->find($this->giftMessageItemButton)->click();
$this->waitForElementVisible(
sprintf($this->giftMessageSummary, $product->getName()),
Locator::SELECTOR_XPATH
);
}
}
}
}
}

This file was deleted.

Loading

0 comments on commit d0e08a2

Please sign in to comment.