From c31a0ed6b26f30c0a8e019391351c0b63cd11669 Mon Sep 17 00:00:00 2001 From: "sagargurung1001@gmail.com" Date: Thu, 1 Sep 2022 14:19:11 +0545 Subject: [PATCH 1/2] Reuse code of code from core at most --- .../features/bootstrap/SpacesContext.php | 49 +++---------------- 1 file changed, 7 insertions(+), 42 deletions(-) diff --git a/tests/acceptance/features/bootstrap/SpacesContext.php b/tests/acceptance/features/bootstrap/SpacesContext.php index 7a278ea5e..c491c582a 100644 --- a/tests/acceptance/features/bootstrap/SpacesContext.php +++ b/tests/acceptance/features/bootstrap/SpacesContext.php @@ -60,6 +60,11 @@ class SpacesContext implements Context { */ private WebDavPropertiesContext $webDavPropertiesContext; + /** + * @var FavoritesContext + */ + private FavoritesContext $favoritesContext; + /** * @var string */ @@ -430,6 +435,7 @@ class SpacesContext implements Context { $this->ocsContext = $environment->getContext('OCSContext'); $this->trashbinContext = $environment->getContext('TrashbinContext'); $this->webDavPropertiesContext = $environment->getContext('WebDavPropertiesContext'); + $this->favoritesContext = $environment->getContext('FavoritesContext'); // Run the BeforeScenario function in OCSContext to set it up correctly $this->ocsContext->before($scope); $this->baseUrl = \trim($this->featureContext->getBaseUrl(), "/"); @@ -618,28 +624,6 @@ class SpacesContext implements Context { return HttpRequestHelper::sendRequest($fullUrl, $xRequestId, $method, $user, $password, $headers); } - /** - * send proppatch request to url - * - * @param string $fullUrl - * @param string $user - * @param string $password - * @param string $xRequestId - * @param array $headers - * @param mixed|null $body - * @return ResponseInterface - */ - public function sendPropPatchRequest( - string $fullUrl, - string $user, - string $password, - string $xRequestId = '', - array $headers = [], - $body - ): ResponseInterface { - return HttpRequestHelper::sendRequest($fullUrl, $xRequestId, 'PROPPATCH', $user, $password, $headers, $body); - } - /** * @When /^user "([^"]*)" lists all available spaces via the GraphApi$/ * @When /^user "([^"]*)" lists all available spaces via the GraphApi with query "([^"]*)"$/ @@ -3276,25 +3260,6 @@ class SpacesContext implements Context { */ public function userFavoritesElementInSpaceUsingTheWebdavApi(string $user, string $path, string $spaceName): void { $space = $this->getSpaceByName($user, $spaceName); - $fullUrl = $space["root"]["webDavUrl"] . '/' . ltrim($path, "/"); - $body = ' - - - - 1 - - - '; - $this->featureContext->setResponse( - $this->sendProppatchRequest( - $fullUrl, - $user, - $this->featureContext->getPasswordForUser($user), - $this->featureContext->getStepLineRef(), - [], - $body - ) - ); + $this->favoritesContext->userFavoritesElement($user, $path, $space['id']); } } From 84c48066f2ca0a30e7079443b11d220b49872e80 Mon Sep 17 00:00:00 2001 From: "sagargurung1001@gmail.com" Date: Thu, 1 Sep 2022 14:28:53 +0545 Subject: [PATCH 2/2] Add commit and branch related to this PR to work --- .drone.env | 2 +- tests/acceptance/config/behat.yml | 1 + .../features/bootstrap/SpacesContext.php | 19 +++++++++++++++++-- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.drone.env b/.drone.env index a80f33a3e..40dc6e216 100644 --- a/.drone.env +++ b/.drone.env @@ -1,5 +1,5 @@ # The test runner source for API tests -CORE_COMMITID=d8ed82769fc422c38d6f6bc21253a052eef5e239 +CORE_COMMITID=b51fb4c01f08763e023aece4f90308e07a7ac73f CORE_BRANCH=master # The test runner source for UI tests diff --git a/tests/acceptance/config/behat.yml b/tests/acceptance/config/behat.yml index 218518da2..2ec0d2630 100644 --- a/tests/acceptance/config/behat.yml +++ b/tests/acceptance/config/behat.yml @@ -61,6 +61,7 @@ default: - FilesVersionsContext: - OCSContext: - PublicWebDavContext: + - FavoritesContext: - TrashbinContext: - WebDavPropertiesContext: diff --git a/tests/acceptance/features/bootstrap/SpacesContext.php b/tests/acceptance/features/bootstrap/SpacesContext.php index c491c582a..bba15fba5 100644 --- a/tests/acceptance/features/bootstrap/SpacesContext.php +++ b/tests/acceptance/features/bootstrap/SpacesContext.php @@ -269,6 +269,21 @@ class SpacesContext implements Context { return $spaces[$spaceName]; } + /** + * This method sets space id by Space Name + * This is currently used to set space id from ocis in core so that we can reuse available resource (code) and avoid duplication + * + * @param string $user + * @param string $spaceName + * + * @return void + * @throws GuzzleException + */ + public function setSpaceIDByName(string $user, string $spaceName): void { + $space = $this->getSpaceByName($user, $spaceName); + WebDavHelper::$SPACE_ID_FROM_OCIS = $space['id']; + } + /** * The method finds available spaces to the manager user and returns the space by spaceName * @@ -3259,7 +3274,7 @@ class SpacesContext implements Context { * @throws GuzzleException */ public function userFavoritesElementInSpaceUsingTheWebdavApi(string $user, string $path, string $spaceName): void { - $space = $this->getSpaceByName($user, $spaceName); - $this->favoritesContext->userFavoritesElement($user, $path, $space['id']); + $this->setSpaceIDByName($user, $spaceName); + $this->favoritesContext->userFavoritesElement($user, $path); } }