Skip to content

Commit

Permalink
Merge pull request #38 from magento-qmt/develop
Browse files Browse the repository at this point in the history
[Mavericks] Functional test maintenance
  • Loading branch information
Dmytro Aponasenko authored and Dmytro Aponasenko committed Oct 24, 2015
2 parents af32ac1 + e571579 commit 4499554
Show file tree
Hide file tree
Showing 161 changed files with 407 additions and 275 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function flushCacheStorage()
*/
public function isStorageCacheFlushed()
{
return $this->getMessagesBlock()->getSuccessMessages() == $this->messagesText['cache_storage_flushed'];
return $this->getMessagesBlock()->getSuccessMessage() == $this->messagesText['cache_storage_flushed'];
}

/**
Expand All @@ -78,7 +78,7 @@ public function isStorageCacheFlushed()
*/
public function isMagentoCacheFlushed()
{
return $this->getMessagesBlock()->getSuccessMessages() == $this->messagesText['cache_magento_flushed'];
return $this->getMessagesBlock()->getSuccessMessage() == $this->messagesText['cache_magento_flushed'];
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ class Messages extends Block
*/
protected $successMessage = '[data-ui-id$=message-success]';

/**
* Last success message selector.
*
* @var string
*/
protected $lastSuccessMessage = '[data-ui-id$=message-success]:last-child';

/**
* Message link.
*
Expand Down Expand Up @@ -62,7 +69,7 @@ public function waitSuccessMessage()
/**
* Get all success messages which are present on the page.
*
* @return string|array
* @return array
*/
public function getSuccessMessages()
{
Expand All @@ -74,7 +81,19 @@ public function getSuccessMessages()
$messages[] = $element->getText();
}

return count($messages) > 1 ? $messages : $messages[0];
return $messages;
}

/**
* Get last success message which is present on the page.
*
* @return string
*/
public function getSuccessMessage()
{
$this->waitForElementVisible($this->successMessage);

return $this->_rootElement->find($this->lastSuccessMessage)->getText();
}

/**
Expand All @@ -96,25 +115,25 @@ function () use ($browser, $selector, $strategy) {
}

/**
* Get all error messages which are present on the page.
* Get all error message which is present on the page.
*
* @return string
*/
public function getErrorMessages()
public function getErrorMessage()
{
return $this->_rootElement
->find($this->errorMessage, Locator::SELECTOR_CSS)
->getText();
}

