Skip to content

Commit 53717c8

Browse files
author
Dmytro Aponasenko
committed
MTA-1499: Analyse functional test failures
1 parent 71cafe4 commit 53717c8

File tree

25 files changed

+175
-129
lines changed

25 files changed

+175
-129
lines changed

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

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,42 +9,62 @@
99
use Magento\Mtf\Client\Locator;
1010

1111
/**
12-
* Class OptgroupselectElement
13-
* Typified element class for option group selectors
12+
* Typified element class for option group selectors.
1413
*/
1514
class OptgroupselectElement extends SelectElement
1615
{
1716
/**
18-
* Option locator
17+
* Option locator.
1918
*
2019
* @var string
2120
*/
22-
protected $optionByIndex = './/optgroup/option[%d]';
21+
protected $optionByIndex = './/option';
2322

2423
/**
25-
* Option group selector
24+
* Option group selector.
2625
*
2726
* @var string
2827
*/
2928
protected $optGroup = 'optgroup[option[contains(.,"%s")]]';
3029

3130
/**
32-
* Get the value of form element
31+
* Option group locator.
32+
*
33+
* @var string
34+
*/
35+
protected $optionGroupValue = ".//optgroup[@label = '%s']/option[text() = '%s']";
36+
37+
/**
38+
* Get the value of form element.
3339
*
3440
* @return string
41+
* @throws \Exception
3542
*/
3643
public function getValue()
3744
{
3845
$this->eventManager->dispatchEvent(['get_value'], [(string)$this->getAbsoluteSelector()]);
39-
$selectedLabel = trim(parent::getValue());
46+
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+
}
55+
if ($selectedLabel == '') {
56+
throw new \Exception('Selected value has not been found in optgroup select.');
57+
}
58+
4059
$element = $this->find(sprintf($this->optGroup, $selectedLabel), Locator::SELECTOR_XPATH);
4160
$value = trim($element->getAttribute('label'), chr(0xC2) . chr(0xA0));
4261
$value .= '/' . $selectedLabel;
62+
4363
return $value;
4464
}
4565

4666
/**
47-
* Select value in dropdown which has option groups
67+
* Select value in dropdown which has option groups.
4868
*
4969
* @param string $value
5070
* @return void
@@ -53,6 +73,8 @@ public function setValue($value)
5373
{
5474
$this->eventManager->dispatchEvent(['set_value'], [__METHOD__, $this->getAbsoluteSelector()]);
5575
list($group, $option) = explode('/', $value);
56-
parent::setOptionGroupValue($group, $option);
76+
$xpath = sprintf($this->optionGroupValue, $group, $option);
77+
$option = $this->find($xpath, Locator::SELECTOR_XPATH);
78+
$option->click();
5779
}
5880
}

dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/BundleProduct/Price.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ public function getDataConfig()
9292
* Get preset array
9393
*
9494
* @return array|null
95+
*
96+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
9597
*/
9698
public function getPreset()
9799
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ protected function prepareCheckoutData(array $options, array $checkoutData)
9797

