Skip to content
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
13 changes: 13 additions & 0 deletions tests/acceptance/features/bootstrap/WebUITagsContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use Behat\MinkExtension\Context\RawMinkContext;
use Page\FilesPage;
use Page\TagsPage;
use Behat\Gherkin\Node\TableNode;

require_once 'bootstrap.php';

Expand Down Expand Up @@ -103,6 +104,18 @@ public function theUserTypesAValueInTheCollaborativeTagsFieldUsingTheWebUI($valu
$this->filesPage->getDetailsDialog()->insertTagNameInTheTagsField($value);
}

/**
* @When the user edits the tag with name :oldName and sets its name to :newName using the webUI
*
* @param string $oldName
* @param string $newName
*
* @return void
*/
public function theUserEditsTheTagWithNameAndSetsItsNameToUsingTheWebui($oldName, $newName) {
$this->filesPage->getDetailsDialog()->renameTag($oldName, $newName);
}

/**
* @Then all the tags starting with :value in their name should be listed in the dropdown list on the webUI
*
Expand Down
58 changes: 58 additions & 0 deletions tests/acceptance/features/lib/FilesPageElement/DetailsDialog.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
use Behat\Mink\Session;
use Page\OwncloudPage;
use SensioLabs\Behat\PageObjectExtension\PageObject\Exception\ElementNotFoundException;
use WebDriver\Exception\NoSuchElement;
use WebDriver\Exception\StaleElementReference;
use WebDriver\Key;

/**
* The Details Dialog
Expand Down Expand Up @@ -60,6 +62,7 @@ class DetailsDialog extends OwncloudPage {
private $tagsDropDownResultXpath = "//div[contains(@class, 'systemtags-select2-dropdown')]" .
"//ul[@class='select2-results']" .
"//span[@class='label']";
private $tagEditInputXpath = "//input[@id='view9-rename-input']";

private $commentXpath = "//ul[@class='comments']//div[@class='message' and contains(., '%s')]";
private $commentInputXpath = "//form[@class='newCommentForm']//textarea[@class='message']";
Expand Down Expand Up @@ -232,6 +235,7 @@ public function getCommentList() {
"xpath", $this->commentListXpath
);
}

/**
* check if a comment with given text is listed on the webUI
*
Expand Down Expand Up @@ -497,6 +501,60 @@ public function deleteTag($tagName) {
}
}
}

/**
* Rename a tag on the files in the details dialog
*
* @param string $tagName
* @param string $newName
*
* @return void
* @throws ElementNotFoundException
*/
public function renameTag($tagName, $newName) {
$this->insertTagNameInTheTagsField($tagName);
$suggestions = $this->getDropDownTagsSuggestionResults();
foreach ($suggestions as $tag) {
if ($tag->getText() === $tagName) {
$tagContainer = $tag->getParent();
$editBtn = $tagContainer->find("xpath", $this->tagEditButtonInTagXpath);
$this->assertElementNotNull(
$editBtn,
__METHOD__ .
" xpath: $this->tagEditButtonInTagXpath" .
"could not find tag edit button"
);
$editBtn->focus();
$editBtn->click();
$editInput = $this->find(
"xpath", $this->tagEditInputXpath
);
$this->assertElementNotNull(
$editInput,
__METHOD__ .
"xpath: $this->tagEditInputXpath" .
" could not find tag edit input"
);
$editInput->focus();
$editInput->click();
try {
$this->fillField("Rename", $newName . Key::ENTER);
} catch (NoSuchElement $e) {
// this seems to be a bug in MinkSelenium2Driver.
// Used to work fine in 1.3.1 but now throws this exception
// Actually all that we need does happen, so we just don't do anything
} catch (StaleElementReference $e) {
// At the end of processing setValue, MinkSelenium2Driver tries to blur
// away from the element. But we pressed enter which has already
// made the element go away. So we do not care about this exception.
// This issue started happening due to:
// https://github.com/minkphp/MinkSelenium2Driver/pull/286
}
break;
}
}
}

