Skip to content

Commit

Permalink
Silence retried to delete file messages
Browse files Browse the repository at this point in the history
  • Loading branch information
phil-davis committed Apr 3, 2018
1 parent b6be432 commit 8d4a1c1
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 15 deletions.
32 changes: 26 additions & 6 deletions tests/acceptance/features/bootstrap/WebUIFilesContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,29 @@ public function theUserRenamesTheFileToOneOfTheseNamesUsingTheWebUI(

}

/**
* Delete a file on the current page. The current page should be one that
* has rows of files.
*
* @param string $name
*
* @param bool $expectToDeleteFile if true, then the caller expects that the file can be deleted
* @return void
* @throws Exception
*/
public function deleteTheFileUsingTheWebUI($name, $expectToDeleteFile = true) {
$pageObject = $this->getCurrentPageObject();
$session = $this->getSession();
$pageObject->waitTillPageIsLoaded($session);
if ($expectToDeleteFile) {
$pageObject->deleteFile($name, $session, $expectToDeleteFile);
} else {
// We do not expect to be able to delete the file,
// so do not waste time doing too many retries.
$pageObject->deleteFile($name, $session, $expectToDeleteFile, MINIMUMRETRYCOUNT);
}
}

/**
* for a folder or individual file that is shared, the receiver of the share
* has an "Unshare" entry in the file actions menu. Clicking it works just
Expand All @@ -371,10 +394,7 @@ public function theUserRenamesTheFileToOneOfTheseNamesUsingTheWebUI(
* @return void
*/
public function theUserDeletesTheFileUsingTheWebUI($name) {
$pageObject = $this->getCurrentPageObject();
$session = $this->getSession();
$pageObject->waitTillPageIsLoaded($session);
$pageObject->deleteFile($name, $session);
$this->deleteTheFileUsingTheWebUI($name);
}

/**
Expand Down Expand Up @@ -458,7 +478,7 @@ public function theUserDeletesTheFollowingElementsUsingTheWebUI(
) {
$this->deletedElementsTable = $table;
foreach ($this->deletedElementsTable as $file) {
$this->theUserDeletesTheFileUsingTheWebUI($file['name']);
$this->deleteTheFileUsingTheWebUI($file['name']);
}
}

Expand Down Expand Up @@ -1040,7 +1060,7 @@ public function folderInputFieldTooltipTextShouldBeDisplayedOnTheWebUI($tooltipt
*/
public function itShouldNotBePossibleToDeleteUsingTheWebUI($name) {
try {
$this->theUserDeletesTheFileUsingTheWebUI($name);
$this->deleteTheFileUsingTheWebUI($name, false);
} catch (ElementNotFoundException $e) {
PHPUnit_Framework_Assert::assertContains(
"could not find button 'Delete' in action Menu",
Expand Down
2 changes: 2 additions & 0 deletions tests/acceptance/features/bootstrap/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,5 @@
const MINIMUMUIWAITTIMEOUTMILLISEC = 500;
// Default number of times to retry where retries are useful
const STANDARDRETRYCOUNT = 5;
// Minimum number of times to retry where retries are useful
const MINIMUMRETRYCOUNT = 2;
27 changes: 18 additions & 9 deletions tests/acceptance/features/lib/FilesPageBasic.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,12 @@ public function openFile($name, Session $session) {
*
* @return void
*/
public function deleteFile($name, Session $session, $maxRetries = STANDARDRETRYCOUNT) {
public function deleteFile(
$name,
Session $session,
$expectToDeleteFile = true,
$maxRetries = STANDARDRETRYCOUNT
) {
$this->initAjaxCounters($session);
$this->resetSumStartedAjaxRequests($session);

Expand All @@ -285,22 +290,26 @@ public function deleteFile($name, Session $session, $maxRetries = STANDARDRETRYC
//if no XHR Request were fired we assume the delete action
//did not work and we retry
if ($countXHRRequests === 0) {
error_log("Error while deleting file");
if ($expectToDeleteFile) {
error_log("Error while deleting file");
}
} else {
break;
}
} catch (\Exception $e) {
$this->closeFileActionsMenu();
error_log(
"Error while deleting file"
. "\n-------------------------\n"
. $e->getMessage()
. "\n-------------------------\n"
);
if ($expectToDeleteFile) {
error_log(
"Error while deleting file"
. "\n-------------------------\n"
. $e->getMessage()
. "\n-------------------------\n"
);
}
usleep(STANDARDSLEEPTIMEMICROSEC);
}
}
if ($counter > 0) {
if ($expectToDeleteFile && ($counter > 0)) {
$message = "INFORMATION: retried to delete file '" . $name . "' " .
$counter . " times";
echo $message;
Expand Down

0 comments on commit 8d4a1c1

Please sign in to comment.