Skip to content

Commit

Permalink
Merge pull request #311 from magento-qmt/develop
Browse files Browse the repository at this point in the history
[Mavericks] Re-factor and maintain functional tests
  • Loading branch information
Aponasenko, Dmytro(daponasenko) committed May 19, 2015
2 parents c6b58c4 + f1e1211 commit 649b03a
Show file tree
Hide file tree
Showing 114 changed files with 1,952 additions and 904 deletions.
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-rc24",
"magento/mtf": "1.0.0-rc25",
"php": "~5.5.0|~5.6.0",
"phpunit/phpunit": "4.1.0",
"phpunit/phpunit-selenium": ">=1.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@
*/
class OptgroupselectElement extends SelectElement
{
/**
* Option locator.
*
* @var string
*/
protected $optionByIndex = './/option';

/**
* Option group selector.
*
Expand All @@ -44,14 +37,7 @@ public function getValue()
{
$this->eventManager->dispatchEvent(['get_value'], [(string)$this->getAbsoluteSelector()]);

$selectedLabel = '';
$labels = $this->getElements($this->optionByIndex, Locator::SELECTOR_XPATH);
foreach ($labels as $label) {
if ($label->isSelected()) {
$selectedLabel = $label->getText();
break;
}
}
$selectedLabel = parent::getValue();
if ($selectedLabel == '') {
throw new \Exception('Selected value has not been found in optgroup select.');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@
*/
class SelectstoreElement extends SelectElement
{
/**
* Option locator
*
* @var string
*/
protected $optionByIndex = './/optgroup/option[%d]';

/**
* Store option group selector.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ public function getTabElement($tabName)
* Open tab
*
* @param string $tabName
* @return Tab
* @return FormTabs
*/
public function openTab($tabName)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,14 @@ abstract class Grid extends Block
*
* @var string
*/
protected $actionNextPage = '.pager .action-next';
protected $actionNextPage = '[class*=data-grid-pager] .action-next';

/**
* Locator for disabled next page action
*
* @var string
*/
protected $actionNextPageDisabled = '.pager .action-next.disabled';
protected $actionNextPageDisabled = '[class*=data-grid-pager] .action-next.disabled';

/**
* First row selector
Expand All @@ -188,6 +188,13 @@ abstract class Grid extends Block
*/
protected $firstRowSelector = '';

/**
* Selector for no records row.
*
* @var string
*/
protected $noRecords = '[data-role="row"] .empty-text';

/**
* Get backend abstract block
*
Expand Down Expand Up @@ -328,6 +335,9 @@ public function resetFilter()
*/
public function massaction(array $items, $action, $acceptAlert = false, $massActionSelection = '')
{
if ($this->_rootElement->find($this->noRecords)->isVisible()) {
return;
}
if (!is_array($action)) {
$action = [$action => '-'];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/Magento/Mtf/Repository/etc/repository.xsd">
<repository class="Magento\Config\Test\Repository\ConfigData">
<dataset name="store_information">
<dataset name="store_information_US">
<field name="general/store_information/name" xsi:type="array">
<item name="scope" xsi:type="string">general</item>
<item name="scope_id" xsi:type="number">1</item>
Expand Down Expand Up @@ -58,6 +58,57 @@
</field>
</dataset>

<dataset name="store_information_DE_with_VAT">
<field name="general/store_information/name" xsi:type="array">
<item name="scope" xsi:type="string">general</item>
<item name="scope_id" xsi:type="number">1</item>
<item name="label" xsi:type="string"/>
<item name="value" xsi:type="string">DE Store</item>
</field>
<field name="general/store_information/phone" xsi:type="array">
<item name="scope" xsi:type="string">general</item>
<item name="scope_id" xsi:type="number">1</item>
<item name="label" xsi:type="string"/>
<item name="value" xsi:type="string">630-371-7008</item>
</field>
<field name="general/store_information/country_id" xsi:type="array">
<item name="scope" xsi:type="string">general</item>
<item name="scope_id" xsi:type="number">1</item>
<item name="label" xsi:type="string">Germany</item>
<item name="value" xsi:type="string">DE</item>
</field>
<field name="general/store_information/region_id" xsi:type="array">
<item name="scope" xsi:type="string">general</item>
<item name="scope_id" xsi:type="number">1</item>
<item name="label" xsi:type="string">Berlin</item>
<item name="value" xsi:type="number">82</item>
</field>
<field name="general/store_information/postcode" xsi:type="array">
<item name="scope" xsi:type="string">general</item>
<item name="scope_id" xsi:type="number">1</item>
<item name="label" xsi:type="string"/>
<item name="value" xsi:type="number">10789</item>
</field>
<field name="general/store_information/city" xsi:type="array">
<item name="scope" xsi:type="string">general</item>
<item name="scope_id" xsi:type="number">1</item>
<item name="label" xsi:type="string"/>
<item name="value" xsi:type="string">Berlin</item>
</field>
<field name="general/store_information/street_line1" xsi:type="array">
<item name="scope" xsi:type="string">general</item>
<item name="scope_id" xsi:type="number">1</item>
<item name="label" xsi:type="string"/>
<item name="value" xsi:type="string">Augsburger Strabe 41</item>
</field>
<field name="general/store_information/merchant_vat_number" xsi:type="array">
<item name="scope" xsi:type="string">general</item>
<item name="scope_id" xsi:type="number">1</item>
<item name="label" xsi:type="string"/>
<item name="value" xsi:type="string">111607872</item>
</field>
</dataset>

<dataset name="admin_session_lifetime_1_hour">
<field name="admin/security/session_lifetime" xsi:type="array">
<item name="scope" xsi:type="string">default</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Option extends Form
*
* @var string
*/
protected $removeSelection = 'button.delete';
protected $removeSelection = '.col-actions .action-delete';

/**
* Get grid for assigning products for bundle option
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/variations.xsd">
<testCase name="Magento\Catalog\Test\TestCase\Product\ValidateOrderOfProductTypeTest">
<variation name="ValidateOrderOfProductTypeTestVariation1">
<data name="menu/4" xsi:type="string">Bundle Product</data>
</variation>
</testCase>
</config>
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,40 @@
use Magento\Catalog\Test\Block\AbstractConfigureBlock;

/**
* Class Configure
* Adminhtml catalog product composite configure block
* Adminhtml catalog product composite configure block.
*/
class Configure extends AbstractConfigureBlock
{
/**
* Custom options CSS selector
* Configure form selector.
*
* @var string
*/
protected $configureForm = '#product_composite_configure_form';

/**
* Custom options CSS selector.
*
* @var string
*/
protected $customOptionsSelector = '#product_composite_configure_fields_options';

/**
* Selector for "Ok" button
* Selector for "Ok" button.
*
* @var string
*/
protected $okButton = '.ui-button.action-primary';

/**
* Backend abstract block
* Backend abstract block.
*
* @var string
*/
protected $templateBlock = './ancestor::body';

/**
* Set quantity
* Set quantity.
*
* @param int $qty
* @return void
Expand All @@ -51,7 +57,7 @@ public function setQty($qty)
}

/**
* Fill in the option specified for the product
* Fill in the option specified for the product.
*
* @param FixtureInterface $product
* @return void
Expand All @@ -61,15 +67,17 @@ public function configProduct(FixtureInterface $product)
/** @var CatalogProductSimple $product */
$checkoutData = $product->getCheckoutData();

$this->waitForFormVisible();
$this->fillOptions($product);
if (isset($checkoutData['qty'])) {
$this->setQty($checkoutData['qty']);
}
$this->clickOk();
$this->waitForFormNotVisible();
}

/**
* Click "Ok" button
* Click "Ok" button.
*
* @return void
*/
Expand All @@ -80,7 +88,39 @@ public function clickOk()
}

/**
* Get backend abstract block
* Wait for form is visible.
*
* @return void
*/
protected function waitForFormVisible()
{
$context = $this->_rootElement;
$selector = $this->configureForm;
return $this->browser->waitUntil(
function () use ($context, $selector) {
return $context->find($selector)->isVisible() ? true : null;
}
);
}

/**
* Wait for form is not visible.
*
* @return void
*/
protected function waitForFormNotVisible()
{
$context = $this->_rootElement;
$selector = $this->configureForm;
return $this->browser->waitUntil(
function () use ($context, $selector) {
return $context->find($selector)->isVisible() ? null : true;
}
);
}

/**
* Get backend abstract block.
*
* @return \Magento\Backend\Test\Block\Template
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,32 @@

namespace Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Action;

use Magento\Mtf\Fixture\FixtureInterface;
use Magento\Backend\Test\Block\Widget\Form;
use Magento\Mtf\Client\Locator;
use Magento\Mtf\Client\Element\SimpleElement;

/**
* Product attribute massaction edit page.
*/
class Attribute extends Form
{
/**
* CSS selector for 'save' button.
* Fill the root form.
*
* @var string
* @param FixtureInterface $fixture
* @param SimpleElement|null $element
* @return $this
*/
protected $saveButton = '[data-ui-id="page-actions-toolbar-save-button"]';

/**
* XPath selector for checkbox that enables price editing.
*
* @var string
*/
protected $priceFieldEnablerSelector = '//*[@id="attribute-price-container"]/div[1]/div/label//*[@type="checkbox"]';

/**
* Enable price field editing.
*
* @return void
*/
public function enablePriceEdit()
public function fill(FixtureInterface $fixture, SimpleElement $element = null)
{
$this->_rootElement->find(
$this->priceFieldEnablerSelector,
Locator::SELECTOR_XPATH,
'checkbox'
)->setValue('Yes');
$data = $fixture->getData();
foreach ($data as $name => $dataValue) {
$fields['toggle_' . $name] = 'Yes';
$fields[$name] = $dataValue;
}
$mapping = $this->dataMapping($fields);
$this->_fill($mapping, $element);

return $this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
<mapping strict="0">
<wrapper>attributes</wrapper>
<fields>
<price/>
<toggle_price>
<selector>[name='toggle_price']</selector>
<input>checkbox</input>
</toggle_price>
<price />
</fields>
</mapping>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Action;

/**
* Form action.
*/
class FormPageActions extends \Magento\Backend\Test\Block\FormPageActions
{
/**
* "Save" button.
*
* @var string
*/
protected $saveButton = '[data-ui-id="page-actions-toolbar-save-button"]';
}
Loading

0 comments on commit 649b03a

Please sign in to comment.