Skip to content

Commit

Permalink
MTA-2211: Deliver functional tests fixes which were made during regre…
Browse files Browse the repository at this point in the history
…ssion
  • Loading branch information
Oleksii Kolesnyk committed May 29, 2015
1 parent ea7b254 commit 9cbb323
Show file tree
Hide file tree
Showing 74 changed files with 324 additions and 272 deletions.
5 changes: 0 additions & 5 deletions dev/tests/functional/.gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
**/var
/composer.lock
/config/*
/generated
/lib/Magento/Mtf/Util/Generate/testcase.xml
/vendor
!/config/application.yml.dist
!/config/handler.yml.dist
!/config/isolation.yml.dist
!/config/server.yml.dist
phpunit.xml
credentials.xml
2 changes: 1 addition & 1 deletion dev/tests/functional/composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"require": {
"magento/mtf": "1.0.0-rc25",
"magento/mtf": "1.0.0-rc26",
"php": "~5.5.0|~5.6.0",
"phpunit/phpunit": "4.1.0",
"phpunit/phpunit-selenium": ">=1.2",
Expand Down
2 changes: 1 addition & 1 deletion dev/tests/functional/phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<env name="testsuite_rule_path" value="Magento/Mtf/TestSuite/InjectableTests" />
<env name="log_directory" value="var/log" />
<env name="events_preset" value="base" />
<env name="module_whitelist" value="Magento_Install,Magento_Core" />
<env name="module_whitelist" value="Magento_Install" />
<env name="basedir" value="var/log" />
<env name="credentials_file_path" value="./credentials.xml.dist" />
</php>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ public function getSuccessMessages()
$elements = $this->_rootElement->getElements($this->successMessage);

$messages = [];
foreach ($elements as $key => $element) {
$messages[$key] = $element->getText();
foreach ($elements as $element) {
$messages[] = $element->getText();
}

return count($messages) > 1 ? $messages : $messages[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Magento\Mtf\Block\BlockFactory;
use Magento\Mtf\Block\Mapper;
use Magento\Mtf\Client\Locator;
use Magento\Mtf\Client\ElementInterface;
use Magento\Mtf\Fixture\FixtureInterface;
use Magento\Mtf\Fixture\InjectableFixture;
use Magento\Mtf\Client\BrowserInterface;
Expand Down Expand Up @@ -84,10 +85,10 @@ protected function fillTabs(array $tabs, SimpleElement $element = null)
{
$context = ($element === null) ? $this->_rootElement : $element;
foreach ($tabs as $tabName => $tabFields) {
$tabElement = $this->getTabElement($tabName);
$tab = $this->getTab($tabName);
$this->openTab($tabName);
$tabElement->fillFormTab(array_merge($tabFields, $this->unassignedFields), $context);
$this->updateUnassignedFields($tabElement);
$tab->fillFormTab(array_merge($tabFields, $this->unassignedFields), $context);
$this->updateUnassignedFields($tab);
}
if (!empty($this->unassignedFields)) {
$this->fillMissedFields($tabs);
Expand All @@ -99,13 +100,13 @@ protected function fillTabs(array $tabs, SimpleElement $element = null)
/**
* Update array with fields which aren't assigned to any tab
*
* @param Tab $tabElement
* @param Tab $tab
*/
protected function updateUnassignedFields(Tab $tabElement)
protected function updateUnassignedFields(Tab $tab)
{
$this->unassignedFields = array_diff_key(
$this->unassignedFields,
array_intersect_key($this->unassignedFields, $tabElement->setFields)
array_intersect_key($this->unassignedFields, $tab->setFields)
);
}

