From 021ab3be5f7ac82b4b03b7eb59efe2c256e53cdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Szo=C5=82tysek?= Date: Wed, 9 Mar 2022 13:06:47 +0100 Subject: [PATCH] IBX-1854: Updated Change Password scenario for 4.0 --- features/personas/ChangePassword.feature | 4 +- .../Resources/config/services/test/pages.yaml | 2 + .../BrowserContext/NavigationContext.php | 8 +++ .../BrowserContext/UserPreferencesContext.php | 25 ++++++- src/lib/Behat/Page/ChangePasswordPage.php | 3 +- src/lib/Behat/Page/UserSettingsPage.php | 65 +++++++++++++++++++ 6 files changed, 101 insertions(+), 6 deletions(-) create mode 100644 src/lib/Behat/Page/UserSettingsPage.php diff --git a/features/personas/ChangePassword.feature b/features/personas/ChangePassword.feature index c98d972b12..8c58ad2fb7 100644 --- a/features/personas/ChangePassword.feature +++ b/features/personas/ChangePassword.feature @@ -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 diff --git a/src/bundle/Resources/config/services/test/pages.yaml b/src/bundle/Resources/config/services/test/pages.yaml index a9c57adff0..6006b5c922 100644 --- a/src/bundle/Resources/config/services/test/pages.yaml +++ b/src/bundle/Resources/config/services/test/pages.yaml @@ -55,3 +55,5 @@ services: Ibexa\AdminUi\Behat\Page\RolesPage: ~ Ibexa\AdminUi\Behat\Page\ChangePasswordPage: ~ + + Ibexa\AdminUi\Behat\Page\UserSettingsPage: ~ diff --git a/src/lib/Behat/BrowserContext/NavigationContext.php b/src/lib/Behat/BrowserContext/NavigationContext.php index f69bba76a0..1fae56171e 100644 --- a/src/lib/Behat/BrowserContext/NavigationContext.php +++ b/src/lib/Behat/BrowserContext/NavigationContext.php @@ -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$/ */ diff --git a/src/lib/Behat/BrowserContext/UserPreferencesContext.php b/src/lib/Behat/BrowserContext/UserPreferencesContext.php index b8fb7da14c..cc1050447b 100644 --- a/src/lib/Behat/BrowserContext/UserPreferencesContext.php +++ b/src/lib/Behat/BrowserContext/UserPreferencesContext.php @@ -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(); } /** diff --git a/src/lib/Behat/Page/ChangePasswordPage.php b/src/lib/Behat/Page/ChangePasswordPage.php index 426deb3119..a99c3650d4 100644 --- a/src/lib/Behat/Page/ChangePasswordPage.php +++ b/src/lib/Behat/Page/ChangePasswordPage.php @@ -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) { diff --git a/src/lib/Behat/Page/UserSettingsPage.php b/src/lib/Behat/Page/UserSettingsPage.php new file mode 100644 index 0000000000..8cac8c16f9 --- /dev/null +++ b/src/lib/Behat/Page/UserSettingsPage.php @@ -0,0 +1,65 @@ +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'; + } +}