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

[full-ci] [tests-only]WebUI tests added to share resource with multiple users at once #40546

Merged
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions tests/acceptance/features/bootstrap/WebUISharingContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,27 @@ public function theUserSharesFileFolderWithUserUsingTheWebUI(
);
}

/**
* @When the user shares file/folder :resource with users :users using the webUI
grgprarup marked this conversation as resolved.
Show resolved Hide resolved
*
* @param string $resource
* @param string $users
*
* @return void
* @throws Exception
*/
public function theUserSharesFileFolderWithUsersUsingTheWebUI(
string $resource,
string $users
):void {
$this->theUserSharesFileFolderWithUserOrGroupUsingTheWebUI(
$resource,
"users",
null,
$users
);
}

/**
* @When /^the user tries to share (?:file|folder) "([^"]*)" with (?:(remote|federated)\s)?user "([^"]*)" ?(?:with displayname "([^"]*)")? using the webUI$/
*
Expand Down Expand Up @@ -448,6 +469,22 @@ public function theUserSharesUsingWebUIWithoutClosingDialog(
$maxRetries
);
}
} elseif ($userOrGroup === "users") {
$users = explode(",", $name);
$usersArray = [];
foreach ($users as $user) {
if ($this->featureContext->userExists($user)) {
$usersArray[] = $user;
}
}
$nameToMatch = join(", ", $usersArray);
$this->sharingDialog->shareWithUsers(
$name,
$nameToMatch,
$this->getSession(),
$quiet,
$maxRetries
);
} else {
$this->sharingDialog->shareWithGroup(
$name,
Expand Down
34 changes: 33 additions & 1 deletion tests/acceptance/features/lib/FilesPageElement/SharingDialog.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class SharingDialog extends OwncloudPage {
private $autocompleteItemsTextXpath = "//*[@class='autocomplete-item-text']";
private $suffixToIdentifyGroups = " Group";
private $suffixToIdentifyUsers = " User";
private $suffixToIdentifyMultipleUsers = " Add multiple users";
private $suffixToIdentifyRemoteUsers = " Federated";
private $sharerInformationXpath = ".//*[@class='reshare']";
private $sharedWithAndByRegEx = "Shared with you(?: and the group (.*))? by (.*)$";
Expand Down Expand Up @@ -352,7 +353,11 @@ public function shareWithUserOrGroup(
);
$userFound = false;
foreach ($userElements as $user) {
if ($this->getTrimmedText($user) === $nameToMatch) {
$trimmedText = $this->getTrimmedText($user);
// The logic is changed due to "Add multiple users" because the order of users in autocomplete items is not fixed
$trimmedUsers = preg_split("/[\s,]+/", $trimmedText);
$usersToMatch = preg_split("/[\s,]+/", $nameToMatch);
if (empty(array_diff($trimmedUsers, $usersToMatch))) {
$user->click();
$this->waitForAjaxCallsToStartAndFinish($session);
$userFound = true;
Expand Down Expand Up @@ -402,6 +407,33 @@ public function shareWithUser(
);
}

/**
*
* @param string|null $name
* @param string|null $nameToMatch
* @param Session $session
* @param boolean $quiet
* @param int $maxRetries
*
* @return void
* @throws ElementNotFoundException|Exception
*/
public function shareWithUsers(
string $name,
string $nameToMatch,
Session $session,
bool $quiet,
int $maxRetries = 5
): void {
$this->shareWithUserOrGroup(
$name,
$nameToMatch . $this->suffixToIdentifyMultipleUsers,
$session,
$quiet,
$maxRetries
);
}

/**
*
* @param string|null $name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,3 +353,101 @@ Feature: Sharing files and folders with internal users
| 123 |
| -123 |
| 0.0 |


Scenario: user shares file with multiple users at once
Given these users have been created with default attributes and without skeleton files:
| username |
| Alice |
| Brian |
| Carol |
And user "Alice" has uploaded file "filesForUpload/lorem.txt" to "lorem.txt"
And user "Alice" has logged in using the webUI
When the user shares file "lorem.txt" with users "Brian,Carol" using the webUI
Then as "Brian" file "lorem.txt" should exist
And as "Carol" file "lorem.txt" should exist


Scenario: user shares folder with multiple users at once
Given these users have been created with default attributes and without skeleton files:
| username |
| Alice |
| Brian |
| Carol |
And user "Alice" has created folder "simple-folder"
And user "Alice" has logged in using the webUI
When the user shares folder "simple-folder" with users "Brian,Carol" using the webUI
grgprarup marked this conversation as resolved.
Show resolved Hide resolved
Then as "Brian" folder "simple-folder" should exist
And as "Carol" folder "simple-folder" should exist


Scenario Outline: user shares file with multiple users including non-existing user at once
Given these users have been created with default attributes and without skeleton files:
| username |
| Alice |
| Brian |
| Carol |
And user "Alice" has uploaded file "filesForUpload/lorem.txt" to "lorem.txt"
And user "Alice" has logged in using the webUI
When the user shares file "lorem.txt" with users "<usernames>" using the webUI
Then a notification should be displayed on the webUI with the text "Could not be shared with the following users: David"
And as "Brian" file "lorem.txt" should exist
And as "Carol" file "lorem.txt" should exist
Examples:
| usernames |
| Brian,Carol,David |
| Brian,David,Carol |
| David,Brian,Carol |


Scenario Outline: user shares folder with multiple users including non-existing user at once
Given these users have been created with default attributes and without skeleton files:
| username |
| Alice |
| Brian |
| Carol |
And user "Alice" has created folder "simple-folder"
And user "Alice" has logged in using the webUI
When the user shares folder "simple-folder" with users "<usernames>" using the webUI
Then a notification should be displayed on the webUI with the text "Could not be shared with the following users: David"
And as "Brian" folder "simple-folder" should exist
And as "Carol" folder "simple-folder" should exist
Examples:
| usernames |
| Brian,Carol,David |
| Brian,David,Carol |
| David,Brian,Carol |


Scenario: user shares file with multiple users having exact same group name
Given these users have been created with default attributes and without skeleton files:
| username |
| Alice |
| Brian |
| Carol |
| David |
And group "Brian,Carol" has been created
grgprarup marked this conversation as resolved.
Show resolved Hide resolved
And user "David" has been added to group "Brian,Carol"
And user "Alice" has uploaded file "filesForUpload/lorem.txt" to "lorem.txt"
And user "Alice" has logged in using the webUI
When the user shares file "lorem.txt" with users "Brian,Carol" using the webUI
Then as "Brian" file "lorem.txt" should exist
And as "Carol" file "lorem.txt" should exist
And as "David" file "lorem.txt" should not exist


Scenario: user shares folder with multiple users having exact same group name
Given these users have been created with default attributes and without skeleton files:
| username |
| Alice |
| Brian |
| Carol |
| David |
And group "Brian,Carol" has been created
And user "David" has been added to group "Brian,Carol"
And user "Alice" has created folder "simple-folder"
And user "Alice" has logged in using the webUI
When the user shares folder "simple-folder" with users "Brian,Carol" using the webUI
Then as "Brian" folder "simple-folder" should exist
And as "Carol" folder "simple-folder" should exist
And as "David" folder "simple-folder" should not exist