Skip to content

Commit e3684af

Browse files
committed
MAGETWO-61877: UI Upgrade from 2.0.x to 2.0.11 Test Failure with Sample Data
- fix regular expression and empty array logic - assert if pager exists
1 parent 4ecc9bb commit e3684af

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

dev/tests/functional/tests/app/Magento/Upgrade/Test/Block/SelectVersion.php

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,11 @@ private function clickOnNextPage()
125125
*/
126126
private function canClickOnNextPage()
127127
{
128-
return !$this->_rootElement->find(
129-
".admin__data-grid-pager .action-next",
130-
Locator::SELECTOR_CSS
131-
)->isDisabled();
128+
$element = $this->_rootElement->find(".admin__data-grid-pager .action-next");
129+
if ($element->isVisible()) {
130+
return !$element->isDisabled();
131+
}
132+
return false;
132133
}
133134

134135
/**
@@ -184,7 +185,7 @@ private function convertVersionFixtureToRegexp($sampleDataVersion)
184185
*/
185186
private function titleContainsSampleData($element)
186187
{
187-
return preg_match('/magento\/*+sample-data/', $element->getText());
188+
return preg_match('/magento\/.*sample-data/', $element->getText());
188189
}
189190

190191
/**
@@ -194,8 +195,7 @@ private function titleContainsSampleData($element)
194195
* @param string $sampleDataVersionForRegex
195196
* @return void
196197
*/
197-
private function setSampleDataVersionToRowSelect($rowIndex, $sampleDataVersionForRegex)
198-
{
198+
private function setSampleDataVersionToRowSelect($rowIndex, $sampleDataVersionForRegex) {
199199
$selectElement = $this->getSelectFromRow($rowIndex);
200200
$optionTextArray = [];
201201
foreach ($selectElement->getElements('option') as $option) {
@@ -206,16 +206,18 @@ private function setSampleDataVersionToRowSelect($rowIndex, $sampleDataVersionFo
206206
}
207207
}
208208

209-
uasort(
210-
$optionTextArray,
211-
function ($versionOne, $versionTwo) {
212-
return version_compare($versionOne, $versionTwo) * -1;
209+
if (!empty($optionTextArray)) {
210+
uasort(
211+
$optionTextArray,
212+
function ($versionOne, $versionTwo) {
213+
return version_compare($versionOne, $versionTwo) * -1;
214+
}
215+
);
216+
217+
$toSelectVersion = key($optionTextArray);
218+
if ($toSelectVersion !== $selectElement->getText()) {
219+
$selectElement->setValue($toSelectVersion);
213220
}
214-
);
215-
216-
$toSelectVersion = key($optionTextArray);
217-
if ($toSelectVersion !== $selectElement->getText()) {
218-
$selectElement->setValue($optionTextArray[]);
219221
}
220222
}
221223
}

0 commit comments

Comments
 (0)