Skip to content

Commit

Permalink
Merge pull request #33400 from owncloud/stable10-webui-test-versions
Browse files Browse the repository at this point in the history
[Stable10]Add webUI acceptance tests for checking the versions feature
  • Loading branch information
dpakach authored Nov 5, 2018
2 parents 84d4d15 + 4a8f0ec commit c3300cb
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/acceptance/features/bootstrap/WebUIFilesContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -2051,4 +2051,26 @@ public function theUserClosesTheDetailsDialog() {
public function theUserDeletesTagWithNameUsingTheWebui($name) {
$this->filesPage->getDetailsDialog()->deleteTag($name);
}

/**
* @Then the versions list should contain :num entries
*
* @param int $num
*
* @return void
*/
public function theVersionsListShouldContainEntries($num) {
$versionsList = $this->filesPage->getDetailsDialog()->getVersionsList();
$versionsCount = \count($versionsList->findAll("xpath", "//li"));
PHPUnit_Framework_Assert::assertEquals($num, $versionsCount);
}

/**
* @When the user restores the file to last version using the webUI
*
* @return void
*/
public function theUserRestoresTheFileToLastVersionUsingTheWebui() {
$this->filesPage->getDetailsDialog()->restoreCurrentFileToLastVersion();
}
}
44 changes: 44 additions & 0 deletions tests/acceptance/features/lib/FilesPageElement/DetailsDialog.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ class DetailsDialog extends OwncloudPage {
private $commentDeleteButtonXpath = "//a[@data-original-title='Delete comment']";
private $commentListXpath = "//ul[@class='comments']//div[@class='message']";

private $versionsListXpath = "//div[@id='versionsTabView']//ul[@class='versions']";
private $lastVersionRevertButton = "//div[@id='versionsTabView']//ul[@class='versions']//li[1]/div/a";

/**
* Lookup the id for the requested details tab.
* If the id is not known, then return the passed-in parameter as the id.
Expand Down Expand Up @@ -113,6 +116,38 @@ private function getCommentXpath($content) {
return "//ul[@class='comments']//div[@class='message' and contains(., '" . $content . "')]";
}

/**
* find the xpath of version list
*
* @return string
*/
public function getVersionsList() {
$versionsList = $this->find("xpath", $this->versionsListXpath);
$this->assertElementNotNull(
$versionsList,
__METHOD__ .
" could not find versions list for current file"
);
$this->waitTillElementIsNotNull($this->versionsListXpath);
return $versionsList;
}

/**
* find the xpath of button to revert to last version
*
* @return void
*/
public function getLastVersionRevertButton() {
$btn = $this->find("xpath", $this->lastVersionRevertButton);
$this->assertElementNotNull(
$btn,
__METHOD__ .
" could not find the button to revert the version"
);
$this->waitTillElementIsNotNull($this->lastVersionRevertButton);
return $btn;
}

/**
* change the active tab of details panel
*
Expand Down Expand Up @@ -374,6 +409,15 @@ public function getTagsDropDownResultsXpath() {
"//span[@class='label']";
}

/**
* @return void
*/
public function restoreCurrentFileToLastVersion() {
$revertBtn = $this->getLastVersionRevertButton();
$revertBtn->click();
$this->waitForAjaxCallsToStartAndFinish($this->getSession());
}

/**
* closes the details dialog panel
*
Expand Down
41 changes: 41 additions & 0 deletions tests/acceptance/features/webUIFiles/versions.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
@webUI @insulated @files_versions-app-required
Feature: Versions of a file

As a user
I would like to see different versions of a file and delete and restore them
So that I can have more control over the files

Background:
Given these users have been created:
| username |
| user0 |
| user1 |

Scenario: upload new file with same name to see if different versions are shown
Given user "user0" has logged in using the webUI
And the user has browsed to the files page
And user "user0" has uploaded file with content "lorem content" to "/lorem.txt"
And user "user0" has uploaded file with content "new lorem content" to "/lorem.txt"
When the user browses directly to display the "versions" details of file "lorem.txt" in folder "/"
Then the content of file "lorem.txt" for user "user0" should be "new lorem content"
And the versions list should contain 2 entries

Scenario: restoring file to old version changes the content of the file
Given user "user0" has logged in using the webUI
And the user has browsed to the files page
And user "user0" has uploaded file with content "lorem content" to "/lorem-file.txt"
And user "user0" has uploaded file with content "new lorem content" to "/lorem-file.txt"
When the user browses directly to display the "versions" details of file "lorem-file.txt" in folder "/"
And the user restores the file to last version using the webUI
Then the content of file "lorem-file.txt" for user "user0" should be "lorem content"

Scenario: sharee can see the versions of a file
Given user "user0" has uploaded file with content "lorem content" to "/lorem-file.txt"
And user "user0" has uploaded file with content "lorem" to "/lorem-file.txt"
And user "user0" has uploaded file with content "new lorem content" to "/lorem-file.txt"
And user "user0" has shared file "lorem-file.txt" with user "user1"
And user "user1" has logged in using the webUI
And the user has browsed to the files page
When the user browses directly to display the "versions" details of file "lorem-file.txt" in folder "/"
Then the content of file "lorem-file.txt" for user "user1" should be "new lorem content"
And the versions list should contain 2 entries

0 comments on commit c3300cb

Please sign in to comment.