Skip to content

Commit 56001b8

Browse files
committed
MAGETWO-61877: UI Upgrade from 2.0.x to 2.0.11 Test Failure with Sample Data
- introducing sample data version selector in the FAT test using versioning from dataset
1 parent 2025e45 commit 56001b8

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed

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

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,62 @@ public function chooseUpgradeOtherComponents()
6363
$this->_rootElement->find("[for=yesUpdateComponents]", Locator::SELECTOR_CSS)->click();
6464
$this->waitForElementVisible("[ng-show='componentsProcessed']");
6565
}
66+
67+
/**
68+
* Set maximum compatible sample data for each row
69+
*
70+
* @param string $sampleDataVersion
71+
* @return void
72+
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
73+
*/
74+
public function chooseVersionUpgradeOtherComponents($sampleDataVersion)
75+
{
76+
$perPageSelect= $this->_rootElement->find(
77+
"select#perPage",
78+
Locator::SELECTOR_CSS,
79+
'select'
80+
);
81+
$fixtureVersion = $sampleDataVersion;
82+
$fixtureVersion = '100.0.*';
83+
$perPageSelect->setValue(200);
84+
sleep(1);
85+
86+
$elementsArray= $this->_rootElement->getElements("table.data-grid tbody tr");
87+
88+
foreach ($elementsArray as $key => $rowElement) {
89+
$textElement = $this->_rootElement->find(
90+
"//table//tbody//tr[" . ($key + 1) . "]//td//*[contains(text(),'sample')]",
91+
Locator::SELECTOR_XPATH
92+
);
93+
if (preg_match('/magento.+sample.+data/', $textElement->getText())) {
94+
$selectElement = $this->_rootElement->find(
95+
'//table//tbody//tr[' . ($key +1) . ']//td//select',
96+
Locator::SELECTOR_XPATH,
97+
'select'
98+
);
99+
100+
$fixtureVersion = str_replace('*', '[0-9]+', $fixtureVersion);
101+
$toSelectValue = $selectElement->getValue();
102+
$toSelectValueOriginal = $toSelectValue;
103+
$toSelectVersion = '0';
104+
foreach ($selectElement->getElements('option') as $option) {
105+
$optionText = $option->getText();
106+
if (preg_match('/' . $fixtureVersion .'/', $optionText)) {
107+
if (preg_match('/([0-9\.\-a-zA-Z]+)/', $optionText, $match)) {
108+
if (!empty($match) > 0) {
109+
if (version_compare($match[0], $toSelectVersion, '>')) {
110+
$toSelectVersion = $match[0];
111+
$toSelectValue = $optionText;
112+
}
113+
}
114+
}
115+
}
116+
}
117+
118+
if ($toSelectValue !== $toSelectValueOriginal) {
119+
$selectElement->setValue($toSelectValue);
120+
}
121+
}
122+
}
123+
}
66124
}

dev/tests/functional/tests/app/Magento/Upgrade/Test/TestCase/UpgradeSystemTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ public function test(
7272
['data' => $createBackupConfig]
7373
);
7474
$version = $upgrade['upgradeVersion'];
75+
$sampleDataVersion = $upgrade['sampledataVersion'];
7576

7677
$suffix = "( (CE|EE))$";
7778
$normalVersion = '(0|[1-9]\d*)';
@@ -109,6 +110,7 @@ public function test(
109110
$this->setupWizard->getSelectVersion()->fill($upgradeFixture);
110111
if ($upgrade['otherComponents'] === 'Yes') {
111112
$this->setupWizard->getSelectVersion()->chooseUpgradeOtherComponents();
113+
$this->setupWizard->getSelectVersion()->chooseVersionUpgradeOtherComponents($sampleDataVersion);
112114
}
113115
$this->setupWizard->getSelectVersion()->clickNext();
114116

dev/tests/functional/tests/app/Magento/Upgrade/Test/TestCase/UpgradeSystemTest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<data name="upgrade/optionsMedia" xsi:type="string">No</data>
1919
<data name="upgrade/optionsDb" xsi:type="string">No</data>
2020
<data name="upgrade/otherComponents" xsi:type="string">{otherComponents}</data>
21+
<data name="upgrade/sampledataVersion" xsi:type="string">{sampledataVersion}</data>
2122
</variation>
2223
</testCase>
2324
</config>

0 commit comments

Comments
 (0)