diff options
author | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2017-04-04 17:24:30 +0200 |
---|---|---|
committer | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2017-04-19 08:26:03 +0200 |
commit | c4613733eb4076f6e641e27e953365feb88e98ee (patch) | |
tree | 87085429f5919e818cd0cdb2a10158c8fd6a6340 | |
parent | 1203369ea6a6bb1a9afb03fd390f1c6342f54aa9 (diff) | |
download | nextcloud-server-c4613733eb4076f6e641e27e953365feb88e98ee.tar.gz nextcloud-server-c4613733eb4076f6e641e27e953365feb88e98ee.zip |
Add acceptance tests related to access levels
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
-rw-r--r-- | build/acceptance/features/access-levels.feature | 21 | ||||
-rw-r--r-- | build/acceptance/features/bootstrap/SettingsMenuContext.php | 52 |
2 files changed, 70 insertions, 3 deletions
diff --git a/build/acceptance/features/access-levels.feature b/build/acceptance/features/access-levels.feature new file mode 100644 index 00000000000..57998899a57 --- /dev/null +++ b/build/acceptance/features/access-levels.feature @@ -0,0 +1,21 @@ +Feature: access-levels + + Scenario: regular users can not see admin-level items in the Settings menu + Given I am logged in + When I open the Settings menu + Then I see that the Settings menu is shown + And I see that the "Personal" item in the Settings menu is shown + And I see that the "Admin" item in the Settings menu is not shown + And I see that the "Users" item in the Settings menu is not shown + And I see that the "Help" item in the Settings menu is shown + And I see that the "Log out" item in the Settings menu is shown + + Scenario: admin users can see admin-level items in the Settings menu + Given I am logged in as the admin + When I open the Settings menu + Then I see that the Settings menu is shown + And I see that the "Personal" item in the Settings menu is shown + And I see that the "Admin" item in the Settings menu is shown + And I see that the "Users" item in the Settings menu is shown + And I see that the "Help" item in the Settings menu is shown + And I see that the "Log out" item in the Settings menu is shown diff --git a/build/acceptance/features/bootstrap/SettingsMenuContext.php b/build/acceptance/features/bootstrap/SettingsMenuContext.php index 78a29b08a10..9ce8df4caef 100644 --- a/build/acceptance/features/bootstrap/SettingsMenuContext.php +++ b/build/acceptance/features/bootstrap/SettingsMenuContext.php @@ -38,6 +38,14 @@ class SettingsMenuContext implements Context, ActorAwareInterface { /** * @return Locator */ + public static function settingsMenu() { + return Locator::forThe()->id("expanddiv")->descendantOf(self::settingsMenuButton())-> + describedAs("Settings menu"); + } + + /** + * @return Locator + */ public static function usersMenuItem() { return self::menuItemFor("Users"); } @@ -53,15 +61,23 @@ class SettingsMenuContext implements Context, ActorAwareInterface { * @return Locator */ private static function menuItemFor($itemText) { - return Locator::forThe()->content($itemText)->descendantOf(self::settingsMenuButton())-> + return Locator::forThe()->content($itemText)->descendantOf(self::settingsMenu())-> describedAs($itemText . " item in Settings menu"); } /** + * @When I open the Settings menu + */ + public function iOpenTheSettingsMenu() { + $this->actor->find(self::settingsMenuButton(), 10)->click(); + } + + /** * @When I open the User settings */ public function iOpenTheUserSettings() { - $this->actor->find(self::settingsMenuButton(), 10)->click(); + $this->iOpenTheSettingsMenu(); + $this->actor->find(self::usersMenuItem(), 2)->click(); } @@ -69,8 +85,38 @@ class SettingsMenuContext implements Context, ActorAwareInterface { * @When I log out */ public function iLogOut() { - $this->actor->find(self::settingsMenuButton(), 10)->click(); + $this->iOpenTheSettingsMenu(); + $this->actor->find(self::logOutMenuItem(), 2)->click(); } + /** + * @Then I see that the Settings menu is shown + */ + public function iSeeThatTheSettingsMenuIsShown() { + PHPUnit_Framework_Assert::assertTrue( + $this->actor->find(self::settingsMenu(), 10)->isVisible()); + } + + /** + * @Then I see that the :itemText item in the Settings menu is shown + */ + public function iSeeThatTheItemInTheSettingsMenuIsShown($itemText) { + PHPUnit_Framework_Assert::assertTrue( + $this->actor->find(self::menuItemFor($itemText), 10)->isVisible()); + } + + /** + * @Then I see that the :itemText item in the Settings menu is not shown + */ + public function iSeeThatTheItemInTheSettingsMenuIsNotShown($itemText) { + $this->iSeeThatTheSettingsMenuIsShown(); + + try { + PHPUnit_Framework_Assert::assertFalse( + $this->actor->find(self::menuItemFor($itemText))->isVisible()); + } catch (NoSuchElementException $exception) { + } + } + } |