From f3a06259e4a58ba7e7b6b55bb595c98867add1bb Mon Sep 17 00:00:00 2001 From: "John Molakvoæ (skjnldsv)" Date: Wed, 9 May 2018 16:53:16 +0200 Subject: newt acceptance tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- .../features/bootstrap/UsersSettingsContext.php | 46 ++++++++++++++++++++++ tests/acceptance/features/users.feature | 21 ++++++++++ 2 files changed, 67 insertions(+) create mode 100644 tests/acceptance/features/users.feature diff --git a/tests/acceptance/features/bootstrap/UsersSettingsContext.php b/tests/acceptance/features/bootstrap/UsersSettingsContext.php index d65c58ecabe..1f488e4f52b 100644 --- a/tests/acceptance/features/bootstrap/UsersSettingsContext.php +++ b/tests/acceptance/features/bootstrap/UsersSettingsContext.php @@ -91,6 +91,23 @@ class UsersSettingsContext implements Context, ActorAwareInterface { describedAs("Password input for user $user in Users Settings"); } + /** + * @return Locator + */ + public static function actionsMenuOf($user) { + return Locator::forThe()->css(".icon-more")->descendantOf(self::rowForUser($user))-> + describedAs("Actions menu for user $user in Users Settings"); + } + + /** + * @return Locator + */ + public static function theAction($action, $user) { + return Locator::forThe()->xpath("//button/span[normalize-space() = '$action']/..")-> + descendantOf(self::rowForUser($user))-> + describedAs("$action action for the user $user"); + } + /** * @When I click the New user button */ @@ -98,6 +115,20 @@ class UsersSettingsContext implements Context, ActorAwareInterface { $this->actor->find(self::newUserButton())->click(); } + /** + * @When I click the $action action in the $user actions menu + */ + public function iClickTheAction($action, $user) { + $this->actor->find(self::theAction($action, $user))->click(); + } + + /** + * @When I open the actions menu for the user :user + */ + public function iOpenTheActionsMenuOf($user) { + $this->actor->find(self::actionsMenuOf($user))->click(); + } + /** * @When I create user :user with password :password */ @@ -122,6 +153,13 @@ class UsersSettingsContext implements Context, ActorAwareInterface { PHPUnit_Framework_Assert::assertNotNull($this->actor->find(self::rowForUser($user), 10)); } + /** + * @Then I see that the list of users does not contains the user :user + */ + public function iSeeThatTheListOfUsersDoesNotContainsTheUser($user) { + PHPUnit_Framework_Assert::assertNull($this->actor->find(self::rowForUser($user), 10)); + } + /** * @Then I see that the new user form is shown */ @@ -130,4 +168,12 @@ class UsersSettingsContext implements Context, ActorAwareInterface { $this->actor->find(self::newUserForm(), 10)->isVisible()); } + /** + * @Then I see the $action action in the $user actions menu + */ + public function iSeeTheAction($action, $user) { + PHPUnit_Framework_Assert::assertTrue( + $this->actor->find(self::theAction($action, $user), 10)->isVisible()); + } + } diff --git a/tests/acceptance/features/users.feature b/tests/acceptance/features/users.feature new file mode 100644 index 00000000000..3b916285501 --- /dev/null +++ b/tests/acceptance/features/users.feature @@ -0,0 +1,21 @@ +Feature: users + + Scenario: create a new user + Given I act as Jane + And I am logged in as the admin + And I open the User settings + And I click the New user button + And I see that the new user form is shown + When I create user unknownUser with password 123456acb + Then I see that the list of users contains the user unknownUser + + Scenario: delete a user + Given I act as Jane + And I am logged in as the admin + And I open the User settings + And I see that the list of users contains the user user0 + And I open the actions menu for the user user0 + And I see the "Delete user" action in the user0 actions menu + When I click the "Delete user" action in the user0 actions menu + Then I see that the list of users does not contains the user user0 + -- cgit v1.2.3