aboutsummaryrefslogtreecommitdiffstats
path: root/tests/acceptance/features/bootstrap/AppSettingsContext.php
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2018-05-09 19:53:08 +0200
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2018-05-16 09:50:23 +0200
commit07a592bd27e297390b8d47a26381d38429cd13b4 (patch)
tree63cee6430f3e0d6223522ba31a5dcbcaa0353672 /tests/acceptance/features/bootstrap/AppSettingsContext.php
parentf3a06259e4a58ba7e7b6b55bb595c98867add1bb (diff)
downloadnextcloud-server-07a592bd27e297390b8d47a26381d38429cd13b4.tar.gz
nextcloud-server-07a592bd27e297390b8d47a26381d38429cd13b4.zip
Users list acceptance tests
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'tests/acceptance/features/bootstrap/AppSettingsContext.php')
-rw-r--r--tests/acceptance/features/bootstrap/AppSettingsContext.php101
1 files changed, 101 insertions, 0 deletions
diff --git a/tests/acceptance/features/bootstrap/AppSettingsContext.php b/tests/acceptance/features/bootstrap/AppSettingsContext.php
new file mode 100644
index 00000000000..6b77b3aac00
--- /dev/null
+++ b/tests/acceptance/features/bootstrap/AppSettingsContext.php
@@ -0,0 +1,101 @@
+<?php
+
+/**
+ * @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com)
+ * @copyright Copyright (c) 2018, John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+use Behat\Behat\Context\Context;
+
+class AppSettingsContext implements Context, ActorAwareInterface {
+
+ use ActorAware;
+
+ /**
+ * @return Locator
+ */
+ public static function appSettings() {
+ return Locator::forThe()->id("app-settings")->
+ describedAs("App settings");
+ }
+ /**
+ * @return Locator
+ */
+ public static function appSettingsContent() {
+ return Locator::forThe()->id("app-settings-content")->
+ descendantOf(self::appSettings())->
+ describedAs("App settings");
+ }
+
+ /**
+ * @return Locator
+ */
+ public static function appSettingsOpenButton() {
+ return Locator::forThe()->xpath("//div[@id = 'app-settings-header']/button")->
+ descendantOf(self::appSettings())->
+ describedAs("The button to open the app settings");
+ }
+
+ /**
+ * @return Locator
+ */
+ public static function checkboxInTheSettings($id) {
+ return Locator::forThe()->xpath("//input[@id = '$id']")->
+ descendantOf(self::appSettingsContent())->
+ describedAs("The $id checkbox in the settings");
+ }
+
+ /**
+ * @return Locator
+ */
+ public static function checkboxLabelInTheSettings($id) {
+ return Locator::forThe()->xpath("//label[@for = '$id']")->
+ descendantOf(self::appSettingsContent())->
+ describedAs("The label for the $id checkbox in the settings");
+ }
+
+ /**
+ * @Given I open the settings
+ */
+ public function iOpenTheSettings() {
+ $this->actor->find(self::appSettingsOpenButton())->click();
+ }
+
+ /**
+ * @Given I toggle the :id checkbox in the settings
+ */
+ public function iToggleTheCheckboxInTheSettingsTo($id) {
+ $locator = self::CheckboxInTheSettings($id);
+
+ // If locator is not visible, fallback to label
+ if (!$this->actor->find(self::CheckboxInTheSettings($id))->isVisible()) {
+ $locator = self::checkboxLabelInTheSettings($id);
+ }
+
+ $this->actor->find($locator)->click();
+ }
+
+ /**
+ * @Then I see that the settings are opened
+ */
+ public function iSeeThatTheSettingsAreOpened() {
+ WaitFor::elementToBeEventuallyShown($this->actor, self::appSettingsContent());
+ }
+
+}