From 0abff19aa91e4ba8bffd99b963fdb2b33a3d7639 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Wed, 20 Nov 2019 17:09:52 +0100 Subject: [PATCH 1/2] Rename "Notification" to "Toast" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since Nextcloud 17 the proper name for the old built-in notifications is "Toast". Moreover, this will reduce ambiguity when using the "notification" term to refer to elements in the Notifications app. Signed-off-by: Daniel Calviño Sánchez --- tests/acceptance/config/behat.yml | 4 ++-- ...otificationContext.php => ToastContext.php} | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) rename tests/acceptance/features/bootstrap/{NotificationContext.php => ToastContext.php} (71%) diff --git a/tests/acceptance/config/behat.yml b/tests/acceptance/config/behat.yml index 182629701e887..53633d9345a4a 100644 --- a/tests/acceptance/config/behat.yml +++ b/tests/acceptance/config/behat.yml @@ -19,12 +19,12 @@ default: - FilesAppContext - FilesAppSharingContext - LoginPageContext - - NotificationContext - PublicShareContext - SearchContext - SettingsContext - SettingsMenuContext - ThemingAppContext + - ToastContext - UsersSettingsContext filters: tags: "~@apache" @@ -48,12 +48,12 @@ default: - FilesAppContext - FilesAppSharingContext - LoginPageContext - - NotificationContext - PublicShareContext - SearchContext - SettingsContext - SettingsMenuContext - ThemingAppContext + - ToastContext - UsersSettingsContext filters: tags: "@apache" diff --git a/tests/acceptance/features/bootstrap/NotificationContext.php b/tests/acceptance/features/bootstrap/ToastContext.php similarity index 71% rename from tests/acceptance/features/bootstrap/NotificationContext.php rename to tests/acceptance/features/bootstrap/ToastContext.php index 717de4302da58..28c81f8c50df9 100644 --- a/tests/acceptance/features/bootstrap/NotificationContext.php +++ b/tests/acceptance/features/bootstrap/ToastContext.php @@ -23,33 +23,33 @@ use Behat\Behat\Context\Context; -class NotificationContext implements Context, ActorAwareInterface { +class ToastContext implements Context, ActorAwareInterface { use ActorAware; /** * @return Locator */ - public static function notificationMessage($message) { + public static function toastMessage($message) { return Locator::forThe()->xpath("//*[contains(concat(' ', normalize-space(@class), ' '), ' toastify ') and normalize-space(text()) = '$message']")-> - descendantOf(self::notificationContainer())-> - describedAs("$message notification"); + descendantOf(self::toastContainer())-> + describedAs("$message toast"); } /** * @return Locator */ - private static function notificationContainer() { + private static function toastContainer() { return Locator::forThe()->id("content")-> - describedAs("Notification container"); + describedAs("Toast container"); } /** - * @Then I see that the :message notification is shown + * @Then I see that the :message toast is shown */ - public function iSeeThatTheNotificationIsShown($message) { + public function iSeeThatTheToastIsShown($message) { PHPUnit_Framework_Assert::assertTrue($this->actor->find( - self::notificationMessage($message), 10)->isVisible()); + self::toastMessage($message), 10)->isVisible()); } } From f402e234480cd9d18c6c90ef011968eb7abcd5dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Wed, 20 Nov 2019 21:00:05 +0100 Subject: [PATCH 2/2] 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 --- tests/acceptance/config/behat.yml | 2 + .../acceptance/features/app-comments.feature | 9 ++ .../features/app-files-sharing.feature | 32 +++--- .../bootstrap/NotificationsContext.php | 98 +++++++++++++++++++ tests/acceptance/run-local.sh | 5 + 5 files changed, 128 insertions(+), 18 deletions(-) create mode 100644 tests/acceptance/features/bootstrap/NotificationsContext.php diff --git a/tests/acceptance/config/behat.yml b/tests/acceptance/config/behat.yml index 53633d9345a4a..dfea50b3c5aad 100644 --- a/tests/acceptance/config/behat.yml +++ b/tests/acceptance/config/behat.yml @@ -19,6 +19,7 @@ default: - FilesAppContext - FilesAppSharingContext - LoginPageContext + - NotificationsContext - PublicShareContext - SearchContext - SettingsContext @@ -48,6 +49,7 @@ default: - FilesAppContext - FilesAppSharingContext - LoginPageContext + - NotificationsContext - PublicShareContext - SearchContext - SettingsContext diff --git a/tests/acceptance/features/app-comments.feature b/tests/acceptance/features/app-comments.feature index b57883d8ba8e3..001d0967c18a1 100644 --- a/tests/acceptance/features/app-comments.feature +++ b/tests/acceptance/features/app-comments.feature @@ -47,6 +47,7 @@ Feature: app-comments And I create a new comment with "Hello world" as message And I see a comment with "Hello world" as message When I act as Jane + And I accept the share for "shared.txt" in the notifications # The Files app is open again to reload the file list and the comments And I open the Files app And I open the details view for "shared.txt" @@ -63,6 +64,7 @@ Feature: app-comments And I share "shared.txt" with "user0" And I see that the file is shared with "user0" And I act as Jane + And I accept the share for "shared.txt" in the notifications # The Files app is open again to reload the file list And I open the Files app And I open the details view for "shared.txt" @@ -92,6 +94,7 @@ Feature: app-comments And I create a new comment with "Hello world" as message And I see a comment with "Hello world" as message When I act as Jane + And I accept the share for "shared.txt" in the notifications # The Files app is open again to reload the file list and the comments And I open the Files app Then I see that "shared.txt" has unread comments @@ -109,6 +112,7 @@ Feature: app-comments And I share "shared.txt" with "user0" And I see that the file is shared with "user0" And I act as Jane + And I accept the share for "shared.txt" in the notifications # The Files app is open again to reload the file list And I open the Files app And I open the details view for "shared.txt" @@ -137,6 +141,7 @@ Feature: app-comments And I create a new comment with "Hello world" as message And I see a comment with "Hello world" as message When I act as Jane + And I accept the share for "Folder" in the notifications # The Files app is open again to reload the file list and the comments And I open the Files app Then I see that "Folder" has unread comments @@ -154,6 +159,7 @@ Feature: app-comments And I share "Folder" with "user0" And I see that the file is shared with "user0" And I act as Jane + And I accept the share for "Folder" in the notifications # The Files app is open again to reload the file list And I open the Files app And I open the details view for "Folder" @@ -184,6 +190,7 @@ Feature: app-comments And I create a new comment with "Hello world" as message And I see a comment with "Hello world" as message When I act as Jane + And I accept the share for "Folder" in the notifications # The Files app is open again to reload the file list and the comments And I open the Files app And I enter in the folder named "Folder" @@ -202,6 +209,7 @@ Feature: app-comments And I share "Folder" with "user0" And I see that the file is shared with "user0" And I act as Jane + And I accept the share for "Folder" in the notifications # The Files app is open again to reload the file list And I open the Files app And I enter in the folder named "Folder" @@ -256,6 +264,7 @@ Feature: app-comments And I share "shared.txt" with "user0" And I see that the file is shared with "user0" And I act as Jane + And I accept the share for "shared.txt" in the notifications # The Files app is open again to reload the file list And I open the Files app And I open the details view for "shared.txt" diff --git a/tests/acceptance/features/app-files-sharing.feature b/tests/acceptance/features/app-files-sharing.feature index 401384816e853..15ed42aba6a84 100644 --- a/tests/acceptance/features/app-files-sharing.feature +++ b/tests/acceptance/features/app-files-sharing.feature @@ -11,6 +11,7 @@ Feature: app-files-sharing When I share "farewell.txt" with "user0" And I see that the file is shared with "user0" And I act as Jane + And I accept the share for "farewell.txt" in the notifications # The Files app is open again to reload the file list And I open the Files app Then I see that the file list contains a file named "farewell.txt" @@ -29,6 +30,7 @@ Feature: app-files-sharing When I share "welcome.txt" with "user0" And I see that the file is shared with "user0" And I act as Jane + And I accept the share for "welcome.txt" in the notifications # The Files app is open again to reload the file list And I open the Files app Then I see that the file list contains a file named "welcome (2).txt" @@ -38,24 +40,6 @@ Feature: app-files-sharing And I see that the "Sharing" tab in the details view is eventually loaded And I see that the file is shared with me by "admin" - Scenario: share a skeleton file with another user before first login - # If a file is shared with a user before her first login the skeleton would - # not have been created, so if the shared file has the same name as one from - # the skeleton the shared file will take its place and the skeleton file - # will not be added. - Given I act as John - And I am logged in as the admin - When I share "welcome.txt" with "user0" - And I see that the file is shared with "user0" - And I act as Jane - And I am logged in - Then I see that the file list contains a file named "welcome.txt" - And I open the details view for "welcome.txt" - And I see that the details view is open - And I open the "Sharing" tab in the details view - And I see that the "Sharing" tab in the details view is eventually loaded - And I see that the file is shared with me by "admin" - Scenario: reshare a file with another user Given I act as John And I am logged in as the admin @@ -69,11 +53,13 @@ Feature: app-files-sharing And I share "farewell.txt" with "user0" And I see that the file is shared with "user0" And I act as Jane + And I accept the share for "farewell.txt" in the notifications # The Files app is open again to reload the file list And I open the Files app When I share "farewell.txt" with "user1" And I see that the file is shared with "user1" And I act as Jim + And I accept the share for "farewell.txt" in the notifications # The Files app is open again to reload the file list And I open the Files app Then I see that the file list contains a file named "farewell.txt" @@ -94,6 +80,7 @@ Feature: app-files-sharing And I share "farewell.txt" with "user0" And I see that the file is shared with "user0" And I act as Jane + And I accept the share for "farewell.txt" in the notifications # The Files app is open again to reload the file list And I open the Files app And I share "farewell.txt" with "user1" @@ -119,6 +106,7 @@ Feature: app-files-sharing When I share "Shared folder" with "user0" And I see that the file is shared with "user0" And I act as Jane + And I accept the share for "Shared folder" in the notifications # The Files app is open again to reload the file list And I open the Files app Then I see that the file list contains a file named "Shared folder" @@ -142,6 +130,7 @@ Feature: app-files-sharing And I create a new folder named "Subfolder" And I see that the file list contains a file named "Subfolder" When I act as Jane + And I accept the share for "Shared folder" in the notifications # The Files app is open again to reload the file list And I open the Files app And I enter in the folder named "Shared folder" @@ -158,6 +147,7 @@ Feature: app-files-sharing And I share "Shared folder" with "user0" And I see that the file is shared with "user0" And I act as Jane + And I accept the share for "Shared folder" in the notifications # The Files app is open again to reload the file list And I open the Files app And I enter in the folder named "Shared folder" @@ -180,6 +170,7 @@ Feature: app-files-sharing And I share "Shared folder" with "user0" And I see that the file is shared with "user0" And I act as Jane + And I accept the share for "Shared folder" in the notifications # The Files app is open again to reload the file list And I open the Files app And I share "Shared folder" with "user1" @@ -188,6 +179,7 @@ Feature: app-files-sharing And I create a new folder named "Subfolder" And I see that the file list contains a file named "Subfolder" When I act as Jim + And I accept the share for "Shared folder" in the notifications # The Files app is open again to reload the file list And I open the Files app And I enter in the folder named "Shared folder" @@ -206,10 +198,12 @@ Feature: app-files-sharing And I share "Shared folder" with "user0" And I see that the file is shared with "user0" And I act as Jane + And I accept the share for "Shared folder" in the notifications # The Files app is open again to reload the file list And I open the Files app And I share "Shared folder" with "user1" And I act as Jim + And I accept the share for "Shared folder" in the notifications # The Files app is open again to reload the file list And I open the Files app And I enter in the folder named "Shared folder" @@ -232,6 +226,7 @@ Feature: app-files-sharing And I set the share with "user0" as not reshareable And I see that "user0" can not reshare the share When I act as Jane + And I accept the share for "Shared folder" in the notifications # The Files app is open again to reload the file list And I open the Files app Then I see that the file list contains a file named "Shared folder" @@ -258,6 +253,7 @@ Feature: app-files-sharing And I create a new folder named "Subfolder" And I see that the file list contains a file named "Subfolder" When I act as Jane + And I accept the share for "Shared folder" in the notifications # The Files app is open again to reload the file list And I open the Files app And I enter in the folder named "Shared folder" diff --git a/tests/acceptance/features/bootstrap/NotificationsContext.php b/tests/acceptance/features/bootstrap/NotificationsContext.php new file mode 100644 index 0000000000000..6f959f0468ce7 --- /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(); + } + +} diff --git a/tests/acceptance/run-local.sh b/tests/acceptance/run-local.sh index 548e9e9ceae69..cd63f2870965f 100755 --- a/tests/acceptance/run-local.sh +++ b/tests/acceptance/run-local.sh @@ -193,6 +193,11 @@ cd ../../ # server to make possible to run the Nextcloud server on Apache if needed. ln --symbolic $(pwd) /var/www/html +# Add Notifications app to the "apps" directory (unless it is already there). +if [ ! -e "apps/notifications" ]; then + (cd apps && git clone --depth 1 https://github.com/nextcloud/notifications) +fi + INSTALL_AND_CONFIGURE_SERVER_PARAMETERS="" if [ "$NEXTCLOUD_SERVER_DOMAIN" != "$DEFAULT_NEXTCLOUD_SERVER_DOMAIN" ]; then INSTALL_AND_CONFIGURE_SERVER_PARAMETERS+="--nextcloud-server-domain $NEXTCLOUD_SERVER_DOMAIN"