Skip to content

Commit 649b03a

Browse files
author
Aponasenko, Dmytro(daponasenko)
committed
Merge pull request #311 from magento-qmt/develop
[Mavericks] Re-factor and maintain functional tests
2 parents c6b58c4 + f1e1211 commit 649b03a

File tree

114 files changed

+1952
-904
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+1952
-904
lines changed

dev/tests/functional/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"require": {
3-
"magento/mtf": "1.0.0-rc24",
3+
"magento/mtf": "1.0.0-rc25",
44
"php": "~5.5.0|~5.6.0",
55
"phpunit/phpunit": "4.1.0",
66
"phpunit/phpunit-selenium": ">=1.2",

dev/tests/functional/lib/Magento/Mtf/Client/Element/OptgroupselectElement.php

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,6 @@
1313
*/
1414
class OptgroupselectElement extends SelectElement
1515
{
16-
/**
17-
* Option locator.
18-
*
19-
* @var string
20-
*/
21-
protected $optionByIndex = './/option';
22-
2316
/**
2417
* Option group selector.
2518
*
@@ -44,14 +37,7 @@ public function getValue()
4437
{
4538
$this->eventManager->dispatchEvent(['get_value'], [(string)$this->getAbsoluteSelector()]);
4639

47-
$selectedLabel = '';
48-
$labels = $this->getElements($this->optionByIndex, Locator::SELECTOR_XPATH);
49-
foreach ($labels as $label) {
50-
if ($label->isSelected()) {
51-
$selectedLabel = $label->getText();
52-
break;
53-
}
54-
}
40+
$selectedLabel = parent::getValue();
5541
if ($selectedLabel == '') {
5642
throw new \Exception('Selected value has not been found in optgroup select.');
5743
}

dev/tests/functional/lib/Magento/Mtf/Client/Element/SelectstoreElement.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,6 @@
1313
*/
1414
class SelectstoreElement extends SelectElement
1515
{
16-
/**
17-
* Option locator
18-
*
19-
* @var string
20-
*/
21-
protected $optionByIndex = './/optgroup/option[%d]';
22-
2316
/**
2417
* Store option group selector.
2518
*

dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/FormTabs.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ public function getTabElement($tabName)
273273
* Open tab
274274
*
275275
* @param string $tabName
276-
* @return Tab
276+
* @return FormTabs
277277
*/
278278
public function openTab($tabName)
279279
{

dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/Grid.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,14 @@ abstract class Grid extends Block
172172
*
173173
* @var string
174174
*/
175-
protected $actionNextPage = '.pager .action-next';
175+
protected $actionNextPage = '[class*=data-grid-pager] .action-next';
176176

177177
/**
178178
* Locator for disabled next page action
179179
*
180180
* @var string
181181
*/
182-
protected $actionNextPageDisabled = '.pager .action-next.disabled';
182+
protected $actionNextPageDisabled = '[class*=data-grid-pager] .action-next.disabled';
183183

184184
/**
185185
* First row selector
@@ -188,6 +188,13 @@ abstract class Grid extends Block
188188
*/
189189
protected $firstRowSelector = '';
190190

191+
/**
192+
* Selector for no records row.
193+
*
194+
* @var string
195+
*/
196+
protected $noRecords = '[data-role="row"] .empty-text';
197+
191198
/**
192199
* Get backend abstract block
193200
*
@@ -328,6 +335,9 @@ public function resetFilter()
328335
*/
329336
public function massaction(array $items, $action, $acceptAlert = false, $massActionSelection = '')
330337
{
338+
if ($this->_rootElement->find($this->noRecords)->isVisible()) {
339+
return;
340+
}
331341
if (!is_array($action)) {
332342
$action = [$action => '-'];
333343
}

dev/tests/functional/tests/app/Magento/Backend/Test/Repository/ConfigData.xml

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/Magento/Mtf/Repository/etc/repository.xsd">
99
<repository class="Magento\Config\Test\Repository\ConfigData">
10-
<dataset name="store_information">
10+
<dataset name="store_information_US">
1111
<field name="general/store_information/name" xsi:type="array">
1212
<item name="scope" xsi:type="string">general</item>
1313
<item name="scope_id" xsi:type="number">1</item>
@@ -58,6 +58,57 @@
5858
</field>
5959
</dataset>
6060

61+
<dataset name="store_information_DE_with_VAT">
62+
<field name="general/store_information/name" xsi:type="array">
63+
<item name="scope" xsi:type="string">general</item>
64+
<item name="scope_id" xsi:type="number">1</item>
65+
<item name="label" xsi:type="string"/>
66+
<item name="value" xsi:type="string">DE Store</item>
67+
</field>
68+
<field name="general/store_information/phone" xsi:type="array">
69+
<item name="scope" xsi:type="string">general</item>
70+
<item name="scope_id" xsi:type="number">1</item>
71+
<item name="label" xsi:type="string"/>
72+
<item name="value" xsi:type="string">630-371-7008</item>
73+
</field>
74+
<field name="general/store_information/country_id" xsi:type="array">
75+
<item name="scope" xsi:type="string">general</item>
76+
<item name="scope_id" xsi:type="number">1</item>
77+
<item name="label" xsi:type="string">Germany</item>
78+
<item name="value" xsi:type="string">DE</item>
79+
</field>
80+
<field name="general/store_information/region_id" xsi:type="array">
81+
<item name="scope" xsi:type="string">general</item>
82+
<item name="scope_id" xsi:type="number">1</item>
83+
<item name="label" xsi:type="string">Berlin</item>
84+
<item name="value" xsi:type="number">82</item>
85+
</field>
86+
<field name="general/store_information/postcode" xsi:type="array">
87+
<item name="scope" xsi:type="string">general</item>
88+
<item name="scope_id" xsi:type="number">1</item>
89+
<item name="label" xsi:type="string"/>
90+
<item name="value" xsi:type="number">10789</item>
91+
</field>
92+
<field name="general/store_information/city" xsi:type="array">
93+
<item name="scope" xsi:type="string">general</item>
94+
<item name="scope_id" xsi:type="number">1</item>
95+
<item name="label" xsi:type="string"/>
96+
<item name="value" xsi:type="string">Berlin</item>
97+
</field>
98+
<field name="general/store_information/street_line1" xsi:type="array">
99+
<item name="scope" xsi:type="string">general</item>
100+
<item name="scope_id" xsi:type="number">1</item>
101+
<item name="label" xsi:type="string"/>
102+
<item name="value" xsi:type="string">Augsburger Strabe 41</item>
103+
</field>
104+
<field name="general/store_information/merchant_vat_number" xsi:type="array">
105+
<item name="scope" xsi:type="string">general</item>
106+
<item name="scope_id" xsi:type="number">1</item>
107+
<item name="label" xsi:type="string"/>
108+
<item name="value" xsi:type="string">111607872</item>
109+
</field>
110+
</dataset>
111+
61112
<dataset name="admin_session_lifetime_1_hour">
62113
<field name="admin/security/session_lifetime" xsi:type="array">
63114
<item name="scope" xsi:type="string">default</item>

dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class Option extends Form
5050
*
5151
* @var string
5252
*/
53-
protected $removeSelection = 'button.delete';
53+
protected $removeSelection = '.col-actions .action-delete';
5454

5555
/**
5656
* Get grid for assigning products for bundle option
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
/**
4+
* Copyright © 2015 Magento. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/variations.xsd">
9+
<testCase name="Magento\Catalog\Test\TestCase\Product\ValidateOrderOfProductTypeTest">
10+
<variation name="ValidateOrderOfProductTypeTestVariation1">
11+
<data name="menu/4" xsi:type="string">Bundle Product</data>
12+
</variation>
13+
</testCase>
14+
</config>

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Composite/Configure.php

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,34 +13,40 @@
1313
use Magento\Catalog\Test\Block\AbstractConfigureBlock;
1414

1515
/**
16-
* Class Configure
17-
* Adminhtml catalog product composite configure block
16+
* Adminhtml catalog product composite configure block.
1817
*/
1918
class Configure extends AbstractConfigureBlock
2019
{
2120
/**
22-
* Custom options CSS selector
21+
* Configure form selector.
22+
*
23+
* @var string
24+
*/
25+
protected $configureForm = '#product_composite_configure_form';
26+
27+
/**
28+
* Custom options CSS selector.
2329
*
2430
* @var string
2531
*/
2632
protected $customOptionsSelector = '#product_composite_configure_fields_options';
2733

2834
/**
29-
* Selector for "Ok" button
35+
* Selector for "Ok" button.
3036
*
3137
* @var string
3238
*/
3339
protected $okButton = '.ui-button.action-primary';
3440

3541
/**
36-
* Backend abstract block
42+
* Backend abstract block.
3743
*
3844
* @var string
3945
*/
4046
protected $templateBlock = './ancestor::body';
4147

4248
/**
43-
* Set quantity
49+
* Set quantity.
4450
*
4551
* @param int $qty
4652
* @return void
@@ -51,7 +57,7 @@ public function setQty($qty)
5157
}
5258

5359
/**
54-
* Fill in the option specified for the product
60+
* Fill in the option specified for the product.
5561
*
5662
* @param FixtureInterface $product
5763
* @return void
@@ -61,15 +67,17 @@ public function configProduct(FixtureInterface $product)
6167
/** @var CatalogProductSimple $product */
6268
$checkoutData = $product->getCheckoutData();
6369

70+
$this->waitForFormVisible();
6471
$this->fillOptions($product);
6572
if (isset($checkoutData['qty'])) {
6673
$this->setQty($checkoutData['qty']);
6774
}
6875
$this->clickOk();
76+
$this->waitForFormNotVisible();
6977
}
7078

7179
/**
72-
* Click "Ok" button
80+
* Click "Ok" button.
7381
*
7482
* @return void
7583
*/
@@ -80,7 +88,39 @@ public function clickOk()
8088
}
8189

8290
/**
83-
* Get backend abstract block
91+
* Wait for form is visible.
92+
*
93+
* @return void
94+
*/
95+
protected function waitForFormVisible()
96+
{
97+
$context = $this->_rootElement;
98+
$selector = $this->configureForm;
99+
return $this->browser->waitUntil(
100+
function () use ($context, $selector) {
101+
return $context->find($selector)->isVisible() ? true : null;
102+
}
103+
);
104+
}
105+
106+
/**
107+
* Wait for form is not visible.
108+
*
109+
* @return void
110+
*/
111+
protected function waitForFormNotVisible()
112+
{
113+
$context = $this->_rootElement;
114+
$selector = $this->configureForm;
115+
return $this->browser->waitUntil(
116+
function () use ($context, $selector) {
117+
return $context->find($selector)->isVisible() ? null : true;
118+
}
119+
);
120+
}
121+
122+
/**
123+
* Get backend abstract block.
84124
*
85125
* @return \Magento\Backend\Test\Block\Template
86126
*/

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Action/Attribute.php

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,32 @@
66

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

9+
use Magento\Mtf\Fixture\FixtureInterface;
910
use Magento\Backend\Test\Block\Widget\Form;
10-
use Magento\Mtf\Client\Locator;
11+
use Magento\Mtf\Client\Element\SimpleElement;
1112

1213
/**
1314
* Product attribute massaction edit page.
1415
*/
1516
class Attribute extends Form
1617
{
1718
/**
18-
* CSS selector for 'save' button.
19+
* Fill the root form.
1920
*
20-
* @var string
21+
* @param FixtureInterface $fixture
22+
* @param SimpleElement|null $element
23+
* @return $this
2124
*/
22-
protected $saveButton = '[data-ui-id="page-actions-toolbar-save-button"]';
23-
24-
/**
25-
* XPath selector for checkbox that enables price editing.
26-
*
27-
* @var string
28-
*/
29-
protected $priceFieldEnablerSelector = '//*[@id="attribute-price-container"]/div[1]/div/label//*[@type="checkbox"]';
30-
31-
/**
32-
* Enable price field editing.
33-
*
34-
* @return void
35-
*/
36-
public function enablePriceEdit()
25+
public function fill(FixtureInterface $fixture, SimpleElement $element = null)
3726
{
38-
$this->_rootElement->find(
39-
$this->priceFieldEnablerSelector,
40-
Locator::SELECTOR_XPATH,
41-
'checkbox'
42-
)->setValue('Yes');
27+
$data = $fixture->getData();
28+
foreach ($data as $name => $dataValue) {
29+
$fields['toggle_' . $name] = 'Yes';
30+
$fields[$name] = $dataValue;
31+
}
32+
$mapping = $this->dataMapping($fields);
33+
$this->_fill($mapping, $element);
34+
35+
return $this;
4336
}
4437
}

0 commit comments

Comments
 (0)