Expand All @@ -120,10 +121,10 @@ protected function updateUnassignedFields(Tab $tabElement)
protected function fillMissedFields(array $tabs)
{
foreach (array_diff_key($this->tabs, $tabs) as $tabName => $tabData) {
$tabElement = $this->getTabElement($tabName);
$tab = $this->getTab($tabName);
if ($this->openTab($tabName)) {
$tabElement->fillFormTab($this->unassignedFields, $this->_rootElement);
$this->updateUnassignedFields($tabElement);
$tab->fillFormTab($this->unassignedFields, $this->_rootElement);
$this->updateUnassignedFields($tab);
if (empty($this->unassignedFields)) {
break;
}
Expand Down Expand Up @@ -154,15 +155,15 @@ public function getData(FixtureInterface $fixture = null, SimpleElement $element
if (null === $fixture) {
foreach ($this->tabs as $tabName => $tab) {
$this->openTab($tabName);
$tabData = $this->getTabElement($tabName)->getDataFormTab();
$tabData = $this->getTab($tabName)->getDataFormTab();
$data = array_merge($data, $tabData);
}
} else {
$isHasData = ($fixture instanceof InjectableFixture) ? $fixture->hasData() : true;
$tabsFields = $isHasData ? $this->getFieldsByTabs($fixture) : [];
foreach ($tabsFields as $tabName => $fields) {
$this->openTab($tabName);
$tabData = $this->getTabElement($tabName)->getDataFormTab($fields, $this->_rootElement);
$tabData = $this->getTab($tabName)->getDataFormTab($fields, $this->_rootElement);
$data = array_merge($data, $tabData);
}
}
Expand Down Expand Up @@ -249,41 +250,61 @@ private function getFixtureFieldsByTabsDeprecated(FixtureInterface $fixture)
}

/**
* Get tab element
* Get tab class.
*
* @param string $tabName
* @return Tab
* @throws \Exception
*/
public function getTabElement($tabName)
public function getTab($tabName)
{
$tabClass = $this->tabs[$tabName]['class'];
/** @var Tab $tabElement */
$tabElement = $this->blockFactory->create($tabClass, ['element' => $this->_rootElement]);
if (!$tabElement instanceof Tab) {
/** @var Tab $tab */
$tab = $this->blockFactory->create($tabClass, ['element' => $this->_rootElement]);
if (!$tab instanceof Tab) {
throw new \Exception('Wrong Tab Class.');
}
$tabElement->setWrapper(isset($this->tabs[$tabName]['wrapper']) ? $this->tabs[$tabName]['wrapper'] : '');
$tabElement->setMapping(isset($this->tabs[$tabName]['fields']) ? (array)$this->tabs[$tabName]['fields'] : []);
$tab->setWrapper(isset($this->tabs[$tabName]['wrapper']) ? $this->tabs[$tabName]['wrapper'] : '');
$tab->setMapping(isset($this->tabs[$tabName]['fields']) ? (array)$this->tabs[$tabName]['fields'] : []);

return $tabElement;
return $tab;
}

/**
* Open tab
* Get tab element.
*
* @param string $tabName
* @return FormTabs
* @return ElementInterface
*/
public function openTab($tabName)
protected function getTabElement($tabName)
{
$selector = $this->tabs[$tabName]['selector'];
$strategy = isset($this->tabs[$tabName]['strategy'])
? $this->tabs[$tabName]['strategy']
: Locator::SELECTOR_CSS;
$tab = $this->_rootElement->find($selector, $strategy);
$tab->click();
return $this->_rootElement->find($selector, $strategy);
}

/**
* Open tab.
*
* @param string $tabName
* @return FormTabs
*/
public function openTab($tabName)
{
$this->getTabElement($tabName)->click();
return $this;
}

/**
* Check whether tab is visible.
*
* @param string $tabName
* @return bool
*/
public function isTabVisible($tabName)
{
return $this->getTabElement($tabName)->isVisible();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ protected function getTemplateBlock()
* @param array $filters
* @throws \Exception
*/
private function prepareForSearch(array $filters)
protected function prepareForSearch(array $filters)
{
foreach ($filters as $key => $value) {
if (isset($this->filters[$key])) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function processAssert(OrderInjectable $order, Dashboard $dashboard)
$dashboard->open();
$dashboard->getStoreStatsBlock()->refreshData();
/** @var \Magento\Backend\Test\Block\Dashboard\Tab\Products\Ordered $bestsellersGrid */
$bestsellersGrid = $dashboard->getStoreStatsBlock()->getTabElement('bestsellers')->getBestsellersGrid();
$bestsellersGrid = $dashboard->getStoreStatsBlock()->getTab('bestsellers')->getBestsellersGrid();
$products = $order->getEntityId()['products'];
foreach ($products as $product) {
\PHPUnit_Framework_Assert::assertTrue(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use Magento\Backend\Test\Block\Widget\FormTabs;
use Magento\Mtf\Client\Element\SimpleElement;
use Magento\Mtf\Client\Element;
use Magento\Mtf\Client\Locator;
use Magento\Mtf\Fixture\FixtureInterface;
use Magento\Mtf\Fixture\InjectableFixture;

Expand Down Expand Up @@ -60,7 +59,7 @@ public function getData(FixtureInterface $fixture = null, SimpleElement $element
if ($this->isTabVisible($tabName)) {
$this->openTab($tabName);
$this->expandAllToggles();
$tabData = $this->getTabElement($tabName)->getDataFormTab();
$tabData = $this->getTab($tabName)->getDataFormTab();
$data = array_merge($data, $tabData);
}
}
Expand All @@ -71,7 +70,7 @@ public function getData(FixtureInterface $fixture = null, SimpleElement $element
if ($this->isTabVisible($tabName)) {
$this->openTab($tabName);
$this->expandAllToggles();
$tabData = $this->getTabElement($tabName)->getDataFormTab($fields, $this->_rootElement);
$tabData = $this->getTab($tabName)->getDataFormTab($fields, $this->_rootElement);
$data = array_merge($data, $tabData);
}
}
Expand Down Expand Up @@ -104,19 +103,4 @@ public function openTab($tabName)
$this->browser->find($this->pageTitle)->click(); // Handle menu overlap problem
return parent::openTab($tabName);
}

/**
* Check if tab is visible.
*
* @param string $tabName
* @return bool
*/
protected function isTabVisible($tabName)
{
$selector = $this->tabs[$tabName]['selector'];
$strategy = isset($this->tabs[$tabName]['strategy'])
? $this->tabs[$tabName]['strategy']
: Locator::SELECTOR_CSS;
return $this->_rootElement->find($selector, $strategy)->isVisible();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ class Configure extends AbstractConfigureBlock
*/
protected $customOptionsSelector = '#product_composite_configure_fields_options';

/**
* Product quantity selector.
*
* @var string
*/
protected $qty = '[name="qty"]';

/**
* Selector for "Ok" button.
*
Expand All @@ -53,7 +60,7 @@ class Configure extends AbstractConfigureBlock
*/
public function setQty($qty)
{
$this->_fill($this->dataMapping(['qty' => $qty]));
$this->_rootElement->find($this->qty)->setValue($qty);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ProductOnlineSwitcher extends SimpleElement
*
* @var string
*/
protected $topPage = './ancestor::body//*[@class="page-main-actions"]';
protected $topPage = './ancestor::body//*[contains(@class,"page-header")]';

/**
* Set value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ public function fill(FixtureInterface $product, SimpleElement $element = null, F
if ($category) {
$tabs['product-details']['category_ids']['value'] = $category->getName();
}
$this->showAdvancedSettings();
$this->fillTabs($tabs, $element);

if ($product->hasData('custom_attribute')) {
Expand Down Expand Up @@ -168,7 +167,9 @@ public function getData(FixtureInterface $fixture = null, SimpleElement $element
*/
public function openTab($tabName)
{
$this->showAdvancedSettings();
if (!$this->isTabVisible($tabName)) {
$this->showAdvancedSettings();
}
return parent::openTab($tabName);
}

Expand Down Expand Up @@ -255,12 +256,12 @@ public function checkAttributeInSearchAttributeForm(CatalogProductAttribute $pro
}

/**
* Check tab visibility on Product form.
* Check custom tab visibility on Product form.
*
* @param string $tabName
* @return bool
*/
public function isTabVisible($tabName)
public function isCustomTabVisible($tabName)
{
$tabName = strtolower($tabName);
$selector = sprintf($this->customTab, $tabName);
Expand Down Expand Up @@ -294,7 +295,7 @@ public function getRequireNoticeAttributes(InjectableFixture $product)
$data = [];
$tabs = $this->getFieldsByTabs($product);
foreach ($tabs as $tabName => $fields) {
$tab = $this->getTabElement($tabName);
$tab = $this->getTab($tabName);
$this->openTab($tabName);
$errors = $tab->getJsErrors();
if (!empty($errors)) {
Expand Down Expand Up @@ -367,7 +368,7 @@ public function getAttributeElement(CatalogProductAttribute $attribute)
*/
public function addNewAttribute($tabName = 'product-details')
{
$tab = $this->getTabElement($tabName);
$tab = $this->getTab($tabName);
if ($tab instanceof ProductTab) {
$this->openTab($tabName);
$tab->addNewAttribute($tabName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function processAssert(
$productBlockForm->fill($productSimple);

\PHPUnit_Framework_Assert::assertTrue(
$productEdit->getProductForm()->isTabVisible($attributeSet->getGroup()),
$productEdit->getProductForm()->isCustomTabVisible($attributeSet->getGroup()),
"Product Group is absent on Product form tabs."
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/pages.xsd">
<page name="CatalogProductCompare" area="Product" mca="catalog/product_compare/index" module="Magento_Catalog">
<block name="compareProductsBlock" class="Magento\Catalog\Test\Block\Product\Compare\ListCompare" locator=".column.main" strategy="css selector"/>
<block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator=".page.messages .messages" strategy="css selector"/>
<block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator=".page.messages" strategy="css selector"/>
<block name="widgetView" class="Magento\Widget\Test\Block\WidgetView" locator=".column.main .widget" strategy="css selector"/>
</page>
</config>
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<block name="upsellBlock" class="Magento\Catalog\Test\Block\Product\ProductList\Upsell" locator=".block.upsell" strategy="css selector" />
<block name="crosssellBlock" class="Magento\Catalog\Test\Block\Product\ProductList\Crosssell" locator=".block.crosssell" strategy="css selector" />
<block name="downloadableLinksBlock" class="Magento\Downloadable\Test\Block\Catalog\Product\View\Links" locator="[data-container-for=downloadable-links]" strategy="css selector" />
<block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator=".page.messages .messages" strategy="css selector" />
<block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator=".page.messages" strategy="css selector" />
<block name="titleBlock" class="Magento\Theme\Test\Block\Html\Title" locator=".page-title-wrapper h1.page-title .base" strategy="css selector" />
<block name="widgetView" class="Magento\Widget\Test\Block\WidgetView" locator=".column.main .widget" strategy="css selector" />
</page>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ public function __inject(
*/
public function test(CatalogProductSimple $initialProduct, CatalogProductSimple $product, $configData)
{
$this->markTestIncomplete('Bug: MAGETWO-37154');
$this->configData = $configData;

// Preconditions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ protected function deleteAttributes()
{
$this->catalogProductEdit->getProductForm()->openTab('variations');
/** @var Config $variationsTab */
$variationsTab = $this->catalogProductEdit->getProductForm()->getTabElement('variations');
$variationsTab = $this->catalogProductEdit->getProductForm()->getTab('variations');
$variationsTab->deleteAttributes();
}

Expand All @@ -142,7 +142,7 @@ protected function clearDownloadableData()
{
$this->catalogProductEdit->getProductForm()->openTab('downloadable_information');
/** @var Downloadable $downloadableInfoTab */
$downloadableInfoTab = $this->catalogProductEdit->getProductForm()->getTabElement('downloadable_information');
$downloadableInfoTab = $this->catalogProductEdit->getProductForm()->getTab('downloadable_information');
$downloadableInfoTab->getDownloadableBlock('Links')->clearDownloadableData();
}
}
Loading

0 comments on commit 9cbb323

Please sign in to comment.