diff --git a/behat_suites.yml b/behat_suites.yml index b309ba3c8d..8d46d60ecd 100644 --- a/behat_suites.yml +++ b/behat_suites.yml @@ -93,3 +93,4 @@ adminui: - EzSystems\EzPlatformAdminUi\Behat\BusinessContext\NotificationContext - EzSystems\EzPlatformAdminUi\Behat\BusinessContext\TrashContext - EzSystems\EzPlatformAdminUi\Behat\BusinessContext\UDWContext + - EzSystems\EzPlatformAdminUi\Behat\BusinessContext\UserPreferencesContext diff --git a/features/personas/ChangePassword.feature b/features/personas/ChangePassword.feature new file mode 100644 index 0000000000..c06f4e5165 --- /dev/null +++ b/features/personas/ChangePassword.feature @@ -0,0 +1,16 @@ +@javascript @changePassword +Feature: Verify that an User allowed to change password can change his password + + Scenario: I can change my password + Given I open Login page + And I log in as "UserPassword" with password "Passw0rd-42" + When I go to change my password + 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 + And I should be on Dashboard page + + Scenario: I can log in with new password + Given I open Login page + When I log in as "UserPassword" with password "Passw0rd-43" + Then I should be on Dashboard page diff --git a/src/lib/Behat/BusinessContext/NavigationContext.php b/src/lib/Behat/BusinessContext/NavigationContext.php index d996accd43..aa7091d8f1 100644 --- a/src/lib/Behat/BusinessContext/NavigationContext.php +++ b/src/lib/Behat/BusinessContext/NavigationContext.php @@ -144,6 +144,16 @@ public function iGoToUserNotifications() $upperMenu->chooseFromUserDropdown('View Notifications'); } + /** + * @Given I go to change my password + * @Given I go to change my password in user preferences + */ + public function iGoToChangeMyPassword() + { + $upperMenu = ElementFactory::createElement($this->utilityContext, UpperMenu::ELEMENT_NAME); + $upperMenu->chooseFromUserDropdown('Change password'); + } + /** * @Then I should be redirected to root in default view */ diff --git a/src/lib/Behat/BusinessContext/UserPreferencesContext.php b/src/lib/Behat/BusinessContext/UserPreferencesContext.php new file mode 100644 index 0000000000..5f8fa45f79 --- /dev/null +++ b/src/lib/Behat/BusinessContext/UserPreferencesContext.php @@ -0,0 +1,25 @@ +utilityContext, ChangePasswordPage::PAGE_NAME); + $passwordPage->verifyIsLoaded(); + $passwordPage->setOldPassword($oldPassword); + $passwordPage->setNewPassword($newPassword); + $passwordPage->setConfirmPassword($newPassword); + } +} diff --git a/src/lib/Behat/PageObject/ChangePasswordPage.php b/src/lib/Behat/PageObject/ChangePasswordPage.php new file mode 100644 index 0000000000..e2e2bb22f2 --- /dev/null +++ b/src/lib/Behat/PageObject/ChangePasswordPage.php @@ -0,0 +1,75 @@ +rightMenu = ElementFactory::createElement($this->context, RightMenu::ELEMENT_NAME); + $this->siteAccess = 'admin'; + $this->route = '/user/change-password'; + $this->pageTitleLocator = '.ez-header h1'; + $this->fields = [ + 'oldPassword' => '#user_password_change_oldPassword', + 'newPassword' => '#user_password_change_newPassword_first', + 'confirmPassword' => '#user_password_change_newPassword_second', + ]; + } + + public function verifyElements(): void + { + $this->rightMenu->verifyVisibility(); + } + + public function verifyRoute(): void + { + $expectedRoute = '/' . $this->siteAccess . $this->route; + Assert::assertContains($expectedRoute, $this->getCurrentRoute()); + } + + public function verifyTitle(): void + { + Assert::assertContains($this::PAGE_NAME, $this->getPageTitle()); + } + + public function verifyIsLoaded(): void + { + $this->verifyElements(); + $this->verifyRoute(); + $this->verifyTitle(); + } + + public function setOldPassword(string $value): void + { + $this->context->findElement($this->fields['oldPassword'])->setValue($value); + } + + public function setNewPassword(string $value): void + { + $this->context->findElement($this->fields['newPassword'])->setValue($value); + } + + public function setConfirmPassword(string $value): void + { + $this->context->findElement($this->fields['confirmPassword'])->setValue($value); + } +} diff --git a/src/lib/Behat/PageObject/PlatformPageObjectFactory.php b/src/lib/Behat/PageObject/PlatformPageObjectFactory.php index 3a186f415b..3ef92863ee 100644 --- a/src/lib/Behat/PageObject/PlatformPageObjectFactory.php +++ b/src/lib/Behat/PageObject/PlatformPageObjectFactory.php @@ -62,6 +62,8 @@ public static function createPage(UtilityContext $context, string $pageName, ?st return new SearchPage($context); case UserCreationPage::PAGE_NAME: return new UserCreationPage($context); + case ChangePasswordPage::PAGE_NAME: + return new ChangePasswordPage($context); default: throw new \InvalidArgumentException(sprintf('Unrecognised page name: %s', $pageName)); }