Skip to content

Commit 3ffef60

Browse files
author
Vitaliy Honcharenko
committed
MTA-2395: Tax module functional tests maintenance
- fixed random fails on bamboo
1 parent 347547a commit 3ffef60

File tree

1 file changed

+35
-15
lines changed
  • dev/tests/functional/tests/app/Magento/Tax/Test/Block/Adminhtml/Rule/Edit

1 file changed

+35
-15
lines changed

dev/tests/functional/tests/app/Magento/Tax/Test/Block/Adminhtml/Rule/Edit/Form.php

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@ class Form extends FormInterface
108108
*/
109109
protected $taxClassMultiSelectList = ".//*[contains(@class, 'tax_%s_class')]//*[@class='block mselect-list']";
110110

111+
/**
112+
* Count of try for fill new tax class input.
113+
*/
114+
const MAX_TRY_COUNT = 3;
115+
111116
/**
112117
* Fill the root form.
113118
*
@@ -212,25 +217,40 @@ protected function addNewTaxClass(array $taxClasses, SimpleElement $element)
212217
foreach ($taxClasses as $taxClass) {
213218
$option = $element->find(sprintf($this->optionMaskElement, $taxClass), Locator::SELECTOR_XPATH);
214219
if (!$option->isVisible()) {
215-
$element->waitUntil(
216-
function () use ($element, $taxClass) {
217-
$input = $element->find($this->addNewInput);
218-
if ($input->isVisible()) {
219-
$input->click();
220-
$input->setValue($taxClass);
221-
$element->find($this->saveButton)->click();
222-
$this->waitUntilOptionIsVisible($element, $taxClass);
223-
return true;
224-
} else {
225-
$this->clickAddNewButton($element);
226-
return null;
227-
}
228-
}
229-
);
220+
$this->setNewTaxClassName($element, $taxClass);
230221
}
231222
}
232223
}
233224

225+
/**
226+
* Set new tax class name.
227+
*
228+
* @param SimpleElement $element
229+
* @param string $taxClass
230+
* @throws \Exception
231+
* @return void
232+
*/
233+
protected function setNewTaxClassName(SimpleElement $element, $taxClass)
234+
{
235+
$count = 0;
236+
do {
237+
try {
238+
$this->clickAddNewButton($element);
239+
$input = $element->find($this->addNewInput);
240+
$input->click();
241+
$input->setValue($taxClass);
242+
$element->find($this->saveButton)->click();
243+
$this->waitUntilOptionIsVisible($element, $taxClass);
244+
return;
245+
} catch (\Exception $e) {
246+
// In parallel run on windows change the focus is lost on element
247+
$count++;
248+
}
249+
} while ($count < self::MAX_TRY_COUNT);
250+
251+
throw new \Exception("Multiple rewrites detected:\n" . $e);
252+
}
253+
234254
/**
235255
* Waiting until option in list is visible.
236256
*

0 commit comments

Comments
 (0)