/**
* Returns xpath of the tag results dropdown
*
Expand Down
34 changes: 34 additions & 0 deletions tests/acceptance/features/webUITags/deleteTags.feature
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,37 @@ Feature: Deletion of existing tags from files and folders
| lorem | normal |
When the user deletes tag with name "lorem" using the webUI
Then tag "lorem" should not exist for user "user1"

Scenario: Delete a tag that exists for multiple file
Given the user has created a "normal" tag with name "lorem"
And the user has added tag "lorem" to file "lorem.txt"
And the user has added tag "lorem" to file "lorem-big.txt"
And the user has browsed directly to display the details of file "lorem.txt" in folder "simple-folder"
When the user deletes tag with name "lorem" using the webUI
Then tag "lorem" should not exist for user "user1"

Scenario: Delete all tags that exist for a file
Given the user has created a "normal" tag with name "lorem"
And the user has created a "normal" tag with name "Confidential"
And the user has added tag "lorem" to file "lorem.txt"
And the user has added tag "Confidential" to file "lorem.txt"
And the user has browsed directly to display the details of file "lorem.txt" in folder "/"
When the user deletes tag with name "lorem" using the webUI
And the user deletes tag with name "Confidential" using the webUI
Then file "lorem.txt" should have no tags for user "user1"

Scenario: Delete multiple tags that exist for a file
Given the user has created a "normal" tag with name "lorem"
And the user has created a "normal" tag with name "Confidential"
And the user has created a "normal" tag with name "some-tag"
And the user has added tag "lorem" to file "lorem.txt"
And the user has added tag "Confidential" to file "lorem.txt"
And the user has added tag "some-tag" to file "lorem.txt"
And the user has browsed directly to display the details of file "lorem.txt" in folder "/"
When the user deletes tag with name "lorem" using the webUI
And the user deletes tag with name "Confidential" using the webUI
Then tag "lorem" should not exist for user "user1"
And tag "Confidential" should not exist for user "user1"
And file "/lorem.txt" should have the following tags for user "user1"
| some-tag | normal |

36 changes: 36 additions & 0 deletions tests/acceptance/features/webUITags/editTags.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
@webUI @insulated @disablePreviews @systemtags-app-required
Feature: Edit tags for files and folders
As a user
I want to edit tags for files/folders
So that I can find them easily

Background:
Given these users have been created with default attributes:
| username |
| user1 |
| user2 |
And the user has browsed to the login page
And the user has logged in with username "user1" and password "%alt1%" using the webUI

Scenario: Change the name of a tag that already exists for a file
Given the user has created a "normal" tag with name "lorem"
And the user has added tag "lorem" to file "lorem.txt"
When the user browses directly to display the details of file "lorem.txt" in folder "/"
And the user edits the tag with name "lorem" and sets its name to "lorem-big" using the webUI
Then file "lorem.txt" should have the following tags for user "user1"
| lorem-big | normal |
And tag "lorem" should not exist for the user

Scenario: Change the name of multiple tags that exist for a file
Given the user has created a "normal" tag with name "lorem"
And the user has created a "normal" tag with name "some-tag"
And the user has added tag "lorem" to file "lorem.txt"
And the user has added tag "some-tag" to file "lorem.txt"
When the user browses directly to display the details of file "lorem.txt" in folder "/"
And the user edits the tag with name "lorem" and sets its name to "lorem-big" using the webUI
And the user edits the tag with name "some-tag" and sets its name to "another-tag" using the webUI
Then file "lorem.txt" should have the following tags for user "user1"
| lorem-big | normal |
| another-tag | normal |
And tag "lorem" should not exist for the user
And tag "some-tag" should not exist for the user
65 changes: 65 additions & 0 deletions tests/acceptance/features/webUITags/removeTags.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Feature: Removal of already existing tags from files and folders
Given these users have been created with default attributes:
| username |
| user1 |
| user2 |
And the user has browsed to the login page
And the user has logged in with username "user1" and password "%alt1%" using the webUI

Expand All @@ -18,4 +19,68 @@ Feature: Removal of already existing tags from files and folders
And the user toggles a tag "lorem" on the file using the webUI
Then file "simple-folder/lorem.txt" should have no tags for user "user1"

Scenario: Remove a tag that already exists for a file in the root
Given the user has browsed directly to display the details of file "lorem.txt" in folder "/"
And the user has added a tag "lorem" to the file using the webUI
When the user browses directly to display the details of file "lorem.txt" in folder "/"
And the user toggles a tag "lorem" on the file using the webUI
Then file "lorem.txt" should have no tags for user "user1"

Scenario: Remove all tags that already exist for a file
Given the user has created a "normal" tag with name "lorem"
And the user has created a "normal" tag with name "Confidential"
And the user has added tag "lorem" to file "lorem.txt"
And the user has added tag "Confidential" to file "lorem.txt"
When the user browses directly to display the details of file "lorem.txt" in folder "/"
And the user toggles a tag "lorem" on the file using the webUI
And the user toggles a tag "Confidential" on the file using the webUI
Then file "lorem.txt" should have no tags for user "user1"

Scenario: Shared user removes a tag in shared file
Given the user has created a "normal" tag with name "tag1"
And user "user1" has uploaded file with content "does-not-matter" to "/coolnewfile.txt"
And the user has added tag "tag1" to file "coolnewfile.txt"
And the user has shared file "coolnewfile.txt" with user "user2"
When the user re-logs in as "user2" using the webUI
Then file "coolnewfile.txt" should have the following tags for user "user2"
| tag1 | normal |
When the user browses directly to display the details of file "coolnewfile.txt" in folder "/"
And the user toggles a tag "tag1" on the file using the webUI
Then file "coolnewfile.txt" should have no tags for user "user2"
And file "coolnewfile.txt" should have no tags for user "user1"

Scenario: Sharer removes a tag in shared file
Given the user has created a "normal" tag with name "tag1"
And user "user1" has uploaded file with content "does-not-matter" to "/coolnewfile.txt"
And the user has added tag "tag1" to file "coolnewfile.txt"
And the user has shared file "coolnewfile.txt" with user "user2"
When the user re-logs in as "user2" using the webUI
Then file "coolnewfile.txt" should have the following tags for user "user2"
| tag1 | normal |
When the user re-logs in with username "user1" and password "%alt1%" using the webUI
And the user browses directly to display the details of file "coolnewfile.txt" in folder "/"
And the user toggles a tag "tag1" on the file using the webUI
Then file "coolnewfile.txt" should have no tags for user "user2"
And file "coolnewfile.txt" should have no tags for user "user1"

Scenario: Remove multiple tags that exist for a file
Given the user has created a "normal" tag with name "lorem"
And the user has created a "normal" tag with name "Confidential"
And the user has created a "normal" tag with name "some-tag"
And the user has added tag "lorem" to file "lorem.txt"
And the user has added tag "Confidential" to file "lorem.txt"
And the user has added tag "some-tag" to file "lorem.txt"
When the user browses directly to display the details of file "lorem.txt" in folder "/"
And the user toggles a tag "lorem" on the file using the webUI
And the user toggles a tag "Confidential" on the file using the webUI
Then file "lorem.txt" should have the following tags for user "user1"
| some-tag | normal |

Scenario: Remove a tag from a file and assign another tag
Given the user has created a "normal" tag with name "lorem"
And the user has added tag "lorem" to file "lorem.txt"
When the user browses directly to display the details of file "lorem.txt" in folder "/"
And the user toggles a tag "lorem" on the file using the webUI
And the user adds a tag "some-tag" to the file using the webUI
Then file "lorem.txt" should have the following tags for user "user1"
| some-tag | normal |