Skip to content

Commit 2eaa8b5

Browse files
committed
Merge pull request magento#71 from magento-qmt/MTA-3333
[Maveriks] Functional test fixes
2 parents f06e0d9 + 076dc1e commit 2eaa8b5

File tree

56 files changed

+1422
-134
lines changed

Some content is hidden

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

56 files changed

+1422
-134
lines changed

dev/tests/functional/composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"require": {
3-
"magento/mtf": "1.0.0-rc42",
3+
"magento/mtf": "1.0.0-rc43",
44
"php": "~5.5.22|~5.6.0|~7.0.0",
55
"phpunit/phpunit": "4.1.0",
66
"phpunit/phpunit-selenium": ">=1.2"

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

+10-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
namespace Magento\Mtf\Client\Element;
88

9+
use Magento\Mtf\Client\Locator;
10+
911
/**
1012
* Toggle element in the backend.
1113
* Switches value between YES and NO.
@@ -19,6 +21,13 @@ class SwitcherElement extends SimpleElement
1921
*/
2022
protected $parentContainer = 'parent::div[@data-role="switcher"]';
2123

24+
/**
25+
* XPath selector for label text on swticher element.
26+
*
27+
* @var string
28+
*/
29+
private $labelText = './following-sibling::label';
30+
2231
/**
2332
* Set value to Yes or No.
2433
*
@@ -33,7 +42,7 @@ public function setValue($value)
3342
);
3443
}
3544
if ($value != $this->getValue()) {
36-
$this->click();
45+
$this->find($this->labelText, Locator::SELECTOR_XPATH)->click();
3746
}
3847
}
3948

dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/BundleProduct.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
<field name="tax_class_id" is_required="0" group="product-details" source="Magento\Catalog\Test\Fixture\Product\TaxClass" />
7777
<field name="thumbnail" is_required="0" />
7878
<field name="thumbnail_label" is_required="0" />
79-
<field name="tier_price" is_required="0" group="advanced-pricing" repository="Magento\Catalog\Test\Repository\Product\TierPrice" />
79+
<field name="tier_price" is_required="0" group="advanced-pricing" source="Magento\Catalog\Test\Fixture\Product\TierPrice" repository="Magento\Catalog\Test\Repository\Product\TierPrice" />
8080
<field name="updated_at" is_required="1" />
8181
<field name="url_key" is_required="0" group="search-engine-optimization" />
8282
<field name="url_path" is_required="0" />

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/Options/Type.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,12 @@ class Type extends OptgroupselectElement
4949
*/
5050
protected function getData(ElementInterface $element)
5151
{
52-
$this->find($this->advancedSelect)->click();
53-
return trim($element->getText());
52+
$selectedElement = $this->find($this->advancedSelect);
53+
$selectedElement->click();
54+
$text = trim($element->getText());
55+
$selectedElement->click();
56+
57+
return $text;
5458
}
5559

5660
/**

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Search.php

+47
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,20 @@ class Search extends Block
5050
*/
5151
protected $placeholder = '//input[@id="search" and contains(@placeholder, "%s")]';
5252

53+
/**
54+
* Locator value for list items.
55+
*
56+
* @var string
57+
*/
58+
private $searchListItems = './/div[@id="search_autocomplete"]//li';
59+
60+
/**
61+
* Locator value for body with aria-busy attribute.
62+
*
63+
* @var string
64+
*/
65+
private $selectorAriaBusy = './/body[@aria-busy="false"]';
66+
5367
/**
5468
* Perform search by a keyword.
5569
*
@@ -73,6 +87,27 @@ public function search($keyword)
7387
public function fillSearch($text)
7488
{
7589
$this->_rootElement->find($this->searchInput)->setValue($text);
90+
$this->waitUntilSearchPrepared();
91+
}
92+
93+
/**
94+
* Wait until "Suggest Search" block will be prepared.
95+
*
96+
* @return bool
97+
*/
98+
public function waitUntilSearchPrepared()
99+
{
100+
$this->browser->waitUntil(
101+
function () {
102+
$count = count($this->_rootElement->getElements($this->searchListItems, Locator::SELECTOR_XPATH));
103+
usleep(200);
104+
$newCount = count($this->_rootElement->getElements($this->searchListItems, Locator::SELECTOR_XPATH));
105+
return $this->browser->find($this->selectorAriaBusy, Locator::SELECTOR_XPATH)->isVisible()
106+
&& ($newCount == $count)
107+
? true
108+
: null;
109+
}
110+
);
76111
}
77112

78113
/**
@@ -108,4 +143,16 @@ function () use ($rootElement, $searchAutocomplete) {
108143
}
109144
);
110145
}
146+
147+
/**
148+
* Click on suggested text.
149+
*
150+
* @param string $text
151+
* @return void
152+
*/
153+
public function clickSuggestedText($text)
154+
{
155+
$searchAutocomplete = sprintf($this->searchAutocomplete, $text);
156+
$this->_rootElement->find($searchAutocomplete, Locator::SELECTOR_XPATH)->click();
157+
}
111158
}

dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
<field name="tax_class_id" is_required="0" group="product-details" source="Magento\Catalog\Test\Fixture\Product\TaxClass" />
6565
<field name="thumbnail" is_required="0" />
6666
<field name="thumbnail_label" is_required="0" />
67-
<field name="tier_price" is_required="0" group="advanced-pricing" repository="Magento\Catalog\Test\Repository\Product\TierPrice" />
67+
<field name="tier_price" is_required="0" group="advanced-pricing" source="Magento\Catalog\Test\Fixture\Product\TierPrice" repository="Magento\Catalog\Test\Repository\Product\TierPrice" />
6868
<field name="updated_at" is_required="1" />
6969
<field name="url_key" is_required="0" group="search-engine-optimization" />
7070
<field name="url_path" is_required="0" />

dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductVirtual.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
<field name="tax_class_id" is_required="0" group="product-details" source="Magento\Catalog\Test\Fixture\Product\TaxClass" />
6767
<field name="thumbnail" is_required="0" />
6868
<field name="thumbnail_label" is_required="0" />
69-
<field name="tier_price" is_required="0" group="advanced-pricing" repository="Magento\Catalog\Test\Repository\Product\TierPrice" />
69+
<field name="tier_price" is_required="0" group="advanced-pricing" source="Magento\Catalog\Test\Fixture\Product\TierPrice" repository="Magento\Catalog\Test\Repository\Product\TierPrice" />
7070
<field name="stock_data" group="advanced-inventory" />
7171
<field name="updated_at" is_required="1" />
7272
<field name="url_key" is_required="0" group="search-engine-optimization" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Catalog\Test\Fixture\Product;
8+
9+
use Magento\Mtf\Fixture\DataSource;
10+
use Magento\Mtf\Fixture\FixtureFactory;
11+
use Magento\Customer\Test\Fixture\CustomerGroup;
12+
use Magento\Mtf\Repository\RepositoryFactory;
13+
14+
/**
15+
* TierPrice data source.
16+
*
17+
* Data keys:
18+
* - dataset
19+
*/
20+
class TierPrice extends DataSource
21+
{
22+
/**
23+
* Customer group fixture array.
24+
*
25+
* @var array
26+
*/
27+
private $customerGroups;
28+
29+
/**
30+
* Repository Factory instance.
31+
*
32+
* @var RepositoryFactory
33+
*/
34+
private $repositoryFactory;
35+
36+
/**
37+
* Fixture Factory instance.
38+
*
39+
* @var FixtureFactory
40+
*/
41+
private $fixtureFactory;
42+
43+
/**
44+
* Rought fixture field data.
45+
*
46+
* @var array
47+
*/
48+
private $fixtureData = null;
49+
50+
/**
51+
* @constructor
52+
* @param RepositoryFactory $repositoryFactory
53+
* @param FixtureFactory $fixtureFactory
54+
* @param array $params
55+
* @param array $data
56+
* @throws \Exception
57+
*/
58+
public function __construct(
59+
RepositoryFactory $repositoryFactory,
60+
FixtureFactory $fixtureFactory,
61+
array $params,
62+
$data = []
63+
) {
64+
$this->repositoryFactory = $repositoryFactory;
65+
$this->fixtureFactory = $fixtureFactory;
66+
$this->params = $params;
67+
$this->fixtureData = $data;
68+
}
69+
70+
/**
71+
* Return prepared data set.
72+
*
73+
* @param string $key [optional]
74+
* @return mixed
75+
* @throws \Exception
76+
*/
77+
public function getData($key = null)
78+
{
79+
if (!isset($this->fixtureData['dataset'])) {
80+
throw new \Exception("Data must be set");
81+
}
82+
$this->data = $this->repositoryFactory->get($this->params['repository'])->get($this->fixtureData['dataset']);
83+
foreach ($this->data as $key => $item) {
84+
/** @var CustomerGroup $customerGroup */
85+
$customerGroup = $this->fixtureFactory->createByCode(
86+
'customerGroup',
87+
['dataset' => $item['customer_group']['dataset']]
88+
);
89+
if (!$customerGroup->hasData('customer_group_id')) {
90+
$customerGroup->persist();
91+
}
92+
$this->data[$key]['customer_group'] = $customerGroup->getCustomerGroupCode();
93+
$this->customerGroups[$key] = $customerGroup;
94+
}
95+
96+
return parent::getData($key);
97+
}
98+
99+
/**
100+
* Return customer group fixture.
101+
*
102+
* @return array
103+
*/
104+
public function getCustomerGroups()
105+
{
106+
return $this->customerGroups;
107+
}
108+
}

dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductSimple/Curl.php

+8-12
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,6 @@ class Curl extends AbstractCurl implements CatalogProductSimpleInterface
119119
'Yes' => 1,
120120
'No' => 0,
121121
],
122-
'use_config_enable_qty_increments' => [
123-
'Yes' => 1,
124-
'No' => 0,
125-
],
126122
];
127123

128124
/**
@@ -138,12 +134,7 @@ class Curl extends AbstractCurl implements CatalogProductSimpleInterface
138134
]
139135
],
140136
'customer_group' => [
141-
'name' => 'cust_group',
142-
'data' => [
143-
'ALL GROUPS' => 32000,
144-
'NOT LOGGED IN' => 0,
145-
'General' => 1
146-
]
137+
'name' => 'cust_group'
147138
]
148139
];
149140

@@ -455,9 +446,14 @@ protected function prepareAdvancedPricing()
455446
*/
456447
protected function preparePriceFields(array $fields)
457448
{
458-
foreach ($fields as &$field) {
449+
foreach ($fields as $priceKey => &$field) {
459450
foreach ($this->priceData as $key => $data) {
460-
$field[$data['name']] = $this->priceData[$key]['data'][$field[$key]];
451+
if ($data['name'] == 'cust_group') {
452+
$field[$data['name']] = $this->fixture->getDataFieldConfig('tier_price')['source']
453+
->getCustomerGroups()[$priceKey]->getCustomerGroupId();
454+
} else {
455+
$field[$data['name']] = $this->priceData[$key]['data'][$field[$key]];
456+
}
461457
unset($field[$key]);
462458
}
463459
$field['delete'] = '';

dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/Product/TierPrice.xml

+12-4
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,17 @@
1212
<item name="price" xsi:type="string">15</item>
1313
<item name="website" xsi:type="string">All Websites [USD]</item>
1414
<item name="price_qty" xsi:type="string">3</item>
15-
<item name="customer_group" xsi:type="string">ALL GROUPS</item>
15+
<item name="customer_group" xsi:type="array">
16+
<item name="dataset" xsi:type="string">ALL_GROUPS</item>
17+
</item>
1618
</field>
1719
<field name="1" xsi:type="array">
1820
<item name="price" xsi:type="string">24</item>
1921
<item name="website" xsi:type="string">All Websites [USD]</item>
2022
<item name="price_qty" xsi:type="string">15</item>
21-
<item name="customer_group" xsi:type="string">ALL GROUPS</item>
23+
<item name="customer_group" xsi:type="array">
24+
<item name="dataset" xsi:type="string">ALL_GROUPS</item>
25+
</item>
2226
</field>
2327
</dataset>
2428

@@ -42,7 +46,9 @@
4246
<item name="price" xsi:type="string">90</item>
4347
<item name="website" xsi:type="string">All Websites [USD]</item>
4448
<item name="price_qty" xsi:type="string">2</item>
45-
<item name="customer_group" xsi:type="string">ALL GROUPS</item>
49+
<item name="customer_group" xsi:type="array">
50+
<item name="dataset" xsi:type="string">ALL_GROUPS</item>
51+
</item>
4652
</field>
4753
</dataset>
4854

@@ -51,7 +57,9 @@
5157
<item name="price" xsi:type="string">80</item>
5258
<item name="website" xsi:type="string">All Websites [USD]</item>
5359
<item name="price_qty" xsi:type="string">2</item>
54-
<item name="customer_group" xsi:type="string">General</item>
60+
<item name="customer_group" xsi:type="array">
61+
<item name="dataset" xsi:type="string">General</item>
62+
</item>
5563
</field>
5664
</dataset>
5765
</repository>

dev/tests/functional/tests/app/Magento/CatalogRule/Test/Page/Adminhtml/CatalogRuleNew.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
<page name="CatalogRuleNew" area="Adminhtml" mca="catalog_rule/promo_catalog/new" module="Magento_CatalogRule">
1010
<block name="formPageActions" class="Magento\CatalogRule\Test\Block\Adminhtml\FormPageActions" locator=".page-main-actions" strategy="css selector"/>
1111
<block name="editForm" class="Magento\CatalogRule\Test\Block\Adminhtml\Promo\Catalog\Edit\PromoForm" locator="[id='page:main-container']" strategy="css selector"/>
12-
<block name="modalBlock" class="Magento\Ui\Test\Block\Adminhtml\Modal" locator="._show[data-role=modal]" strategy="css selector"/>
12+
<block name="modalBlock" class="Magento\Ui\Test\Block\Adminhtml\Modal" locator="._show[data-role=modal][style='z-index: 900;']" strategy="css selector"/>
1313
</page>
1414
</config>

dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Constraint/AssertSuggestSearchingResult.php

+13-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Magento\CatalogSearch\Test\Fixture\CatalogSearchQuery;
1010
use Magento\Cms\Test\Page\CmsIndex;
1111
use Magento\Mtf\Constraint\AbstractConstraint;
12+
use Magento\CatalogSearch\Test\Page\AdvancedResult;
1213

1314
/**
1415
* Class AssertSuggestSearchingResult
@@ -18,13 +19,20 @@ class AssertSuggestSearchingResult extends AbstractConstraint
1819
/**
1920
* Check that after input some text(e.g. product name) into search field, drop-down window is appeared.
2021
* Window contains requested entity and number of quantity.
22+
* Click on search suggestion and verify that search is performed.
2123
*
2224
* @param CmsIndex $cmsIndex
2325
* @param CatalogSearchQuery $catalogSearch
26+
* @param AssertCatalogSearchResult $assertCatalogSearchResult
27+
* @param AdvancedResult $resultPage
2428
* @return void
2529
*/
26-
public function processAssert(CmsIndex $cmsIndex, CatalogSearchQuery $catalogSearch)
27-
{
30+
public function processAssert(
31+
CatalogSearchQuery $catalogSearch,
32+
CmsIndex $cmsIndex,
33+
AssertCatalogSearchResult $assertCatalogSearchResult,
34+
AdvancedResult $resultPage
35+
) {
2836
$cmsIndex->open();
2937
$searchBlock = $cmsIndex->getSearchBlock();
3038

@@ -41,6 +49,8 @@ public function processAssert(CmsIndex $cmsIndex, CatalogSearchQuery $catalogSea
4149
$isVisible,
4250
'Block "Suggest Search" when searching was not found'
4351
);
52+
$searchBlock->clickSuggestedText($queryText);
53+
$assertCatalogSearchResult->processAssert($catalogSearch, $resultPage);
4454
}
4555

4656
/**
@@ -50,6 +60,6 @@ public function processAssert(CmsIndex $cmsIndex, CatalogSearchQuery $catalogSea
5060
*/
5161
public function toString()
5262
{
53-
return 'Asserts window contains requested entity and quantity';
63+
return 'Asserts window contains requested entity and quantity. Searched product has been successfully found.';
5464
}
5565
}

0 commit comments

Comments
 (0)