Skip to content

Commit

Permalink
[tests-only][full-ci]refactor for Intermittent test failures on coreA…
Browse files Browse the repository at this point in the history
…piTrashbin/trashbinDelete.feature (#6718)

* assert the response code after listing from trashbin

* set endpoint according to dav path and assert while listing

* php style fix

* changed comment

* changed as reviews
  • Loading branch information
KarunAtreya authored Jul 12, 2023
1 parent db39d6b commit 56c48df
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions tests/acceptance/features/bootstrap/TrashbinContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,21 +231,39 @@ public function listTrashbinFolderCollection(?string $user, ?string $collectionP
'trash-bin',
$davPathVersion
);
$response->getBody()->rewind();
$statusCode = $response->getStatusCode();
$respBody = $response->getBody()->getContents();
Assert::assertEquals("207", $statusCode, "Expected status code to be '207' but got $statusCode \nResponse\n$respBody");

$responseXml = HttpRequestHelper::getResponseXml(
$response,
__METHOD__ . " $collectionPath"
);

$files = $this->getTrashbinContentFromResponseXml($responseXml);

// set endpoint according to webdav request (2 = new, 3 = spaces)
$endpoint = "/remote.php/dav/trash-bin/$user";
if ($davPathVersion === 3) {
$space_id = (WebDavHelper::$SPACE_ID_FROM_OCIS) ?: WebDavHelper::getPersonalSpaceIdForUser(
$this->featureContext->getBaseUrl(),
$user,
$this->featureContext->getPasswordForUser($user),
$this->featureContext->getStepLineRef()
);
$endpoint = "/remote.php/dav/spaces/trash-bin/$space_id";
}

// filter out the collection itself, we only want to return the members
$files = \array_filter(
$files,
static function ($element) use ($user, $collectionPath) {
static function ($element) use ($endpoint, $collectionPath) {
$path = $collectionPath;
if ($path !== "") {
$path = $path . "/";
}
return ($element['href'] !== "/remote.php/dav/trash-bin/$user/$path");
return ($element['href'] !== "$endpoint/$path");
}
);

Expand Down Expand Up @@ -714,11 +732,8 @@ public function asFileOrFolderExistsInTrash(?string $user, ?string $path):void {
* @throws Exception
*/
private function isInTrash(?string $user, ?string $originalPath):bool {
$res = $this->featureContext->getResponse();
$listing = $this->listTrashbinFolder($user);

$this->featureContext->setResponse($res);

// we don't care if the test step writes a leading "/" or not
$originalPath = \ltrim($originalPath, '/');

Expand Down

0 comments on commit 56c48df

Please sign in to comment.