Skip to content

Commit 40d44c2

Browse files
committed
ENGCOM-3725: MTF test fix.
1 parent eeb40d8 commit 40d44c2

14 files changed

+219
-10
lines changed

dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/Dashboard.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@
1717
<block name="accessDeniedBlock" class="Magento\Backend\Test\Block\Denied" locator="#anchor-content" strategy="css selector" />
1818
<block name="systemMessageDialog" class="Magento\AdminNotification\Test\Block\System\Messages" locator='.ui-popup-message .modal-inner-wrap' strategy="css selector" />
1919
<block name="applicationVersion" class="Magento\Backend\Test\Block\Version" locator="body" strategy="css selector" />
20+
<block name="modalMessage" class="Magento\Ui\Test\Block\Adminhtml\Modal" locator=".modal-popup>.modal-inner-wrap" strategy="css selector" />
2021
</page>
2122
</config>

dev/tests/functional/tests/app/Magento/User/Test/Constraint/AssertUserRoleRestrictedAccess.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Mtf\Client\BrowserInterface;
1111
use Magento\Mtf\Constraint\AbstractConstraint;
1212
use Magento\User\Test\Fixture\User;
13+
use Magento\User\Test\TestStep\LoginUserOnBackendWithErrorStep;
1314

1415
/**
1516
* Asserts that user has only related permissions.
@@ -18,6 +19,8 @@ class AssertUserRoleRestrictedAccess extends AbstractConstraint
1819
{
1920
const DENIED_ACCESS = 'Sorry, you need permissions to view this content.';
2021

22+
protected $loginStep = 'Magento\User\Test\TestStep\LoginUserOnBackendStep';
23+
2124
/**
2225
* Asserts that user has only related permissions.
2326
*
@@ -36,7 +39,7 @@ public function processAssert(
3639
$denyUrl
3740
) {
3841
$this->objectManager->create(
39-
\Magento\User\Test\TestStep\LoginUserOnBackendStep::class,
42+
$this->loginStep,
4043
['user' => $user]
4144
)->run();
4245

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\User\Test\Constraint;
10+
11+
/**
12+
* @inheritdoc
13+
*/
14+
class AssertUserRoleRestrictedAccessWithError extends AssertUserRoleRestrictedAccess
15+
{
16+
protected $loginStep = 'Magento\User\Test\TestStep\LoginUserOnBackendWithErrorStep';
17+
}

dev/tests/functional/tests/app/Magento/User/Test/Constraint/AssertUserSuccessLogin.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,20 @@
77
namespace Magento\User\Test\Constraint;
88

99
use Magento\Backend\Test\Page\Adminhtml\Dashboard;
10-
use Magento\User\Test\Fixture\User;
1110
use Magento\Mtf\Constraint\AbstractConstraint;
11+
use Magento\User\Test\Fixture\User;
12+
use Magento\User\Test\TestStep\LoginUserOnBackendStep;
1213

