From 56c48df0bd6e3ab59b2ec910c21a6cc77460f292 Mon Sep 17 00:00:00 2001 From: Karun Atreya <33852651+KarunAtreya@users.noreply.github.com> Date: Wed, 12 Jul 2023 12:26:51 +0545 Subject: [PATCH] [tests-only][full-ci]refactor for Intermittent test failures on coreApiTrashbin/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 --- .../features/bootstrap/TrashbinContext.php | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/tests/acceptance/features/bootstrap/TrashbinContext.php b/tests/acceptance/features/bootstrap/TrashbinContext.php index 1eb3310af8e..ef098f3d125 100644 --- a/tests/acceptance/features/bootstrap/TrashbinContext.php +++ b/tests/acceptance/features/bootstrap/TrashbinContext.php @@ -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"); } ); @@ -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, '/');