Skip to content

Commit 2f20584

Browse files
danxuliubackportbot[bot]
authored andcommitted
Add acceptance tests for reshares when resharing is disabled
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
1 parent 3a833fd commit 2f20584

File tree

2 files changed

+150
-0
lines changed

2 files changed

+150
-0
lines changed

tests/acceptance/features/app-files-sharing.feature

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,110 @@ Feature: app-files-sharing
246246
And I enter in the folder named "Shared folder"
247247
Then I see that the file list contains a file named "Subfolder"
248248

249+
Scenario: sharer does not see resharing option for a folder if resharing is disabled in the settings after the share is created
250+
Given I am logged in as the admin
251+
And I create a new folder named "Shared folder"
252+
And I see that the file list contains a file named "Shared folder"
253+
And I share "Shared folder" with "user0"
254+
And I see that the file is shared with "user0"
255+
When I visit the settings page
256+
And I open the "Sharing" section of the "Administration" group
257+
And I disable resharing
258+
And I see that resharing is disabled
259+
Then I open the Files app
260+
And I open the details view for "Shared folder"
261+
And I see that the details view is open
262+
And I open the "Sharing" tab in the details view
263+
And I see that the "Sharing" tab in the details view is eventually loaded
264+
And I see that resharing for "user0" is not available
265+
266+
Scenario: sharee can not reshare a folder if resharing is disabled in the settings after the share is created
267+
Given I act as John
268+
And I am logged in as the admin
269+
And I act as Jane
270+
And I am logged in
271+
And I act as John
272+
And I create a new folder named "Shared folder"
273+
And I see that the file list contains a file named "Shared folder"
274+
And I share "Shared folder" with "user0"
275+
And I see that the file is shared with "user0"
276+
And I visit the settings page
277+
And I open the "Sharing" section of the "Administration" group
278+
And I disable resharing
279+
And I see that resharing is disabled
280+
When I act as Jane
281+
# The Files app is open again to reload the file list
282+
And I open the Files app
283+
Then I see that the file list contains a file named "Shared folder"
284+
And I open the details view for "Shared folder"
285+
And I see that the details view is open
286+
And I open the "Sharing" tab in the details view
287+
And I see that the "Sharing" tab in the details view is eventually loaded
288+
And I see that the file is shared with me by "admin"
289+
And I see that resharing the file is not allowed
290+
291+
Scenario: sharee can unshare a folder if resharing is disabled in the settings after the share is created
292+
Given I act as John
293+
And I am logged in as the admin
294+
And I act as Jane
295+
And I am logged in
296+
And I act as John
297+
And I create a new folder named "Shared folder"
298+
And I see that the file list contains a file named "Shared folder"
299+
And I share "Shared folder" with "user0"
300+
And I see that the file is shared with "user0"
301+
And I act as Jane
302+
# The Files app is open again to reload the file list
303+
And I open the Files app
304+
And I share "Shared folder" with "user1"
305+
And I act as John
306+
And I visit the settings page
307+
And I open the "Sharing" section of the "Administration" group
308+
And I disable resharing
309+
And I see that resharing is disabled
310+
When I act as Jane
311+
# The Files app is open again to reload the file list
312+
And I open the Files app
313+
Then I see that the file list contains a file named "Shared folder"
314+
And I open the details view for "Shared folder"
315+
And I see that the details view is open
316+
And I open the "Sharing" tab in the details view
317+
And I see that the "Sharing" tab in the details view is eventually loaded
318+
And I see that the file is shared with me by "admin"
319+
And I unshare the share with "user1"
320+
And I see that the file is not shared with "user1"
321+
322+
Scenario: resharee sees a folder created by the owner in a shared folder if resharing is disabled in the settings after the share is created
323+
Given I act as John
324+
And I am logged in as the admin
325+
And I act as Jane
326+
And I am logged in
327+
And I act as Jim
328+
And I am logged in as "user1"
329+
And I act as John
330+
And I create a new folder named "Shared folder"
331+
And I see that the file list contains a file named "Shared folder"
332+
And I share "Shared folder" with "user0"
333+
And I see that the file is shared with "user0"
334+
And I act as Jane
335+
# The Files app is open again to reload the file list
336+
And I open the Files app
337+
And I share "Shared folder" with "user1"
338+
And I act as John
339+
And I visit the settings page
340+
And I open the "Sharing" section of the "Administration" group
341+
And I disable resharing
342+
And I see that resharing is disabled
343+
And I open the Files app
344+
And I enter in the folder named "Shared folder"
345+
And I create a new folder named "Subfolder"
346+
And I see that the file list contains a file named "Subfolder"
347+
When I act as Jim
348+
# The Files app is open again to reload the file list
349+
And I open the Files app
350+
And I enter in the folder named "Shared folder"
351+
Then I see that the file list contains a file named "Subfolder"
352+
249353
Scenario: sharee can not reshare a folder if the sharer disables it
250354
Given I act as John
251355
And I am logged in as the admin

