Skip to content

Commit c7e5f62

Browse files
committed
MTO-134: [Variation] Add Simple Product with required Custom Options to Cart
- Defects fixed
1 parent 4c79517 commit c7e5f62

File tree

5 files changed

+51
-28
lines changed

5 files changed

+51
-28
lines changed

dev/tests/functional/tests/app/Magento/Backend/Test/Block/Messages.php

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,6 @@ class Messages extends Block
2121
*/
2222
protected $successMessage = '[data-ui-id$=message-success]';
2323

24-
/**
25-
* Selector for "This is a required field." validation error message.
26-
*
27-
* @var string
28-
*/
29-
private $validationErrorMessage = '//div[@class="mage-error"][contains(text(), "This is required field")]';
30-
3124
/**
3225
* Last success message selector.
3326
*
@@ -73,18 +66,6 @@ public function waitSuccessMessage()
7366
return $this->waitForElementVisible($this->successMessage, Locator::SELECTOR_CSS);
7467
}
7568

76-
/**
77-
* Wait for success or JS validation error message.
78-
*
79-
* @return bool
80-
*/
81-
public function waitMessage()
82-
{
83-
return $this->_rootElement->find($this->successMessage, Locator::SELECTOR_CSS)->isVisible() ?
84-
$this->waitForElementVisible($this->successMessage, Locator::SELECTOR_CSS) :
85-
$this->waitForElementVisible($this->validationErrorMessage, Locator::SELECTOR_XPATH);
86-
}
87-
8869
/**
8970
* Get all success messages which are present on the page.
9071
*
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Catalog\Test\Block;
8+
9+
use Magento\Mtf\Client\Locator;
10+
11+
/**
12+
* Catalog messages block.
13+
*/
14+
class Messages extends \Magento\Backend\Test\Block\Messages
15+
{
16+
/**
17+
* Selector for "This is a required field." validation error message.
18+
*
19+
* @var string
20+
*/
21+
private $validationErrorMessage = '.mage-error';
22+
23+
/**
24+
* Wait for Success message or JS validation error message.
25+
*
26+
* @param string $strategy
27+
* @return bool
28+
*/
29+
public function waitMessage($strategy = Locator::SELECTOR_CSS)
30+
{
31+
$browser = $this->browser;
32+
$successMessage = $this->successMessage;
33+
$errorMessage = $this->validationErrorMessage;
34+
return $browser->waitUntil(
35+
function () use ($browser, $successMessage, $errorMessage, $strategy) {
36+
$success = $browser->find($successMessage, $strategy);
37+
$error = $browser->find($errorMessage, $strategy);
38+
return $success->isVisible() || $error->isVisible() ? true : null;
39+
}
40+
);
41+
}
42+
}

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View/CustomOptions.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,12 +188,12 @@ protected function getListOptions()
188188
}
189189

190190
/**
191-
* Check that validation error message beside custom option is visible.
191+
* Check option's validation message is visible or not.
192192
*
193193
* @param string $customOptionTitle
194194
* @return bool
195195
*/
196-
public function validationErrorMessageIsVisible($customOptionTitle)
196+
public function isValidationErrorMessageVisible($customOptionTitle)
197197
{
198198
$optionSelector = $this->customOptionField . $this->requiredOption . $this->validationErrorMessage;
199199
$title = sprintf($optionSelector, $customOptionTitle);

dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductCustomOptionsErrors.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
use Magento\Catalog\Test\Page\Product\CatalogProductView;
1111

1212
/**
13-
* Assert that JS validation error message is visible beside every required product option.
13+
* Assert that every required product's Custom Option contains JS validation error.
1414
*/
1515
class AssertProductCustomOptionsErrors extends AbstractConstraint
1616
{
1717
/**
18-
* Assert that JS validation error message is visible beside every required product option.
18+
* Assert that every required product's Custom Option contains JS validation error.
1919
*
2020
* @param CatalogProductView $catalogProductView
2121
* @param array $products
@@ -28,20 +28,20 @@ public function processAssert(
2828
foreach ($products as $product) {
2929
foreach ($product->getData('custom_options') as $option) {
3030
\PHPUnit_Framework_Assert::assertTrue(
31-
$catalogProductView->getCustomOptionsBlock()->validationErrorMessageIsVisible($option['title']),
32-
'JS validation error message is absent after required product option ' . $option['title']
31+
$catalogProductView->getCustomOptionsBlock()->isValidationErrorMessageVisible($option['title']),
32+
'Required Custom Option ' . $option['title'] . " doesn't contain JS validation error."
3333
);
3434
}
3535
}
3636
}
3737

3838
/**
39-
* Assert success message that JS validation error message is visible beside every required product option.
39+
* Assert success message that every required product's Custom Option contains JS validation error.
4040
*
4141
* @return string
4242
*/
4343
public function toString()
4444
{
45-
return 'JS validation error message is visible beside every required product option.';
45+
return "Every required product's Custom Option contains JS validation error.";
4646
}
4747
}

dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Product/CatalogProductView.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<block name="upsellBlock" class="Magento\Catalog\Test\Block\Product\ProductList\Upsell" locator=".block.upsell" strategy="css selector" />
1515
<block name="crosssellBlock" class="Magento\Catalog\Test\Block\Product\ProductList\Crosssell" locator=".block.crosssell" strategy="css selector" />
1616
<block name="downloadableLinksBlock" class="Magento\Downloadable\Test\Block\Catalog\Product\View\Links" locator="[data-container-for=downloadable-links]" strategy="css selector" />
17-
<block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator=".page.messages" strategy="css selector" />
17+
<block name="messagesBlock" class="Magento\Catalog\Test\Block\Messages" locator=".page.messages" strategy="css selector" />
1818
<block name="titleBlock" class="Magento\Theme\Test\Block\Html\Title" locator=".page-title-wrapper h1.page-title .base" strategy="css selector" />
1919
<block name="widgetView" class="Magento\Widget\Test\Block\WidgetView" locator=".column.main .widget" strategy="css selector" />
2020
</page>

0 commit comments

Comments
 (0)