Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBX-1854: Updated Change Password scenario for 4.0 #357

Merged
merged 1 commit into from
Mar 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As in UserPreferencesContext, maybe function here can be more precise.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO it's fine as it is currently: the usage is $this->userSettingsPage->switchTab(...), which provides enough context about the action that's happening

{
$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';
}
}