From d996bf8b162a723c2febae85ccfdb3d33ceb4cae Mon Sep 17 00:00:00 2001 From: Hari Bhandari Date: Wed, 15 May 2019 14:44:34 +0545 Subject: [PATCH] acceptance test for tags removal and tags deletion --- .../features/bootstrap/WebUITagsContext.php | 13 ++++ .../lib/FilesPageElement/DetailsDialog.php | 58 +++++++++++++++++ .../features/webUITags/deleteTags.feature | 34 ++++++++++ .../features/webUITags/editTags.feature | 36 ++++++++++ .../features/webUITags/removeTags.feature | 65 +++++++++++++++++++ 5 files changed, 206 insertions(+) create mode 100644 tests/acceptance/features/webUITags/editTags.feature diff --git a/tests/acceptance/features/bootstrap/WebUITagsContext.php b/tests/acceptance/features/bootstrap/WebUITagsContext.php index 82e2e6ba2d90..6c2497e241e8 100644 --- a/tests/acceptance/features/bootstrap/WebUITagsContext.php +++ b/tests/acceptance/features/bootstrap/WebUITagsContext.php @@ -25,6 +25,7 @@ use Behat\MinkExtension\Context\RawMinkContext; use Page\FilesPage; use Page\TagsPage; +use Behat\Gherkin\Node\TableNode; require_once 'bootstrap.php'; @@ -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 * diff --git a/tests/acceptance/features/lib/FilesPageElement/DetailsDialog.php b/tests/acceptance/features/lib/FilesPageElement/DetailsDialog.php index 4a7a857ef9db..f4e4e94b57ad 100644 --- a/tests/acceptance/features/lib/FilesPageElement/DetailsDialog.php +++ b/tests/acceptance/features/lib/FilesPageElement/DetailsDialog.php @@ -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 @@ -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']"; @@ -232,6 +235,7 @@ public function getCommentList() { "xpath", $this->commentListXpath ); } + /** * check if a comment with given text is listed on the webUI * @@ -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 * diff --git a/tests/acceptance/features/webUITags/deleteTags.feature b/tests/acceptance/features/webUITags/deleteTags.feature index 8255c805927f..8e054681567c 100644 --- a/tests/acceptance/features/webUITags/deleteTags.feature +++ b/tests/acceptance/features/webUITags/deleteTags.feature @@ -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 | + diff --git a/tests/acceptance/features/webUITags/editTags.feature b/tests/acceptance/features/webUITags/editTags.feature new file mode 100644 index 000000000000..9fe8738cb4a5 --- /dev/null +++ b/tests/acceptance/features/webUITags/editTags.feature @@ -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 \ No newline at end of file diff --git a/tests/acceptance/features/webUITags/removeTags.feature b/tests/acceptance/features/webUITags/removeTags.feature index 4260633a6156..65b00ffecb59 100644 --- a/tests/acceptance/features/webUITags/removeTags.feature +++ b/tests/acceptance/features/webUITags/removeTags.feature @@ -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 @@ -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 |