Skip to content

Commit e614ff5

Browse files
committed
Merge remote-tracking branch 'helix/pr-tests' into MAGETWO-83826
2 parents 1ea4ce2 + 9a99e82 commit e614ff5

File tree

10 files changed

+236
-28
lines changed

10 files changed

+236
-28
lines changed

dev/tests/functional/etc/events.xml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,37 @@
4343
<tag name="webapi_failed" />
4444
</observer>
4545
</preset>
46+
<preset name="debug" extends="base">
47+
<observer class="Magento\Mtf\System\Observer\Screenshot">
48+
<tag name="exception"/>
49+
<tag name="failure"/>
50+
<tag name="click_after"/>
51+
<tag name="accept_alert_after"/>
52+
<tag name="dismiss_alert_after"/>
53+
<tag name="open_after"/>
54+
<tag name="forward"/>
55+
<tag name="back"/>
56+
</observer>
57+
<observer class="Magento\Mtf\System\Observer\SourceCode">
58+
<tag name="exception"/>
59+
<tag name="failure"/>
60+
<tag name="click_after"/>
61+
<tag name="accept_alert_after"/>
62+
<tag name="dismiss_alert_after"/>
63+
<tag name="open_after"/>
64+
<tag name="forward"/>
65+
<tag name="back"/>
66+
</observer>
67+
<observer class="Magento\Mtf\System\Observer\Log">
68+
<tag name="exception"/>
69+
<tag name="failure"/>
70+
<tag name="click_before"/>
71+
<tag name="click_after"/>
72+
<tag name="accept_alert_after"/>
73+
<tag name="dismiss_alert_after"/>
74+
<tag name="open_after"/>
75+
<tag name="forward"/>
76+
<tag name="back"/>
77+
</observer>
78+
</preset>
4679
</config>

dev/tests/functional/tests/app/Magento/Setup/Test/Block/Readiness.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,14 @@ public function getDependencyCheck()
192192
return $this->_rootElement->find($this->dependencyCheck, Locator::SELECTOR_CSS)->getText();
193193
}
194194

195+
/**
196+
* @return bool
197+
*/
198+
public function isPhpVersionCheckVisible()
199+
{
200+
return $this->_rootElement->find($this->phpVersionCheck)->isVisible();
201+
}
202+
195203
/**
196204
* Get PHP Version check result.
197205
*

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

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Mtf\Client\Element\SimpleElement;
1111
use Magento\Mtf\Client\Locator;
1212
use Magento\Mtf\Fixture\FixtureInterface;
13+
use Magento\Setup\Test\Block\SelectVersion\OtherComponentsGrid;
1314

1415
/**
1516
* Select version block.
@@ -37,6 +38,13 @@ class SelectVersion extends Form
3738
*/
3839
private $showAllVersions = '#showUnstable';
3940