9898
if (isset($options[$attribute])) {
9999
$result[] = [
100-
'type' => strtolower(preg_replace('/[^a-z]/i', '', $options[$attribute]['type'])),
100+
'type' => $options[$attribute]['type'],
101101
'title' => isset($options[$attribute]['title'])
102102
? $options[$attribute]['title']
103103
: $attribute,

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ class AttributeForm extends FormTabs
3232
*/
3333
protected $saveButton = '#save';
3434

35+
/**
36+
* Attribute to determine whether tab is opened.
37+
*
38+
* @var string
39+
*/
40+
protected $isTabOpened = '.opened ';
41+
3542
/**
3643
* Fill the attribute form.
3744
*
@@ -64,10 +71,11 @@ public function openTab($tabName)
6471
$strategy = isset($this->tabs[$tabName]['strategy'])
6572
? $this->tabs[$tabName]['strategy']
6673
: Locator::SELECTOR_CSS;
67-
$tab = $this->_rootElement->find($selector, $strategy);
68-
$target = $this->browser->find('.page-footer-wrapper'); // Handle menu overlap problem
69-
$this->_rootElement->dragAndDrop($target);
70-
$tab->click();
74+
75+
$isTabOpened = $this->_rootElement->find($this->isTabOpened . $selector, $strategy);
76+
if (!$isTabOpened->isVisible()) {
77+
$this->_rootElement->find($selector, $strategy)->click();
78+
}
7179

7280
return $this;
7381
}

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Attribute/AttributeForm.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
</fields>
2929
</properties>
3030
<advanced-properties>
31-
<class>\Magento\Catalog\Test\Block\Adminhtml\Product\Attribute\Edit\Tab\Advanced</class>
31+
<class>\Magento\Backend\Test\Block\Widget\Tab</class>
3232
<selector>[data-target="#advanced_fieldset-content"]</selector>
3333
<strategy>css selector</strategy>
3434
<fields>

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ class AttributeForm extends FormTabs
3333
*/
3434
protected $propertiesTab = '#product_attribute_tabs_main';
3535

36+
/**
37+
* Page title.
38+
*
39+
* @var string
40+
*/
41+
protected $pageTitle = '.page-title .title';
42+
3643
/**
3744
* Get data of the tabs.
3845
*
@@ -94,15 +101,8 @@ protected function expandAllToggles()
94101
*/
95102
public function openTab($tabName)
96103
{
97-
$selector = $this->tabs[$tabName]['selector'];
98-
$strategy = isset($this->tabs[$tabName]['strategy'])
99-
? $this->tabs[$tabName]['strategy']
100-
: Locator::SELECTOR_CSS;
101-
$tab = $this->_rootElement->find($selector, $strategy);
102-
$target = $this->browser->find('.page-title .title');// Handle menu overlap problem
103-
$this->_rootElement->dragAndDrop($target);
104-
$tab->click();
105-
return $this;
104+
$this->browser->find($this->pageTitle)->click(); // Handle menu overlap problem
105+
return parent::openTab($tabName);
106106
}
107107

108108
/**

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,16 +204,17 @@ protected function prepareCustomOptions(array $options)
204204
/**
205205
* Convert option name
206206
*
207-
* @param string $str
207+
* @param string $inputType
208208
* @return string
209209
*/
210-
protected function optionNameConvert($str)
210+
protected function optionNameConvert($inputType)
211211
{
212-
$str = str_replace([' ', '&'], "", $str);
213-
if ($end = strpos($str, '-')) {
214-
$str = substr($str, 0, $end) . ucfirst(substr($str, ($end + 1)));
212+
$option = substr($inputType, strpos($inputType, "/") + 1);
213+
$option = str_replace([' ', '&'], "", $option);
214+
if ($end = strpos($option, '-')) {
215+
$option = substr($option, 0, $end) . ucfirst(substr($option, ($end + 1)));
215216
}
216217

217-
return $str;
218+
return $option;
218219
}
219220
}

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,19 @@ class ProductDetails extends \Magento\Catalog\Test\Block\Adminhtml\Product\Edit\
3838
public function fillFormTab(array $fields, SimpleElement $element = null)
3939
{
4040
$data = $this->dataMapping($fields);
41-
41+
// Select attribute set
42+
if (isset($data['attribute_set_id'])) {
43+
$this->_fill([$data['attribute_set_id']], $element);
44+
unset($data['attribute_set_id']);
45+
}
46+
// Select categories
4247
if (isset($data['category_ids'])) {
4348
/* Fix browser behavior for click by hidden list result of suggest(category) element */
4449
$this->scrollToCategory();
4550
$this->_fill([$data['category_ids']], $element);
4651
unset($data['category_ids']);
4752
}
53+
4854
$this->_fill($data, $element);
4955

5056
return $this;

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/ProductDetails/AttributeSet.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ class AttributeSet extends SuggestElement
2828
*/
2929
protected $actionToggle = '.action-toggle';
3030

31+
/**
32+
* Magento loader
33+
*
34+
* @var string
35+
*/
36+
protected $loader = '[data-role="loader"]';
37+
3138
/**
3239
* Set value
3340
*
@@ -40,6 +47,14 @@ public function setValue($value)
4047
$this->find($this->actionToggle)->click();
4148
parent::setValue($value);
4249
}
50+
// Wait loader
51+
$element = $this->driver;
52+
$selector = $this->loader;
53+
$element->waitUntil(
54+
function () use ($element, $selector) {
55+
return $element->find($selector)->isVisible() == false ? true : null;
56+
}
57+
);
4358
}
4459

4560
/**

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@
162162
<type>
163163
<selector>.field [id$='_type']</selector>
164164
<strategy>css selector</strategy>
165-
<input>strictselect</input>
165+
<input>optgroupselect</input>
166166
</type>
167167
</fields>
168168
</customer-options>

0 commit comments

Comments
 (0)