From 7aaf5e6a4c8eefe315d2a3399ac73acf90a6dfef Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= <danxuliu@gmail.com>
Date: Fri, 23 Nov 2018 12:29:30 +0100
Subject: [PATCH] Add acceptance test for resharing a file with another user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

To reshare a file there must be at least three enabled users in the
system; although it would be possible to run the steps to create a third
user in the scenarios that need it for convenience a third enabled user
besides "admin" and "user0" was added to the default setup.

In a similar way, a new step was added too to login as a given user
name, similar to the steps to log in as "user0" and as "admin".

Finally, another actor, "Jim", was introduced for those scenarios which
should be played by three standard actors (that is, without a special
configuration like "Rubeus").

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
---
 tests/acceptance/config/behat.yml             |  3 +++
 tests/acceptance/features/app-files.feature   | 27 +++++++++++++++++++
 .../features/bootstrap/LoginPageContext.php   |  9 +++++++
 tests/acceptance/installAndConfigureServer.sh |  1 +
 4 files changed, 40 insertions(+)

diff --git a/tests/acceptance/config/behat.yml b/tests/acceptance/config/behat.yml
index d1489a00864..3108ea41407 100644
--- a/tests/acceptance/config/behat.yml
+++ b/tests/acceptance/config/behat.yml
@@ -63,6 +63,9 @@ default:
         Jane:
           selenium2:
             wd_host: %selenium.server%
+        Jim:
+          selenium2:
+            wd_host: %selenium.server%
         Rubeus:
           # Rubeus uses a browser that has CSS grid support.
           selenium2:
diff --git a/tests/acceptance/features/app-files.feature b/tests/acceptance/features/app-files.feature
index b894d2bb839..e037bc1a36e 100644
--- a/tests/acceptance/features/app-files.feature
+++ b/tests/acceptance/features/app-files.feature
@@ -351,6 +351,33 @@ Feature: app-files
     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
+    And I act as Jane
+    And I am logged in
+    And I act as Jim
+    And I am logged in as "user1"
+    And I act as John
+    And I rename "welcome.txt" to "farewell.txt"
+    And I see that the file list contains a file named "farewell.txt"
+    And I share "farewell.txt" with "user0"
+    And I see that the file is shared with "user0"
+    And I act as Jane
+    # 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
+    # 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"
+    And I open the details view for "farewell.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 "user0"
+
   Scenario: share an empty folder with another user
     Given I act as John
     And I am logged in as the admin
diff --git a/tests/acceptance/features/bootstrap/LoginPageContext.php b/tests/acceptance/features/bootstrap/LoginPageContext.php
index df7944aa912..048d23d9295 100644
--- a/tests/acceptance/features/bootstrap/LoginPageContext.php
+++ b/tests/acceptance/features/bootstrap/LoginPageContext.php
@@ -131,6 +131,15 @@ class LoginPageContext implements Context, ActorAwareInterface {
 		$this->filesAppContext->iSeeThatTheCurrentPageIsTheFilesApp();
 	}
 
+	/**
+	 * @Given I am logged in as :userName
+	 */
+	public function iAmLoggedInAs($userName) {
+		$this->featureContext->iVisitTheHomePage();
+		$this->iLogInWithUserAndPassword($userName, "123456acb");
+		$this->filesAppContext->iSeeThatTheCurrentPageIsTheFilesApp();
+	}
+
 	/**
 	 * @Given I am logged in as the admin
 	 */
diff --git a/tests/acceptance/installAndConfigureServer.sh b/tests/acceptance/installAndConfigureServer.sh
index 98de72bf45e..d24405fa448 100755
--- a/tests/acceptance/installAndConfigureServer.sh
+++ b/tests/acceptance/installAndConfigureServer.sh
@@ -35,6 +35,7 @@ fi
 php occ maintenance:install --admin-pass=admin
 
 OC_PASS=123456acb php occ user:add --password-from-env user0
+OC_PASS=123456acb php occ user:add --password-from-env user1
 OC_PASS=123456acb php occ user:add --password-from-env disabledUser
 php occ user:disable disabledUser
 
-- 
GitLab