1314
/**
1415
* Verify whether customer has logged in to the Backend.
1516
*/
1617
class AssertUserSuccessLogin extends AbstractConstraint
1718
{
19+
/**
20+
* @var string
21+
*/
22+
protected $loginStep = LoginUserOnBackendStep::class;
23+
1824
/**
1925
* Verify whether customer has logged in to the Backend.
2026
*
@@ -25,7 +31,7 @@ class AssertUserSuccessLogin extends AbstractConstraint
2531
public function processAssert(User $user, Dashboard $dashboard)
2632
{
2733
$this->objectManager->create(
28-
\Magento\User\Test\TestStep\LoginUserOnBackendStep::class,
34+
$this->loginStep,
2935
['user' => $user]
3036
)->run();
3137
\PHPUnit\Framework\Assert::assertTrue(
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\User\Test\Constraint;
8+
9+
use Magento\User\Test\TestStep\LoginUserOnBackendWithErrorStep;
10+
11+
/**
12+
* Verify whether customer has logged in to the Backend with error alert.
13+
*/
14+
class AssertUserSuccessLoginWithError extends AssertUserSuccessLogin
15+
{
16+
/**
17+
* @var string
18+
*/
19+
protected $loginStep = LoginUserOnBackendWithErrorStep::class;
20+
}

dev/tests/functional/tests/app/Magento/User/Test/TestCase/UpdateAdminUserEntityTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
<constraint name="Magento\User\Test\Constraint\AssertUserInGrid" />
3333
<constraint name="Magento\User\Test\Constraint\AssertUserSuccessLogOut" />
3434
<constraint name="Magento\User\Test\Constraint\AssertUserSuccessLogin" />
35-
<constraint name="Magento\User\Test\Constraint\AssertUserRoleRestrictedAccess" />
35+
<constraint name="Magento\User\Test\Constraint\AssertUserRoleRestrictedAccessWithError" />
3636
</variation>
3737
</testCase>
3838
</config>

dev/tests/functional/tests/app/Magento/User/Test/TestCase/UpdateAdminUserRoleEntityTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ public function testUpdateAdminUserRolesEntity(
121121
*/
122122
public function tearDown()
123123
{
124+
sleep(3);
125+
$modalMessage = $this->dashboard->getModalMessage();
126+
if ($modalMessage->isVisible()) {
127+
$modalMessage->acceptAlert();
128+
}
124129
$this->dashboard->getAdminPanelHeader()->logOut();
125130
}
126131
}

dev/tests/functional/tests/app/Magento/User/Test/TestCase/UpdateAdminUserRoleEntityTest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
<constraint name="Magento\User\Test\Constraint\AssertRoleSuccessSaveMessage" />
3030
<constraint name="Magento\User\Test\Constraint\AssertRoleInGrid" />
3131
<constraint name="Magento\User\Test\Constraint\AssertUserSuccessLogOut" />
32-
<constraint name="Magento\User\Test\Constraint\AssertUserSuccessLogin" />
33-
<constraint name="Magento\User\Test\Constraint\AssertUserRoleRestrictedAccess" />
32+
<constraint name="Magento\User\Test\Constraint\AssertUserSuccessLoginWithError"/>
33+
<constraint name="Magento\User\Test\Constraint\AssertUserRoleRestrictedAccessWithError" />
3434
</variation>
3535
<variation name="UpdateAdminUserRoleEntityTestVariation3">
3636
<data name="user/dataset" xsi:type="string">custom_admin_with_default_role</data>
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\User\Test\TestStep;
8+
9+
use Magento\Backend\Test\Page\Adminhtml\Dashboard;
10+
use Magento\Mtf\Client\BrowserInterface;
11+
use Magento\Mtf\TestStep\TestStepInterface;
12+
13+
/**
14+
* Close access error modal message.
15+
*/
16+
class CloseErrorAlertStep implements TestStepInterface
17+
{
18+
/**
19+
* @var Dashboard
20+
*/
21+
private $dashboard;
22+
23+
/**
24+
* @var BrowserInterface
25+
*/
26+
private $browser;
27+
28+
/**
29+
* @param Dashboard $dashboard
30+
* @param BrowserInterface $browser
31+
*/
32+
public function __construct(
33+
Dashboard $dashboard,
34+
BrowserInterface $browser
35+
) {
36+
$this->dashboard = $dashboard;
37+
$this->browser = $browser;
38+
}
39+
40+
/**
41+
* @inheritdoc
42+
*/
43+
public function run()
44+
{
45+
$modalMessage = $this->dashboard->getModalMessage();
46+
$this->browser->waitUntil(
47+
function () use ($modalMessage) {
48+
return $modalMessage->isVisible() ? true : null;
49+
}
50+
);
51+
$modalMessage->acceptAlert();
52+
}
53+
}

dev/tests/functional/tests/app/Magento/User/Test/TestStep/LoginUserOnBackendStep.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class LoginUserOnBackendStep implements TestStepInterface
5050
*
5151
* @var BrowserInterface
5252
*/
53-
private $browser;
53+
protected $browser;
5454

5555
/**
5656
* Array of error messages on admin login form.
@@ -108,8 +108,6 @@ public function run()
108108
}
109109
}
110110
}
111-
112-
$this->dashboard->getSystemMessageDialog()->closePopup();
113111
}
114112

115113
/**

0 commit comments

Comments
 (0)