tests/acceptance/features/bootstrap/FilesAppSharingContext.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,15 @@ public static function canReshareCheckboxInput($sharedWithName) {
164164
return self::permissionCheckboxInputFor($sharedWithName, 'Allow resharing');
165165
}
166166

167+
/**
168+
* @return Locator
169+
*/
170+
public static function unshareButton($sharedWithName, $shareWithMenuTriggerElement) {
171+
return Locator::forThe()->xpath("//li[contains(concat(' ', normalize-space(@class), ' '), ' action ')]//button[normalize-space() = 'Unshare']")->
172+
descendantOf(self::shareWithMenu($sharedWithName, $shareWithMenuTriggerElement))->
173+
describedAs("Unshare button in the share with $sharedWithName menu in the details view in Files app");
174+
}
175+
167176
/**
168177
* @return Locator
169178
*/
@@ -434,6 +443,16 @@ public function iSetTheShareWithAsNotReshareable($shareWithName) {
434443
$this->actor->find(self::canReshareCheckbox($shareWithName), 2)->click();
435444
}
436445

446+
/**
447+
* @When I unshare the share with :shareWithName
448+
*/
449+
public function iUnshareTheFileWith($shareWithName) {
450+
$this->showShareWithMenuIfNeeded($shareWithName);
451+
452+
$shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($shareWithName), 2);
453+
$this->actor->find(self::unshareButton($shareWithName, $shareWithMenuTriggerElement), 2)->click();
454+
}
455+
437456
/**
438457
* @Then I see that the file is shared with me by :sharedByName
439458
*/
@@ -450,6 +469,18 @@ public function iSeeThatTheFileIsSharedWith($sharedWithName) {
450469
$this->actor->find(self::sharedWithRow($sharedWithName), 10)->isVisible());
451470
}
452471

472+
/**
473+
* @Then I see that the file is not shared with :sharedWithName
474+
*/
475+
public function iSeeThatTheFileIsNotSharedWith($sharedWithName) {
476+
if (!WaitFor::elementToBeEventuallyNotShown(
477+
$this->actor,
478+
self::sharedWithRow($sharedWithName),
479+
$timeout = 10 * $this->actor->getFindTimeoutMultiplier())) {
480+
PHPUnit_Framework_Assert::fail("The shared with $sharedWithName row is still shown after $timeout seconds");
481+
}
482+
}
483+
453484
/**
454485
* @Then I see that resharing the file is not allowed
455486
*/
@@ -520,6 +551,21 @@ public function iSeeThatCanNotCreateInTheShare($sharedWithName) {
520551
$this->actor->find(self::canCreateCheckboxInput($sharedWithName), 10)->isChecked());
521552
}
522553

554+
/**
555+
* @Then I see that resharing for :sharedWithName is not available
556+
*/
557+
public function iSeeThatResharingForIsNotAvailable($sharedWithName) {
558+
$this->showShareWithMenuIfNeeded($sharedWithName);
559+
560+
$shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($sharedWithName), 10);
561+
if (!WaitFor::elementToBeEventuallyNotShown(
562+
$this->actor,
563+
self::canReshareCheckbox($sharedWithName, $shareWithMenuTriggerElement),
564+
$timeout = 10 * $this->actor->getFindTimeoutMultiplier())) {
565+
PHPUnit_Framework_Assert::fail("The resharing checkbox for $sharedWithName is still shown after $timeout seconds");
566+
}
567+
}
568+
523569
/**
524570
* @Then I see that :sharedWithName can reshare the share
525571
*/

0 commit comments

Comments
 (0)