Skip to content

Commit

Permalink
Merge pull request #34246 from bishalrijal/public-link-remove-acceptance
Browse files Browse the repository at this point in the history
Web UI test for multiple public link creation and removal of certain
  • Loading branch information
individual-it authored Jan 25, 2019
2 parents 06e9bf6 + 13edfd5 commit cdce56b
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 7 deletions.
41 changes: 40 additions & 1 deletion tests/acceptance/features/bootstrap/WebUISharingContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,23 @@ public function theUserCancelsTheRemoveOperationOfFileUsingWebui($entryName) {
$this->sharingDialog->cancelRemovePublicLinkOperation($session);
}

/**
* @When the user removes the public link at position :number of file :entryName using the webUI
*
* @param integer $number
* @param string $entryName
*
* @return void
*/
public function removesPublicLinkAtCertainPosition($number, $entryName) {
$session = $this->getSession();
$this->sharingDialog = $this->filesPage->openSharingDialog(
$entryName, $session
);
$this->publicShareTab = $this->sharingDialog->openPublicShareTab($session);
$this->sharingDialog->removePublicLink($session, $number);
}

/**
* @Then the public should not get access to the publicly shared file
*
Expand Down Expand Up @@ -980,7 +997,29 @@ public function assertSharesIsInStateOnWebUIAfterPageReload($item, $state) {
$this->sharedWithYouPage->waitForAjaxCallsToStartAndFinish($this->getSession());
$this->assertShareIsInStateOnWebUI($item, $state);
}


/**
* @Then the public link with name :entryName should not be in the public links list
*
* @param string $entryName
*
* @return void
*/
public function thePublicLinkWithNameShouldNotBeInPublicLinksList($entryName) {
$this->sharingDialog->checkThatNameIsNotInPublicLinkList($this->getSession(), $entryName);
}

/**
* @Then the number of public links should be :count
*
* @param integer $count
*
* @return void
*/
public function theNumberOfPublicLinksShouldBe($count) {
$this->sharingDialog->checkPublicLinkCount($this->getSession(), $count);
}

/**
* @Then /^it should not be possible to share (?:file|folder) "([^"]*)"(?: with "([^"]*)")? using the webUI$/
*
Expand Down
56 changes: 51 additions & 5 deletions tests/acceptance/features/lib/FilesPageElement/SharingDialog.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ class SharingDialog extends OwncloudPage {
private $publicLinksTabContentXpath = "//div[@id='shareDialogLinkList']";
private $noSharingMessageXpath = "//div[@class='noSharingPlaceholder']";
private $publicLinkRemoveBtnXpath = "//div[contains(@class, 'removeLink')]";

private $publicLinkTitleXpath = "//span[@class='link-entry--title']";

private $sharedWithGroupAndSharerName = null;
private $publicLinkRemoveDeclineMsg = "No";

Expand Down Expand Up @@ -477,11 +478,12 @@ public function openPublicShareTab(Session $session) {

/**
* @param Session $session
* @param integer $number
*
* @return void
*/
public function removePublicLink(Session $session) {
$this->clickRemoveBtn($session);
public function removePublicLink(Session $session, $number = 1) {
$this->clickRemoveBtn($session, $number);
$ocDialog = $this->getLastOcDialog($session);
$ocDialog->accept($session);
$this->waitForAjaxCallsToStartAndFinish($session);
Expand All @@ -501,11 +503,22 @@ public function cancelRemovePublicLinkOperation(Session $session) {

/**
* @param Session $session
* @param integer $number
*
* @return void
*/
private function clickRemoveBtn(Session $session) {
$publicLinkRemoveBtn = $this->find("xpath", $this->publicLinkRemoveBtnXpath);
private function clickRemoveBtn(Session $session, $number = 1) {
$publicLinkRemoveBtns = $this->findAll("xpath", $this->publicLinkRemoveBtnXpath);
$this->assertElementNotNull(
$publicLinkRemoveBtns,
__METHOD__ .
" xpath $this->publicLinkRemoveBtnXpath " .
"could not find public link remove buttons"
);
if ($number < 1) {
throw new \Exception("Position cannot be less than 1");
}
$publicLinkRemoveBtn = $publicLinkRemoveBtns[$number - 1];
$this->assertElementNotNull(
$publicLinkRemoveBtn,
__METHOD__ .
Expand All @@ -525,6 +538,39 @@ private function getLastOcDialog(Session $session) {
return \end($ocDialogs);
}

/**
*
* @param Session $session
* @param string $entryName
*
* @throws \Exception
*
* @return void
*/
public function checkThatNameIsNotInPublicLinkList(Session $session, $entryName) {
$publicLinkTitles = $this->findAll("xpath", $this->publicLinkTitleXpath);
foreach ($publicLinkTitles as $publicLinkTitle) {
if ($entryName === $publicLinkTitle->getText()) {
throw new \Exception("Public link with title" . $entryName . "is present");
}
}
}

/**
*
* @param Session $session
* @param integer $count
*
* @throws \Exception
*
* @return void
*/
public function checkPublicLinkCount(Session $session, $count) {
$publicLinkTitles = $this->findAll("xpath", $this->publicLinkTitleXpath);
if (\count($publicLinkTitles) != $count) {
throw new \Exception("Found $publicLinkTitlesCount public link entries but expected $count");
}
}
/**
* waits for the dialog to appear
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,4 +293,37 @@ Feature: Share by public link
Given the user has created a new public link for file "lorem.txt" using the webUI
When the user tries to remove the public link of file "lorem.txt" but later cancels the remove dialog using webUI
And the public accesses the last created public link using the webUI
Then the content of the file shared by the last public link should be the same as "lorem.txt"
Then the content of the file shared by the last public link should be the same as "lorem.txt"

Scenario: user creates a multiple public link of a file and delete the first link
Given the user has created a new public link for file "lorem.txt" using the webUI with
| name | first-link |
And the user has created a new public link for file "lorem.txt" using the webUI with
| name | second-link |
And the user has created a new public link for file "lorem.txt" using the webUI with
| name | third-link |
When the user removes the public link at position 1 of file "lorem.txt" using the webUI
Then the public link with name "first-link" should not be in the public links list
And the number of public links should be 2

Scenario: user creates a multiple public link of a file and delete the second link
Given the user has created a new public link for file "lorem.txt" using the webUI with
| name | first-link |
And the user has created a new public link for file "lorem.txt" using the webUI with
| name | second-link |
And the user has created a new public link for file "lorem.txt" using the webUI with
| name | third-link |
When the user removes the public link at position 2 of file "lorem.txt" using the webUI
Then the public link with name "second-link" should not be in the public links list
And the number of public links should be 2

Scenario: user creates a multiple public link of a file and delete the third link
Given the user has created a new public link for file "lorem.txt" using the webUI with
| name | first-link |
And the user has created a new public link for file "lorem.txt" using the webUI with
| name | second-link |
And the user has created a new public link for file "lorem.txt" using the webUI with
| name | third-link |
When the user removes the public link at position 3 of file "lorem.txt" using the webUI
Then the public link with name "third-link" should not be in the public links list
And the number of public links should be 2

0 comments on commit cdce56b

Please sign in to comment.