summaryrefslogtreecommitdiffstats
path: root/tests/acceptance/features/bootstrap
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2019-11-20 21:00:05 +0100
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2019-11-20 21:15:46 +0100
commitf402e234480cd9d18c6c90ef011968eb7abcd5dc (patch)
tree7568f23103df689f47c0f9510340fe192953448d /tests/acceptance/features/bootstrap
parent0abff19aa91e4ba8bffd99b963fdb2b33a3d7639 (diff)
downloadnextcloud-server-f402e234480cd9d18c6c90ef011968eb7abcd5dc.tar.gz
nextcloud-server-f402e234480cd9d18c6c90ef011968eb7abcd5dc.zip
Accept incoming shares in acceptance tests
Incoming shares are no longer automatically added to the file list of the sharee. Instead, the user now needs to explictly accept the share. Currently shares can be accepted only from the Notifications app, so it must be explicitly cloned before installing Nextcloud if it is not found in the "apps" directory. Note that the development branches are already built, so there is no need to explicitly build the app. With the new sharing behaviour the "share a skeleton file with another user before first login" scenario is no longer valid (as the user will need to log in to accept the share, so at that point the skeleton is already created), so it was removed. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'tests/acceptance/features/bootstrap')
-rw-r--r--tests/acceptance/features/bootstrap/NotificationsContext.php98
1 files changed, 98 insertions, 0 deletions
diff --git a/tests/acceptance/features/bootstrap/NotificationsContext.php b/tests/acceptance/features/bootstrap/NotificationsContext.php
new file mode 100644
index 00000000000..6f959f0468c
--- /dev/null
+++ b/tests/acceptance/features/bootstrap/NotificationsContext.php
@@ -0,0 +1,98 @@
+<?php
+
+/**
+ *
+ * @copyright Copyright (c) 2019, Daniel Calviño Sánchez (danxuliu@gmail.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 NotificationsContext implements Context, ActorAwareInterface {
+
+ use ActorAware;
+
+ /**
+ * @return Locator
+ */
+ public static function notificationsButton() {
+ return Locator::forThe()->css("#header .notifications .notifications-button")->
+ describedAs("Notifications button in the header");
+ }
+
+ /**
+ * @return Locator
+ */
+ public static function notificationsContainer() {
+ return Locator::forThe()->css("#header .notifications .notification-container")->
+ describedAs("Notifications container");
+ }
+
+ /**
+ * @return Locator
+ */
+ public static function incomingShareNotificationForFile($fileName) {
+ return Locator::forThe()->xpath("//div[contains(concat(' ', normalize-space(@class), ' '), ' notification ') and //div[starts-with(normalize-space(), 'You received $fileName as a share by')]]")->
+ descendantOf(self::notificationsContainer())->
+ describedAs("Notification of incoming share for file $fileName");
+ }
+
+ /**
+ * @return Locator
+ */
+ public static function actionsInIncomingShareNotificationForFile($fileName) {
+ return Locator::forThe()->css(".notification-actions")->
+ descendantOf(self::incomingShareNotificationForFile($fileName))->
+ describedAs("Actions in notification of incoming share for file $fileName");
+ }
+
+ /**
+ * @return Locator
+ */
+ public static function actionInIncomingShareNotificationForFile($fileName, $action) {
+ return Locator::forThe()->xpath("//button[normalize-space() = '$action']")->
+ descendantOf(self::actionsInIncomingShareNotificationForFile($fileName))->
+ describedAs("$action button in notification of incoming share for file $fileName");
+ }
+
+ /**
+ * @return Locator
+ */
+ public static function acceptButtonInIncomingShareNotificationForFile($fileName) {
+ return self::actionInIncomingShareNotificationForFile($fileName, 'Accept');
+ }
+
+ /**
+ * @Given I accept the share for :fileName in the notifications
+ */
+ public function iAcceptTheShareForInTheNotifications($fileName) {
+ $this->actor->find(self::notificationsButton(), 10)->click();
+
+ // Notifications are refreshed every 30 seconds, so wait a bit longer.
+ // As the waiting is long enough already the find timeout multiplier is
+ // capped at 2 when finding notifications.
+ $findTimeoutMultiplier = $this->actor->getFindTimeoutMultiplier();
+ $this->actor->setFindTimeoutMultiplier(max(2, $findTimeoutMultiplier));
+ $this->actor->find(self::acceptButtonInIncomingShareNotificationForFile($fileName), 35)->click();
+ $this->actor->setFindTimeoutMultiplier($findTimeoutMultiplier);
+
+ // Hide the notifications again
+ $this->actor->find(self::notificationsButton(), 10)->click();
+ }
+
+}