Skip to content

Commit

Permalink
IBX-1854: Updated Change Password scenario for 4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
micszo committed Mar 17, 2022
1 parent daef05e commit 021ab3b
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 6 deletions.
4 changes: 3 additions & 1 deletion features/personas/ChangePassword.feature
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ Feature: Verify that an User allowed to change password can change his password
Scenario: I can change my password
Given I open Login page in admin SiteAccess
And I log in as "UserPassword" with password "Passw0rd-42"
When I open "Change password" page in admin SiteAccess
When I go to user settings
And I switch to "My Account Settings" tab in User Settings
And I click on the change password button
And I change password from "Passw0rd-42" to "Passw0rd-43"
And I click on the edit action bar button "Update"
Then success notification that "Your password has been successfully changed." appears
Expand Down
2 changes: 2 additions & 0 deletions src/bundle/Resources/config/services/test/pages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,5 @@ services:
Ibexa\AdminUi\Behat\Page\RolesPage: ~

Ibexa\AdminUi\Behat\Page\ChangePasswordPage: ~

Ibexa\AdminUi\Behat\Page\UserSettingsPage: ~
8 changes: 8 additions & 0 deletions src/lib/Behat/BrowserContext/NavigationContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ public function tryToOpenPage(string $pageName): void
$this->pageRegistry->get($pageName)->tryToOpen('admin');
}

/**
* @Given I go to user settings
*/
public function iGoToUserSettings()
{
$this->upperMenu->chooseFromUserDropdown('User Settings');
}

/**
* @Then /^I should be on "?([^\"]*)"? page$/
*/
Expand Down
25 changes: 22 additions & 3 deletions src/lib/Behat/BrowserContext/UserPreferencesContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,34 @@

use Behat\Behat\Context\Context;
use Ibexa\AdminUi\Behat\Page\ChangePasswordPage;
use Ibexa\AdminUi\Behat\Page\UserSettingsPage;

class UserPreferencesContext implements Context
{
/** @var \Ibexa\AdminUi\Behat\Page\ChangePasswordPage */
private $changePasswordPage;
private ChangePasswordPage $changePasswordPage;

public function __construct(ChangePasswordPage $changePasswordPage)
private UserSettingsPage $userSettingsPage;

public function __construct(ChangePasswordPage $changePasswordPage, UserSettingsPage $userSettingsPage)
{
$this->changePasswordPage = $changePasswordPage;
$this->userSettingsPage = $userSettingsPage;
}

/**
* @Given I switch to :tabName tab in User Settings
*/
public function iSwitchToTabInUserSettings($tabName): void
{
$this->userSettingsPage->switchTab($tabName);
}

/**
* @Given I click on the change password button
*/
public function iClickChangePasswordButton(): void
{
$this->userSettingsPage->changePassword();
}

/**
Expand Down
3 changes: 1 addition & 2 deletions src/lib/Behat/Page/ChangePasswordPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@

class ChangePasswordPage extends Page
{
/** @var \Ibexa\AdminUi\Behat\Component\ContentActionsMenu */
private $contentActionsMenu;
private ContentActionsMenu $contentActionsMenu;

public function __construct(Session $session, Router $router, ContentActionsMenu $contentActionsMenu)
{
Expand Down
65 changes: 65 additions & 0 deletions src/lib/Behat/Page/UserSettingsPage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
namespace Ibexa\AdminUi\Behat\Page;

use Behat\Mink\Session;
use Ibexa\AdminUi\Behat\Component\ContentActionsMenu;
use Ibexa\AdminUi\Behat\Component\TableNavigationTab;
use Ibexa\Behat\Browser\Element\Criterion\ElementTextCriterion;
use Ibexa\Behat\Browser\Locator\VisibleCSSLocator;
use Ibexa\Behat\Browser\Page\Page;
use Ibexa\Behat\Browser\Routing\Router;

class UserSettingsPage extends Page
{
private ContentActionsMenu $contentActionsMenu;

private TableNavigationTab $tableNavigationTab;

public function __construct(Session $session, Router $router, ContentActionsMenu $contentActionsMenu, TableNavigationTab $tableNavigationTab)
{
parent::__construct($session, $router);
$this->contentActionsMenu = $contentActionsMenu;
$this->tableNavigationTab = $tableNavigationTab;
}

public function verifyIsLoaded(): void
{
$this->contentActionsMenu->verifyIsLoaded();
$this->getHTMLPage()->find($this->getLocator('title'))->assert()->textEquals('User Settings');
}

public function switchTab(string $tabName): void
{
$this->tableNavigationTab->goToTab($tabName);
}

public function changePassword(): void
{
$this->getHTMLPage()
->findAll($this->getLocator('button'))
->getByCriterion(new ElementTextCriterion('Change password'))
->click();
}

protected function specifyLocators(): array
{
return [
new VisibleCSSLocator('button', '.ibexa-btn'),
];
}

protected function getRoute(): string
{
return '/user/settings/list';
}

public function getName(): string
{
return 'User Settings';
}
}

0 comments on commit 021ab3b

Please sign in to comment.