Skip to content

Commit 6c2838b

Browse files
author
okarpenko
committed
Merge branch 'MAGETWO-38892' of https://github.corp.ebay.com/magento-south/magento2ce into BUGS
2 parents 73343bd + 423cdf3 commit 6c2838b

File tree

12 files changed

+198
-113
lines changed

12 files changed

+198
-113
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\GiftMessage\Test\Block\Cart;
8+
9+
use Magento\GiftMessage\Test\Fixture\GiftMessage;
10+
use Magento\Mtf\Block\Form;
11+
12+
/**
13+
* Class GiftOptions
14+
* Add gift options on checkout cart order level
15+
*/
16+
class GiftOptions extends Form
17+
{
18+
/**
19+
* Selector for gift message on order form
20+
*
21+
* @var string
22+
*/
23+
protected $giftMessageOrderForm = ".gift-message fieldset";
24+
25+
/**
26+
* Allow gift message on order level
27+
*
28+
* @var string
29+
*/
30+
protected $allowGiftOptions = '.title';
31+
32+
/**
33+
* Selector for apply Gift Message button on item
34+
*
35+
* @var string
36+
*/
37+
protected $giftMessageOrderButton = ".action-update";
38+
39+
/**
40+
* Selector for Gift Message Summary
41+
*
42+
* @var string
43+
*/
44+
protected $giftMessageSummary = ".gift-message-summary";
45+
46+
/**
47+
* Fill gift message form on order level
48+
*
49+
* @param GiftMessage $giftMessage
50+
* @return void
51+
*/
52+
public function fillGiftMessageOrder(GiftMessage $giftMessage)
53+
{
54+
/** @var \Magento\GiftMessage\Test\Block\Cart\GiftOptions\GiftMessageForm $giftMessageForm */
55+
if ($giftMessage->getAllowGiftMessagesForOrder() === 'Yes') {
56+
$this->_rootElement->find($this->allowGiftOptions)->click();
57+
$giftMessageForm = $this->blockFactory->create(
58+
'Magento\GiftMessage\Test\Block\Cart\GiftOptions\GiftMessageForm',
59+
['element' => $this->_rootElement->find($this->giftMessageOrderForm)]
60+
);
61+
$giftMessageForm->fill($giftMessage);
62+
$this->_rootElement->find($this->giftMessageOrderButton)->click();
63+
$this->waitForElementVisible($this->giftMessageSummary);
64+
}
65+
}
66+
}

dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Message/Inline/GiftMessageForm.php renamed to dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Cart/GiftOptions/GiftMessageForm.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
namespace Magento\GiftMessage\Test\Block\Message\Inline;
7+
namespace Magento\GiftMessage\Test\Block\Cart\GiftOptions;
88

99
use Magento\Mtf\Block\Form;
1010

dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Message/Inline/GiftMessageForm.xml renamed to dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Cart/GiftOptions/GiftMessageForm.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
<mapping strict="0">
99
<fields>
1010
<sender>
11-
<selector>[id^='gift-message'][name$='[from]']</selector>
11+
<selector>[id='gift-message-whole-from']</selector>
1212
</sender>
1313
<recipient>
14-
<selector>[id^='gift-message'][name$='[to]']</selector>
14+
<selector>[id='gift-message-whole-to']</selector>
1515
</recipient>
1616
<message>
17-
<selector>[id^='gift-message'][name$='[message]']</selector>
17+
<selector>[id='gift-message-whole-message']</selector>
1818
</message>
1919
</fields>
2020
</mapping>
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\GiftMessage\Test\Block\Cart\Item;
8+
9+
use Magento\GiftMessage\Test\Fixture\GiftMessage;
10+
use Magento\Mtf\Block\Form;
11+
use Magento\Mtf\Client\Locator;
12+
13+
/**
14+
* Add gift options on checkout cart item level
15+
*/
16+
class GiftOptions extends Form
17+
{
18+
/**
19+
* Selector for gift message on item form
20+
*
21+
* @var string
22+
*/
23+
protected $giftMessageItemForm = '//div[@class="gift-message"]//fieldset[ancestor::tbody[contains(.,"%s")]]';
24+
25+
/**
26+
* Allow Gift Options for items
27+
*
28+
* @var string
29+
*/
30+
protected $allowGiftOptions = '//a[contains(@class,"action-gift")][ancestor::tbody[contains(.,"%s")]]';
31+
32+
/**
33+
* Selector for apply Gift Message button on order
34+
*
35+
* @var string
36+
*/
37+
protected $giftMessageItemButton = ".action-update";
38+
39+
/**
40+
* Selector for Gift Message Summary
41+
*
42+
* @var string
43+
*/
44+
protected $giftMessageSummary = '//div[@class="gift-message-summary"][ancestor::tbody[contains(.,"%s")]]';
45+
46+
/**
47+
* Fill gift message form on item level
48+
*
49+
* @param GiftMessage $giftMessage
50+
* @param array $products
51+
* @return void
52+
*/
53+
public function fillGiftMessageItem(GiftMessage $giftMessage, $products = [])
54+
{
55+
/** @var \Magento\GiftMessage\Test\Block\Cart\GiftOptions\GiftMessageForm $giftMessageForm */
56+
if ($giftMessage->getAllowGiftOptionsForItems() === 'Yes') {
57+
foreach ($products as $product) {
58+
if ($product->getIsVirtual() !== 'Yes') {
59+
$this->_rootElement->find(
60+
sprintf($this->allowGiftOptions, $product->getName()),
61+
Locator::SELECTOR_XPATH
62+
)->click();
63+
$giftMessageForm = $this->blockFactory->create(
64+
'Magento\GiftMessage\Test\Block\Cart\GiftOptions\GiftMessageForm',
65+
[
66+
'element' => $this->_rootElement->find(
67+
sprintf($this->giftMessageItemForm, $product->getName()),
68+
Locator::SELECTOR_XPATH
69+
)
70+
]
71+
);
72+
$giftMessageForm->fill($giftMessage);
73+
$this->_rootElement->find($this->giftMessageItemButton)->click();
74+
$this->waitForElementVisible(
75+
sprintf($this->giftMessageSummary, $product->getName()),
76+
Locator::SELECTOR_XPATH
77+
);
78+
}
79+
}
80+
}
81+
}
82+
}

dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Message/Inline.php

Lines changed: 0 additions & 87 deletions
This file was deleted.

dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Message/Order/Items/View.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ class View extends Block
5757
*/
5858
public function getGiftMessage($itemName)
5959
{
60+
if (!$this->giftMessageButtonIsVisible($itemName)) {
61+
return [];
62+
}
6063
$message = [];
6164
$labelsToSkip = [];
6265
$this->clickGiftMessageButton($itemName);
@@ -88,4 +91,18 @@ protected function clickGiftMessageButton($itemName)
8891
Locator::SELECTOR_XPATH
8992
)->click();
9093
}
94+
95+
/**
96+
* Click "Gift Message" for special item.
97+
*
98+
* @param string $itemName
99+
* @return bool
100+
*/
101+
protected function giftMessageButtonIsVisible($itemName)
102+
{
103+
return $isVisible = $this->_rootElement->find(
104+
sprintf($this->giftMessageButtonSelector, $itemName),
105+
Locator::SELECTOR_XPATH
106+
)->isVisible();
107+
}
91108
}

dev/tests/functional/tests/app/Magento/GiftMessage/Test/Constraint/AssertGiftMessageInFrontendOrderItems.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ public function processAssert(
6262
'message' => $itemGiftMessage->getMessage(),
6363
];
6464
}
65+
if ($product->getIsVirtual() == 'Yes') {
66+
$expectedData = [];
67+
}
68+
6569
\PHPUnit_Framework_Assert::assertEquals(
6670
$expectedData,
6771
$customerOrderView->getGiftMessageForItemBlock()->getGiftMessage($product->getName()),
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
/**
4+
* Copyright © 2015 Magento. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/pages.xsd">
9+
<page name="CheckoutCart" mca="checkout/cart">
10+
<block name="giftMessagesItemBlock" class="Magento\GiftMessage\Test\Block\Cart\Item\GiftOptions" locator=".gift-options-cart-item" strategy="css selector"/>
11+
<block name="giftMessagesOrderBlock" class="Magento\GiftMessage\Test\Block\Cart\GiftOptions" locator=".cart-gift-item" strategy="css selector"/>
12+
</page>
13+
</config>

dev/tests/functional/tests/app/Magento/GiftMessage/Test/Page/CheckoutOnepage.xml

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)