Skip to content

Commit f6c5c85

Browse files
committed
Add acceptance tests for creation of subfolders in public shared folders
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
1 parent f3bc6fd commit f6c5c85

3 files changed

Lines changed: 121 additions & 0 deletions

File tree

tests/acceptance/features/app-files.feature

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,71 @@ Feature: app-files
4141
And I open the Share menu
4242
Then I see that the Share menu is shown
4343

44+
Scenario: creation is not possible by default in a public shared folder
45+
Given I act as John
46+
And I am logged in
47+
And I create a new folder named "Shared folder"
48+
# To share the link the "Share" inline action has to be clicked but, as the
49+
# details view is opened automatically when the folder is created, clicking
50+
# on the inline action could fail if it is covered by the details view due
51+
# to its opening animation. Instead of ensuring that the animations of the
52+
# contents and the details view have both finished it is easier to close the
53+
# details view and wait until it is closed before continuing.
54+
And I close the details view
55+
And I see that the details view is closed
56+
And I share the link for "Shared folder"
57+
And I write down the shared link
58+
When I act as Jane
59+
And I visit the shared link I wrote down
60+
And I see that the current page is the shared link I wrote down
61+
And I see that the file list is eventually loaded
62+
Then I see that it is not possible to create new files
63+
64+
Scenario: create folder in a public editable shared folder
65+
Given I act as John
66+
And I am logged in
67+
And I create a new folder named "Editable shared folder"
68+
# To share the link the "Share" inline action has to be clicked but, as the
69+
# details view is opened automatically when the folder is created, clicking
70+
# on the inline action could fail if it is covered by the details view due
71+
# to its opening animation. Instead of ensuring that the animations of the
72+
# contents and the details view have both finished it is easier to close the
73+
# details view and wait until it is closed before continuing.
74+
And I close the details view
75+
And I see that the details view is closed
76+
And I share the link for "Editable shared folder"
77+
And I set the shared link as editable
78+
And I write down the shared link
79+
When I act as Jane
80+
And I visit the shared link I wrote down
81+
And I see that the current page is the shared link I wrote down
82+
And I create a new folder named "Subfolder"
83+
Then I see that the file list contains a file named "Subfolder"
84+
85+
Scenario: owner sees folder created in the public page of an editable shared folder
86+
Given I act as John
87+
And I am logged in
88+
And I create a new folder named "Editable shared folder"
89+
# To share the link the "Share" inline action has to be clicked but, as the
90+
# details view is opened automatically when the folder is created, clicking
91+
# on the inline action could fail if it is covered by the details view due
92+
# to its opening animation. Instead of ensuring that the animations of the
93+
# contents and the details view have both finished it is easier to close the
94+
# details view and wait until it is closed before continuing.
95+
And I close the details view
96+
And I see that the details view is closed
97+
And I share the link for "Editable shared folder"
98+
And I set the shared link as editable
99+
And I write down the shared link
100+
And I act as Jane
101+
And I visit the shared link I wrote down
102+
And I see that the current page is the shared link I wrote down
103+
And I create a new folder named "Subfolder"
104+
And I see that the file list contains a file named "Subfolder"
105+
When I act as John
106+
And I enter in the folder named "Editable shared folder"
107+
Then I see that the file list contains a file named "Subfolder"
108+
44109
Scenario: set a password to a shared link
45110
Given I am logged in
46111
And I share the link for "welcome.txt"

tests/acceptance/features/bootstrap/FileListContext.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,15 @@ public function setFileListAncestorForActor($fileListAncestor, Actor $actor) {
7878
$this->fileListAncestorsByActor[$actor->getName()] = $fileListAncestor;
7979
}
8080

81+
/**
82+
* @return Locator
83+
*/
84+
public static function mainWorkingIcon($fileListAncestor) {
85+
return Locator::forThe()->css(".mask.icon-loading")->
86+
descendantOf($fileListAncestor)->
87+
describedAs("Main working icon in file list");
88+
}
89+
8190
/**
8291
* @return Locator
8392
*/
@@ -255,6 +264,13 @@ public function iCreateANewFolderNamed($folderName) {
255264
$this->actor->find(self::createNewFolderMenuItemNameInput($this->fileListAncestor), 2)->setValue($folderName . "\r");
256265
}
257266

267+
/**
268+
* @Given I enter in the folder named :folderName
269+
*/
270+
public function iEnterInTheFolderNamed($folderName) {
271+
$this->actor->find(self::mainLinkForFile($this->fileListAncestor, $folderName), 10)->click();
272+
}
273+
258274
/**
259275
* @Given I open the details view for :fileName
260276
*/
@@ -306,6 +322,27 @@ public function iViewInFolder($fileName) {
306322
$this->actor->find(self::viewFileInFolderMenuItem(), 2)->click();
307323
}
308324

325+
/**
326+
* @Then I see that the file list is eventually loaded
327+
*/
328+
public function iSeeThatTheFileListIsEventuallyLoaded() {
329+
if (!WaitFor::elementToBeEventuallyNotShown(
330+
$this->actor,
331+
self::mainWorkingIcon($this->fileListAncestor),
332+
$timeout = 10 * $this->actor->getFindTimeoutMultiplier())) {
333+
PHPUnit_Framework_Assert::fail("The main working icon for the file list is still shown after $timeout seconds");
334+
}
335+
}
336+
337+
/**
338+
* @Then I see that it is not possible to create new files
339+
*/
340+
public function iSeeThatItIsNotPossibleToCreateNewFiles() {
341+
// Once a file list is loaded the "Create" menu button is always in the
342+
// DOM, so it is checked if it is visible or not.
343+
PHPUnit_Framework_Assert::assertFalse($this->actor->find(self::createMenuButton($this->fileListAncestor))->isVisible());
344+
}
345+
309346
/**
310347
* @Then I see that the file list contains a file named :fileName
311348
*/

tests/acceptance/features/bootstrap/FilesAppContext.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,18 @@ public static function shareLinkField() {
214214
describedAs("Share link field in the details view in Files app");
215215
}
216216

217+
/**
218+
* @return Locator
219+
*/
220+
public static function allowUploadAndEditingRadioButton() {
221+
// forThe()->radio("Allow upload and editing") can not be used here;
222+
// that would return the radio button itself, but the element that the
223+
// user interacts with is the label.
224+
return Locator::forThe()->xpath("//label[normalize-space() = 'Allow upload and editing']")->
225+
descendantOf(self::currentSectionDetailsView())->
226+
describedAs("Allow upload and editing radio button in the details view in Files app");
227+
}
228+
217229
/**
218230
* @return Locator
219231
*/
@@ -307,6 +319,13 @@ public function iUncheckTheTagInTheDropdownForTagsInTheDetailsView($tag) {
307319
$this->actor->find(self::itemInDropdownForTag($tag), 10)->click();
308320
}
309321

322+
/**
323+
* @When I set the shared link as editable
324+
*/
325+
public function iSetTheSharedLinkAsEditable() {
326+
$this->actor->find(self::allowUploadAndEditingRadioButton(), 10)->click();
327+
}
328+
310329
/**
311330
* @When I protect the shared link with the password :password
312331
*/

0 commit comments

Comments
 (0)