Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable13] Add acceptance tests for permissions on public shared folders #8758

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions tests/acceptance/config/behat.yml
Expand Up @@ -12,6 +12,7 @@ default:
- AppNavigationContext
- CommentsAppContext
- FeatureContext
- FileListContext
- FilesAppContext
- FilesSharingAppContext
- LoginPageContext
Expand Down
65 changes: 65 additions & 0 deletions tests/acceptance/features/app-files.feature
Expand Up @@ -41,6 +41,71 @@ Feature: app-files
And I open the Share menu
Then I see that the Share menu is shown

Scenario: creation is not possible by default in a public shared folder
Given I act as John
And I am logged in
And I create a new folder named "Shared folder"
# To share the link the "Share" inline action has to be clicked but, as the
# details view is opened automatically when the folder is created, clicking
# on the inline action could fail if it is covered by the details view due
# to its opening animation. Instead of ensuring that the animations of the
# contents and the details view have both finished it is easier to close the
# details view and wait until it is closed before continuing.
And I close the details view
And I see that the details view is closed
And I share the link for "Shared folder"
And I write down the shared link
When I act as Jane
And I visit the shared link I wrote down
And I see that the current page is the shared link I wrote down
And I see that the file list is eventually loaded
Then I see that it is not possible to create new files

Scenario: create folder in a public editable shared folder
Given I act as John
And I am logged in
And I create a new folder named "Editable shared folder"
# To share the link the "Share" inline action has to be clicked but, as the
# details view is opened automatically when the folder is created, clicking
# on the inline action could fail if it is covered by the details view due
# to its opening animation. Instead of ensuring that the animations of the
# contents and the details view have both finished it is easier to close the
# details view and wait until it is closed before continuing.
And I close the details view
And I see that the details view is closed
And I share the link for "Editable shared folder"
And I set the shared link as editable
And I write down the shared link
When I act as Jane
And I visit the shared link I wrote down
And I see that the current page is the shared link I wrote down
And I create a new folder named "Subfolder"
Then I see that the file list contains a file named "Subfolder"

Scenario: owner sees folder created in the public page of an editable shared folder
Given I act as John
And I am logged in
And I create a new folder named "Editable shared folder"
# To share the link the "Share" inline action has to be clicked but, as the
# details view is opened automatically when the folder is created, clicking
# on the inline action could fail if it is covered by the details view due
# to its opening animation. Instead of ensuring that the animations of the
# contents and the details view have both finished it is easier to close the
# details view and wait until it is closed before continuing.
And I close the details view
And I see that the details view is closed
And I share the link for "Editable shared folder"
And I set the shared link as editable
And I write down the shared link
And I act as Jane
And I visit the shared link I wrote down
And I see that the current page is the shared link I wrote down
And I create a new folder named "Subfolder"
And I see that the file list contains a file named "Subfolder"
When I act as John
And I enter in the folder named "Editable shared folder"
Then I see that the file list contains a file named "Subfolder"

Scenario: set a password to a shared link
Given I am logged in
And I share the link for "welcome.txt"
Expand Down
67 changes: 67 additions & 0 deletions tests/acceptance/features/bootstrap/FileListAncestorSetter.php
@@ -0,0 +1,67 @@
<?php

/**
*
* @copyright Copyright (c) 2018, Daniel Calviño Sánchez (danxuliu@gmail.com)
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

use Behat\Behat\Context\Context;
use Behat\Behat\Hook\Scope\BeforeScenarioScope;

/**
* Helper trait to set the ancestor of the file list.
*
* The FileListContext provides steps to interact with and check the behaviour
* of a file list. However, the FileListContext does not know the right file
* list ancestor that has to be used by the file list steps; this has to be set
* from other contexts, for example, when the Files app or the public page for a
* shared folder is opened.
*
* Contexts that "know" that certain file list ancestor has to be used by the
* FileListContext steps should use this trait and call
* "setFileListAncestorForActor" when needed.
*/
trait FileListAncestorSetter {

/**
* @var FileListContext
*/
private $fileListContext;

/**
* @BeforeScenario
*/
public function getSiblingFileListContext(BeforeScenarioScope $scope) {
$environment = $scope->getEnvironment();

$this->fileListContext = $environment->getContext("FileListContext");
}

/**
* Sets the file list ancestor to be used in the file list steps performed
* by the given actor.
*
* @param null|Locator $fileListAncestor the file list ancestor
* @param Actor $actor the actor
*/
private function setFileListAncestorForActor($fileListAncestor, Actor $actor) {
$this->fileListContext->setFileListAncestorForActor($fileListAncestor, $actor);
}

}