Skip to content

Commit 1a84924

Browse files
author
Dmytro Aponasenko
committed
MTA-2350: Add wait to form element before filling a value
1 parent dc1d806 commit 1a84924

File tree

1 file changed

+10
-18
lines changed
  • dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget

1 file changed

+10
-18
lines changed

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

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ protected function fillTabs(array $tabs, SimpleElement $element = null)
8888
$tab = $this->getTab($tabName);
8989
$this->openTab($tabName);
9090
$tab->fillFormTab(array_merge($tabFields, $this->unassignedFields), $context);
91-
$this->updateUnassignedFields($tab);
9291
}
9392
if (!empty($this->unassignedFields)) {
9493
$this->fillMissedFields($tabs);
@@ -97,19 +96,6 @@ protected function fillTabs(array $tabs, SimpleElement $element = null)
9796
return $this;
9897
}
9998

100-
/**
101-
* Update array with fields which aren't assigned to any tab
102-
*
103-
* @param Tab $tab
104-
*/
105-
protected function updateUnassignedFields(Tab $tab)
106-
{
107-
$this->unassignedFields = array_diff_key(
108-
$this->unassignedFields,
109-
array_intersect_key($this->unassignedFields, $tab->setFields)
110-
);
111-
}
112-
11399
/**
114100
* Fill fields which weren't found on filled tabs
115101
*
@@ -120,11 +106,17 @@ protected function updateUnassignedFields(Tab $tab)
120106
*/
121107
protected function fillMissedFields(array $tabs)
122108
{
123-
foreach (array_diff_key($this->tabs, $tabs) as $tabName => $tabData) {
109+
foreach ($this->tabs as $tabName => $tabData) {
124110
$tab = $this->getTab($tabName);
125-
if ($this->openTab($tabName)) {
126-
$tab->fillFormTab($this->unassignedFields, $this->_rootElement);
127-
$this->updateUnassignedFields($tab);
111+
if ($this->openTab($tabName) && $this->isTabVisible($tabName)) {
112+
$mapping = $tab->dataMapping($this->unassignedFields);
113+
foreach ($mapping as $fieldName => $data) {
114+
$element = $tab->_rootElement->find($data['selector'], $data['strategy'], $data['input']);
115+
if ($element->isVisible()) {
116+
$element->setValue($data['value']);
117+
unset($this->unassignedFields[$fieldName]);
118+
}
119+
}
128120
if (empty($this->unassignedFields)) {
129121
break;
130122
}

0 commit comments

Comments
 (0)