41+
/**
42+
* CSS selector for Other Components Grid Block.
43+
*
44+
* @var string
45+
*/
46+
private $otherComponentsGrid = '.admin__data-grid-wrap[ng-show="componentsProcessed"]';
47+
4048
/**
4149
* Click on 'Next' button.
4250
*
@@ -76,13 +84,28 @@ private function chooseShowAllVersions()
7684
}
7785

7886
/**
79-
* Choose 'yes' for upgrade option called 'Other components'
87+
* Choose 'yes' for upgrade option called 'Other components'.
8088
*
89+
* @param array $packages
8190
* @return void
8291
*/
83-
public function chooseUpgradeOtherComponents()
92+
public function chooseUpgradeOtherComponents(array $packages)
93+
{
94+
$this->_rootElement->find("[for=yesUpdateComponents]")->click();
95+
$this->waitForElementNotVisible("[ng-show=\"!componentsProcessed\"");
96+
$this->getOtherComponentsGrid()->setVersions($packages);
97+
}
98+
99+
/**
100+
* Get grid block for other components.
101+
*
102+
* @return OtherComponentsGrid
103+
*/
104+
private function getOtherComponentsGrid()
84105
{
85-
$this->_rootElement->find("[for=yesUpdateComponents]", Locator::SELECTOR_CSS)->click();
86-
$this->waitForElementVisible("[ng-show='componentsProcessed']");
106+
return $this->blockFactory->create(
107+
OtherComponentsGrid::class,
108+
['element' => $this->_rootElement->find($this->otherComponentsGrid)]
109+
);
87110
}
88111
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Setup\Test\Block\SelectVersion;
7+
8+
use Magento\Mtf\Block\Block;
9+
use Magento\Mtf\Client\Locator;
10+
use Magento\Setup\Test\Block\SelectVersion\OtherComponentsGrid\Item;
11+
12+
class OtherComponentsGrid extends Block
13+
{
14+
/**
15+
* @var string
16+
*/
17+
private $itemComponent = '//tr[contains(@ng-repeat,"component") and //td[contains(.,"%s")]]';
18+
19+
/**
20+
* @param $packages
21+
*/
22+
public function setVersions(array $packages)
23+
{
24+
foreach ($packages as $package) {
25+
$this->getComponentRow($package['name'])->setVersion($package['version']);
26+
}
27+
}
28+
29+
/**
30+
* @param string $componentName
31+
* @return Item
32+
*/
33+
private function getComponentRow($componentName)
34+
{
35+
$selector = sprintf($this->itemComponent, $componentName);
36+
return $this->blockFactory->create(
37+
Item::class,
38+
['element' => $this->_rootElement->find($selector, Locator::SELECTOR_XPATH)]
39+
);
40+
}
41+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Setup\Test\Block\SelectVersion\OtherComponentsGrid;
7+
8+
use Magento\Mtf\Block\Block;
9+
use Magento\Mtf\Client\Locator;
10+
11+
/**
12+
* Block for each component.
13+
*/
14+
class Item extends Block
15+
{
16+
/**
17+
* CSS selector for version element.
18+
*
19+
* @var string
20+
*/
21+
private $version = '[ng-change*="setComponentVersion"]';
22+
23+
/**
24+
* Set version for particular component.
25+
*
26+
* @param string $version
27+
*/
28+
public function setVersion($version)
29+
{
30+
$this->_rootElement->find($this->version, Locator::SELECTOR_CSS, 'select')->setValue($version);
31+
}
32+
}

dev/tests/functional/tests/app/Magento/Setup/Test/Constraint/AssertSuccessfulReadinessCheck.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,14 @@ public function processAssert(SetupWizard $setupWizard)
6767
$setupWizard->getReadiness()->getDependencyCheck(),
6868
'Dependency check is incorrect.'
6969
);
70-
\PHPUnit_Framework_Assert::assertContains(
71-
self::PHP_VERSION_MESSAGE,
72-
$setupWizard->getReadiness()->getPhpVersionCheck(),
73-
'PHP version is incorrect.'
74-
);
70+
if ($setupWizard->getReadiness()->isPhpVersionCheckVisible()) {
71+
\PHPUnit_Framework_Assert::assertContains(
72+
self::PHP_VERSION_MESSAGE,
73+
$setupWizard->getReadiness()->getPhpVersionCheck(),
74+
'PHP version is incorrect.'
75+
);
76+
}
77+
7578
\PHPUnit_Framework_Assert::assertContains(
7679
self::PHP_SETTING_REGEXP,
7780
$setupWizard->getReadiness()->getSettingsCheck(),

dev/tests/functional/tests/app/Magento/Setup/Test/Constraint/AssertVersionAndEditionCheck.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,24 @@ class AssertVersionAndEditionCheck extends AbstractConstraint
1818
* Assert that package and version is correct
1919
*
2020
* @param SetupWizard $setupWizard
21-
* @param string $package
22-
* @param string $version
21+
* @param array $upgrade
2322
* @return void
2423
*/
25-
public function processAssert(SetupWizard $setupWizard, $package, $version)
24+
public function processAssert(SetupWizard $setupWizard, array $upgrade)
2625
{
27-
$message = "We're ready to upgrade $package to $version";
26+
$message = "We're ready to upgrade {$upgrade['package']} to {$upgrade['version']}.";
27+
if (isset($upgrade['otherComponentsList'])) {
28+
foreach ($upgrade['otherComponentsList'] as $item) {
29+
$message .= "\nWe're ready to upgrade {$item['name']} to {$item['version']}.";
30+
}
31+
}
32+
$actualMessage = $setupWizard->getSystemUpgrade()->getUpgradeMessage();
2833
\PHPUnit_Framework_Assert::assertContains(
2934
$message,
30-
$setupWizard->getSystemUpgrade()->getUpgradeMessage(),
31-
'Updater application check is incorrect.'
35+
$actualMessage,
36+
"Updater application check is incorrect: \n"
37+
. "Expected: '$message' \n"
38+
. "Actual: '$actualMessage'"
3239
);
3340
}
3441

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

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,18 @@ class UpgradeSystemTest extends Injectable
3131
protected $adminDashboard;
3232

3333
/**
34-
* @var \Magento\Mtf\Util\Iterator\ApplicationState
35-
*/
36-
private $applicationStateIterator;
37-
38-
/**
34+
* Injection data.
35+
*
3936
* @param Dashboard $adminDashboard
4037
* @param SetupWizard $setupWizard
41-
* @param \Magento\Mtf\Util\Iterator\ApplicationState $applicationStateIterator
38+
* @return void
4239
*/
4340
public function __inject(
4441
Dashboard $adminDashboard,
45-
SetupWizard $setupWizard,
46-
\Magento\Mtf\Util\Iterator\ApplicationState $applicationStateIterator
42+
SetupWizard $setupWizard
4743
) {
4844
$this->adminDashboard = $adminDashboard;
4945
$this->setupWizard = $setupWizard;
50-
$this->applicationStateIterator = $applicationStateIterator;
5146
}
5247

5348
/**
@@ -114,7 +109,7 @@ public function test(
114109
$this->setupWizard->getSetupHome()->clickSystemUpgrade();
115110
$this->setupWizard->getSelectVersion()->fill($upgradeFixture);
116111
if ($upgrade['otherComponents'] === 'Yes') {
117-
$this->setupWizard->getSelectVersion()->chooseUpgradeOtherComponents();
112+
$this->setupWizard->getSelectVersion()->chooseUpgradeOtherComponents($upgrade['otherComponentsList']);
118113
}
119114
$this->setupWizard->getSelectVersion()->clickNext();
120115

@@ -128,7 +123,8 @@ public function test(
128123
$this->setupWizard->getCreateBackup()->clickNext();
129124

130125
// Check info and press 'Upgrade' button
131-
$assertVersionAndEdition->processAssert($this->setupWizard, $upgrade['package'], $version);
126+
$upgrade['version'] = $version;
127+
$assertVersionAndEdition->processAssert($this->setupWizard, $upgrade);
132128
$this->setupWizard->getSystemUpgrade()->clickSystemUpgrade();
133129

134130
$assertSuccessMessage->processAssert($this->setupWizard, $upgrade['package']);

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
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/otherComponentsList" xsi:type="array">
22+
<item name="0" xsi:type="array">
23+
<item name="name" xsi:type="string">{package_0_name}</item>
24+
<item name="version" xsi:type="string">{package_0_version}</item>
25+
</item>
26+
</data>
2127
</variation>
2228
</testCase>
2329
</config>

0 commit comments

Comments
 (0)