Skip to content

Commit 85e856e

Browse files
committed
MC-5274: Create product that visible only in search and check min/max qty allowed in the shopping cart
1 parent 4c55aa1 commit 85e856e

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,13 @@ class View extends AbstractConfigureBlock
220220
*/
221221
private $thresholdMessage = '.availability.only';
222222

223+
/**
224+
* Qty field error message selector.
225+
*
226+
* @var string
227+
*/
228+
private $qtyErrorMessage = '#qty-error';
229+
223230
/**
224231
* Checks if threshold message is displayed.
225232
*
@@ -677,4 +684,16 @@ public function checkVideoDataPresence($videoData)
677684
$dataVideoSelector = $this->productVideo . '[data-code="' . $videoData. '"]';
678685
return $this->_rootElement->find($dataVideoSelector)->isPresent();
679686
}
687+
688+
/**
689+
* Resolve qty field error message.
690+
*
691+
* @return string
692+
*/
693+
public function getQtyErrorMessage()
694+
{
695+
$this->waitForElementVisible($this->qtyErrorMessage);
696+
697+
return $this->_rootElement->find($this->qtyErrorMessage)->getText();
698+
}
680699
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class AssertProductInventoryMaxAllowedQty extends AbstractConstraint
2222
*
2323
* @var string
2424
*/
25-
private $errorMessage = 'The most you may purchase is %s.';
25+
private $errorMessage = 'The maximum you may purchase is %s.';
2626

2727
/**
2828
* Check if max qty setting is working correctly.
@@ -48,8 +48,8 @@ public function processAssert(
4848
$catalogProductView->getViewBlock()->waitLoader();
4949
$catalogProductView->getViewBlock()->setQtyAndClickAddToCart($maxQty * 2);
5050
\PHPUnit\Framework\Assert::assertEquals(
51-
$catalogProductView->getMessagesBlock()->getErrorMessage(),
5251
sprintf($this->errorMessage, $maxQty),
52+
$catalogProductView->getViewBlock()->getQtyErrorMessage(),
5353
'The maximum purchase warning message is not appears.'
5454
);
5555

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ public function processAssert(
4848
$catalogProductView->getViewBlock()->waitLoader();
4949
$catalogProductView->getViewBlock()->setQtyAndClickAddToCart(1);
5050
\PHPUnit\Framework\Assert::assertEquals(
51-
$catalogProductView->getMessagesBlock()->getErrorMessage(),
5251
sprintf($this->errorMessage, $minQty),
52+
$catalogProductView->getViewBlock()->getQtyErrorMessage(),
5353
'The minimum purchase warning message is not appears.'
5454
);
5555

0 commit comments

Comments
 (0)