Skip to content

Commit aeaa430

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

File tree

2 files changed

+111
-0
lines changed

2 files changed

+111
-0
lines changed

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

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,3 +166,83 @@ Feature: app-files-sharing-link
166166
And I authenticate with password "abcdef"
167167
# download starts no page redirection
168168
And I see that the current page is the Authenticate page for the direct download shared link I wrote down
169+
170+
Scenario: sharee can not reshare by link if resharing is disabled in the settings after the share is created
171+
Given I act as John
172+
And I am logged in as the admin
173+
And I act as Jane
174+
And I am logged in
175+
And I act as John
176+
And I rename "welcome.txt" to "farewell.txt"
177+
And I see that the file list contains a file named "farewell.txt"
178+
And I share "farewell.txt" with "user0"
179+
And I see that the file is shared with "user0"
180+
And I visit the settings page
181+
And I open the "Sharing" section of the "Administration" group
182+
And I disable resharing
183+
And I see that resharing is disabled
184+
When I act as Jane
185+
# The Files app is open again to reload the file list
186+
And I open the Files app
187+
Then I see that the file list contains a file named "farewell.txt"
188+
And I open the details view for "farewell.txt"
189+
And I see that the details view is open
190+
And I open the "Sharing" tab in the details view
191+
And I see that the "Sharing" tab in the details view is eventually loaded
192+
And I see that the file is shared with me by "admin"
193+
And I see that resharing the file by link is not available
194+
195+
Scenario: sharee can unshare a reshare by link if resharing is disabled in the settings after the reshare is created
196+
Given I act as John
197+
And I am logged in as the admin
198+
And I act as Jane
199+
And I am logged in
200+
And I act as John
201+
And I rename "welcome.txt" to "farewell.txt"
202+
And I see that the file list contains a file named "farewell.txt"
203+
And I share "farewell.txt" with "user0"
204+
And I see that the file is shared with "user0"
205+
And I act as Jane
206+
# The Files app is open again to reload the file list
207+
And I open the Files app
208+
And I share the link for "farewell.txt"
209+
And I write down the shared link
210+
And I act as John
211+
And I visit the settings page
212+
And I open the "Sharing" section of the "Administration" group
213+
And I disable resharing
214+
And I see that resharing is disabled
215+
When I act as Jane
216+
# The Files app is open again to reload the file list
217+
And I open the Files app
218+
And I open the details view for "farewell.txt"
219+
And I see that the details view is open
220+
And I open the "Sharing" tab in the details view
221+
And I see that the "Sharing" tab in the details view is eventually loaded
222+
And I unshare the link share
223+
Then I see that resharing the file by link is not available
224+
225+
Scenario: reshare by link can be accessed if resharing is disabled in the settings after the reshare is created
226+
Given I act as John
227+
And I am logged in as the admin
228+
And I act as Jane
229+
And I am logged in
230+
And I act as John
231+
And I rename "welcome.txt" to "farewell.txt"
232+
And I see that the file list contains a file named "farewell.txt"
233+
And I share "farewell.txt" with "user0"
234+
And I see that the file is shared with "user0"
235+
And I act as Jane
236+
# The Files app is open again to reload the file list
237+
And I open the Files app
238+
And I share the link for "farewell.txt"
239+
And I write down the shared link
240+
And I act as John
241+
And I visit the settings page
242+
And I open the "Sharing" section of the "Administration" group
243+
And I disable resharing
244+
And I see that resharing is disabled
245+
When I act as Jim
246+
And I visit the shared link I wrote down
247+
Then I see that the current page is the shared link I wrote down
248+
And I see that the shared file preview shows the text "Welcome to your Nextcloud account!"

tests/acceptance/features/bootstrap/FilesAppSharingContext.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,15 @@ public static function passwordProtectByTalkCheckboxInput() {
311311
describedAs("Password protect by Talk checkbox input in the details view in Files app");
312312
}
313313

314+
/**
315+
* @return Locator
316+
*/
317+
public static function unshareLinkButton($shareLinkMenuTriggerElement) {
318+
return Locator::forThe()->xpath("//li[contains(concat(' ', normalize-space(@class), ' '), ' action ')]//button[normalize-space() = 'Unshare']")->
319+
descendantOf(self::shareLinkMenu($shareLinkMenuTriggerElement))->
320+
describedAs("Unshare link button in the details view in Files app");
321+
}
322+
314323
/**
315324
* @Given I share the link for :fileName
316325
*/
@@ -453,6 +462,16 @@ public function iUnshareTheFileWith($shareWithName) {
453462
$this->actor->find(self::unshareButton($shareWithName, $shareWithMenuTriggerElement), 2)->click();
454463
}
455464

465+
/**
466+
* @When I unshare the link share
467+
*/
468+
public function iUnshareTheLink() {
469+
$this->showShareLinkMenuIfNeeded();
470+
471+
$shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 2);
472+
$this->actor->find(self::unshareLinkButton($shareLinkMenuTriggerElement), 2)->click();
473+
}
474+
456475
/**
457476
* @Then I see that the file is shared with me by :sharedByName
458477
*/
@@ -491,6 +510,18 @@ public function iSeeThatResharingTheFileIsNotAllowed() {
491510
$this->actor->find(self::shareWithInput(), 10)->getWrappedElement()->getAttribute("placeholder"), "Resharing is not allowed");
492511
}
493512

513+
/**
514+
* @Then I see that resharing the file by link is not available
515+
*/
516+
public function iSeeThatResharingTheFileByLinkIsNotAvailable() {
517+
if (!WaitFor::elementToBeEventuallyNotShown(
518+
$this->actor,
519+
self::shareLinkAddNewButton(),
520+
$timeout = 10 * $this->actor->getFindTimeoutMultiplier())) {
521+
PHPUnit_Framework_Assert::fail("The add new share link button is still shown after $timeout seconds");
522+
}
523+
}
524+
494525
/**
495526
* @Then I see that :sharedWithName can not be allowed to edit the share
496527
*/

0 commit comments

Comments
 (0)