From f402e234480cd9d18c6c90ef011968eb7abcd5dc Mon Sep 17 00:00:00 2001 From: Daniel Calviño Sánchez Date: Wed, 20 Nov 2019 21:00:05 +0100 Subject: Accept incoming shares in acceptance tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../features/bootstrap/NotificationsContext.php | 98 ++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 tests/acceptance/features/bootstrap/NotificationsContext.php (limited to 'tests/acceptance/features/bootstrap') 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 @@ +. + * + */ + +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(); + } + +} -- cgit v1.2.3