/**
* Click on link in the messages which are present on the page.
* Click on link in the message which is present on the page.
*
* @param string $messageType
* @param string $linkText
* @return void
*/
public function clickLinkInMessages($messageType, $linkText)
public function clickLinkInMessage($messageType, $linkText)
{
if ($this->isVisibleMessage($messageType)) {
$this->_rootElement
Expand Down Expand Up @@ -162,7 +181,7 @@ public function assertNoticeMessage()
*
* @return string
*/
public function getNoticeMessages()
public function getNoticeMessage()
{
$this->waitForElementVisible($this->noticeMessage);
return $this->_rootElement->find($this->noticeMessage)->getText();
Expand All @@ -173,7 +192,7 @@ public function getNoticeMessages()
*
* @return string
*/
public function getWarningMessages()
public function getWarningMessage()
{
$this->waitForElementVisible($this->warningMessage);
return $this->_rootElement->find($this->warningMessage)->getText();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ abstract class Grid extends Block
protected $rowPattern = '//tbody/tr[%s]';

/**
* Selector for confirm.
* Selector for confirm.
*
* @var string
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function processAssert(AdminCache $adminCache, $cacheTags)

\PHPUnit_Framework_Assert::assertEquals(
sprintf(self::SUCCESS_MESSAGE, count($items)),
$adminCache->getMessagesBlock()->getSuccessMessages(),
$adminCache->getMessagesBlock()->getSuccessMessage(),
'Cache is Invalid and refreshable.'
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function processAssert(AdminCache $adminCache, $successMessage)
{
\PHPUnit_Framework_Assert::assertEquals(
$successMessage,
$adminCache->getMessagesBlock()->getSuccessMessages(),
$adminCache->getMessagesBlock()->getSuccessMessage(),
'Action is not successful.'
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class CategoryForm extends FormTabs
protected $dropdownBlock = '.dropdown';

/**
* Selector for confirm.
* Selector for confirm.
*
* @var string
*/
Expand All @@ -51,9 +51,9 @@ public function fill(FixtureInterface $fixture, SimpleElement $element = null)
$store = $fixture->getStoreId();
$storeSwitcherBlock = $this->browser->find($this->storeSwitcherBlock);
$storeSwitcherBlock->find($this->dropdownBlock, Locator::SELECTOR_CSS, 'liselectstore')->setValue($store);
$element = $this->browser->find($this->confirmModal);
$modalElement = $this->browser->find($this->confirmModal);
/** @var \Magento\Ui\Test\Block\Adminhtml\Modal $modal */
$modal = $this->blockFactory->create('Magento\Ui\Test\Block\Adminhtml\Modal', ['element' => $element]);
$modal = $this->blockFactory->create('Magento\Ui\Test\Block\Adminhtml\Modal', ['element' => $modalElement]);
$modal->acceptAlert();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class CustomAttribute extends SimpleElement
*
* @var string
*/
protected $inputSelector = '.control [data-ui-id][name]';
protected $inputSelector = '.control [name]:not([type="hidden"]), table';

/**
* Attribute class to element type reference.
Expand All @@ -45,7 +45,9 @@ public function setValue($data)
$this->eventManager->dispatchEvent(['set_value'], [__METHOD__, $this->getAbsoluteSelector()]);
$element = $this->getElementByClass($this->getElementClass());
$value = is_array($data) ? $data['value'] : $data;
$this->find($this->inputSelector, Locator::SELECTOR_CSS, $element)->setValue($value);
if ($value !== null) {
$this->find($this->inputSelector, Locator::SELECTOR_CSS, $element)->setValue($value);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use Magento\Mtf\Client\Locator;
use Magento\Backend\Test\Block\Widget\Tab;
use Magento\Catalog\Test\Block\Adminhtml\Product\Attribute\Edit;
use Magento\Catalog\Test\Fixture\CatalogProductAttribute;

/**
* General class for tabs on product FormTabs with "Add attribute" button.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
namespace Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\ProductDetails;

use Magento\Mtf\Client\Element\SuggestElement;
use Magento\Mtf\Client\Locator;

/**
* Class AttributeSet
Expand Down Expand Up @@ -35,6 +36,13 @@ class AttributeSet extends SuggestElement
*/
protected $loader = '[data-role="loader"]';

/**
* Page header selector.
*
* @var string
*/
protected $header = 'header';

/**
* Set value
*
Expand All @@ -44,8 +52,27 @@ class AttributeSet extends SuggestElement
public function setValue($value)
{
if ($value !== $this->find($this->actionToggle)->getText()) {
$this->eventManager->dispatchEvent(['set_value'], [__METHOD__, $this->getAbsoluteSelector()]);
$this->find($this->actionToggle)->click();
parent::setValue($value);
$this->clear();
if ($value == '') {
return;
}
foreach (str_split($value) as $symbol) {
$this->keys([$symbol]);
$searchedItem = $this->find(sprintf($this->resultItem, $value), Locator::SELECTOR_XPATH);
if ($searchedItem->isVisible()) {
try {
$searchedItem->hover();
$this->driver->find($this->header)->hover();
$searchedItem->click();
break;
} catch (\Exception $e) {
// In parallel run on windows change the focus is lost on element
// that causes disappearing of category suggest list.
}
}
}
}
// Wait loader
$element = $this->driver;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ class CustomOptions extends Form
*
* @var string
*/
protected $optionElement = '#product-options-wrapper .field';
protected $optionElement = '#product-options-wrapper > * > .field';

/**
* Selector for title of option
*
* @var string
*/
protected $title = 'label';
protected $title = 'label > span:nth-child(1), legend > span:nth-child(1)';

/**
* Selector for required option
Expand Down Expand Up @@ -381,7 +381,7 @@ protected function getOptionNotice(SimpleElement $option, $number)
*/
protected function parseOptionText($optionText)
{
preg_match('`^(.*?)\+\$(\d.*?)$`', $optionText, $match);
preg_match('`^(.*?) \+ ?\$([\d\.,]*?)$`', $optionText, $match);
$optionPrice = isset($match[2]) ? str_replace(',', '', $match[2]) : 0;
$optionTitle = isset($match[1]) ? trim($match[1]) : $optionText;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class AssertAttributeSetSuccessDeleteMessage extends AbstractConstraint
*/
public function processAssert(CatalogProductSetIndex $productSetIndex)
{
$actualMessage = $productSetIndex->getMessagesBlock()->getSuccessMessages();
$actualMessage = $productSetIndex->getMessagesBlock()->getSuccessMessage();
\PHPUnit_Framework_Assert::assertEquals(
self::SUCCESS_DELETE_MESSAGE,
$actualMessage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class AssertAttributeSetSuccessSaveMessage extends AbstractConstraint
*/
public function processAssert(CatalogProductSetIndex $productSetIndex)
{
$actualMessage = $productSetIndex->getMessagesBlock()->getSuccessMessages();
$actualMessage = $productSetIndex->getMessagesBlock()->getSuccessMessage();
\PHPUnit_Framework_Assert::assertEquals(
self::SUCCESS_MESSAGE,
$actualMessage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class AssertCategorySaveMessage extends AbstractConstraint
*/
public function processAssert(CatalogCategoryEdit $catalogCategoryEdit)
{
$actualMessage = $catalogCategoryEdit->getMessagesBlock()->getSuccessMessages();
$actualMessage = $catalogCategoryEdit->getMessagesBlock()->getSuccessMessage();
\PHPUnit_Framework_Assert::assertEquals(
self::SUCCESS_MESSAGE,
$actualMessage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class AssertCategorySuccessDeleteMessage extends AbstractConstraint
*/
public function processAssert(CatalogCategoryEdit $categoryEdit)
{
$actualMessage = $categoryEdit->getMessagesBlock()->getSuccessMessages();
$actualMessage = $categoryEdit->getMessagesBlock()->getSuccessMessage();
\PHPUnit_Framework_Assert::assertEquals(
self::SUCCESS_DELETE_MESSAGE,
$actualMessage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function processAssert(CatalogProductIndex $productGrid, $products = [])
{
$countProducts = count($products) ? count($products) : 1;
$expectedMessage = sprintf(self::SUCCESS_MESSAGE, $countProducts);
$actualMessage = $productGrid->getMessagesBlock()->getSuccessMessages();
$actualMessage = $productGrid->getMessagesBlock()->getSuccessMessage();
\PHPUnit_Framework_Assert::assertEquals(
$expectedMessage,
$actualMessage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
*/
class AssertProductAttributeSaveMessage extends AbstractConstraint
{
/**
* Product attribute success save message.
*/
const SUCCESS_MESSAGE = 'You saved the product attribute.';

/**
Expand All @@ -24,12 +27,13 @@ class AssertProductAttributeSaveMessage extends AbstractConstraint
*/
public function processAssert(CatalogProductAttributeIndex $attributeIndex)
{
$actualMessage = $attributeIndex->getMessagesBlock()->getSuccessMessage();
\PHPUnit_Framework_Assert::assertEquals(
self::SUCCESS_MESSAGE,
$attributeIndex->getMessagesBlock()->getSuccessMessages(),
$actualMessage,
'Wrong success message is displayed.'
. "\nExpected: " . self::SUCCESS_MESSAGE
. "\nActual: " . $attributeIndex->getMessagesBlock()->getSuccessMessages()
. "\nActual: " . $actualMessage
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ class AssertProductAttributeSuccessDeleteMessage extends AbstractConstraint
*/
public function processAssert(CatalogProductAttributeIndex $attributeIndex)
{
$actualMessage = $attributeIndex->getMessagesBlock()->getSuccessMessage();
\PHPUnit_Framework_Assert::assertEquals(
self::SUCCESS_MESSAGE,
$attributeIndex->getMessagesBlock()->getSuccessMessages(),
$actualMessage,
'Wrong success message is displayed.'
. "\nExpected: " . self::SUCCESS_MESSAGE
. "\nActual: " . $attributeIndex->getMessagesBlock()->getSuccessMessages()
. "\nActual: " . $actualMessage
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class AssertProductCompareSuccessAddMessage extends AbstractConstraint
public function processAssert(CatalogProductView $catalogProductView, FixtureInterface $product)
{
$successMessage = sprintf(self::SUCCESS_MESSAGE, $product->getName());
$actualMessage = $catalogProductView->getMessagesBlock()->getSuccessMessages();
$actualMessage = $catalogProductView->getMessagesBlock()->getSuccessMessage();
\PHPUnit_Framework_Assert::assertEquals(
$successMessage,
$actualMessage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class AssertProductCompareSuccessRemoveAllProductsMessage extends AbstractConstr
*/
public function processAssert(CatalogProductView $catalogProductView)
{
$actualMessage = $catalogProductView->getMessagesBlock()->getSuccessMessages();
$actualMessage = $catalogProductView->getMessagesBlock()->getSuccessMessage();
\PHPUnit_Framework_Assert::assertEquals(
self::SUCCESS_MESSAGE,
$actualMessage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class AssertProductCompareSuccessRemoveMessage extends AbstractConstraint
public function processAssert(CatalogProductCompare $catalogProductCompare, FixtureInterface $product)
{
$successMessage = sprintf(self::SUCCESS_MESSAGE, $product->getName());
$actualMessage = $catalogProductCompare->getMessagesBlock()->getSuccessMessages();
$actualMessage = $catalogProductCompare->getMessagesBlock()->getSuccessMessage();
\PHPUnit_Framework_Assert::assertEquals($successMessage, $actualMessage, 'Wrong success message is displayed.');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class AssertProductDuplicateMessage extends AbstractConstraint
public function processAssert(CatalogProductEdit $productPage)
{
$actualMessages = $productPage->getMessagesBlock()->getSuccessMessages();
$actualMessages = is_array($actualMessages) ? $actualMessages : [$actualMessages];
\PHPUnit_Framework_Assert::assertContains(
self::DUPLICATE_MESSAGE,
$actualMessages,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class AssertProductSaveMessage extends AbstractConstraint
public function processAssert(CatalogProductEdit $productPage)
{
$actualMessages = $productPage->getMessagesBlock()->getSuccessMessages();
$actualMessages = is_array($actualMessages) ? $actualMessages : [$actualMessages];
\PHPUnit_Framework_Assert::assertContains(
self::SUCCESS_MESSAGE,
$actualMessages,
Expand Down
Loading

0 comments on commit 4499554

Please sign in to comment.