From c0255880ee4b4b3cb74519dba484ab45e7d670b0 Mon Sep 17 00:00:00 2001 From: Saw-jan Date: Mon, 22 Sep 2025 13:50:45 +0545 Subject: [PATCH] test: wait for share to sync Signed-off-by: Saw-jan --- .../acceptance/TestHelpers/SettingsHelper.php | 1 + .../acceptance/bootstrap/SharingNgContext.php | 20 ++++++++++++------- tests/acceptance/bootstrap/SpacesContext.php | 6 +++++- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/tests/acceptance/TestHelpers/SettingsHelper.php b/tests/acceptance/TestHelpers/SettingsHelper.php index 5fffdae07be..0c3842c025c 100644 --- a/tests/acceptance/TestHelpers/SettingsHelper.php +++ b/tests/acceptance/TestHelpers/SettingsHelper.php @@ -273,6 +273,7 @@ class SettingsHelper { $valuesList = HttpRequestHelper::getJsonDecodedResponseBodyContent($response); if (empty($valuesList)) { + // default is true return true; } diff --git a/tests/acceptance/bootstrap/SharingNgContext.php b/tests/acceptance/bootstrap/SharingNgContext.php index 5ad85cfa176..967bd9b01aa 100644 --- a/tests/acceptance/bootstrap/SharingNgContext.php +++ b/tests/acceptance/bootstrap/SharingNgContext.php @@ -390,7 +390,7 @@ class SharingNgContext implements Context { * share the drive (space) using the drives.root endpoint * * @param string $user - * @param TableNode $table + * @param array $rows * @param bool $federatedShare * * @return ResponseInterface @@ -401,11 +401,10 @@ class SharingNgContext implements Context { */ public function sendDriveShareInvitation( string $user, - TableNode $table, + array $rows, bool $federatedShare = false, ): ResponseInterface { $shareeIds = []; - $rows = $table->getRowsHash(); $space = $this->spacesContext->getSpaceByName($user, $rows['space']); $spaceId = $space['id']; @@ -468,6 +467,13 @@ class SharingNgContext implements Context { ); $response = $this->sendShareInvitation($user, $rows); $this->featureContext->theHTTPStatusCodeShouldBe(200, "", $response); + // wait till the share is available to the sharee + if ($rows['shareType'] === 'user' && $rows['permissionsRole'] !== 'Denied') { + $status = $this->featureContext->getUserAutoSyncSetting($rows['sharee']) ? "enabled" : "disabled"; + $resourcePaths = explode('/', $rows['resource']); + $resource = array_pop($resourcePaths); + $this->waitAndCheckShareSyncStatus($rows['sharee'], $resource, $status); + } } /** @@ -511,7 +517,7 @@ class SharingNgContext implements Context { $rows, "'resource' should not be provided in the data-table while sharing a space", ); - $response = $this->sendDriveShareInvitation($user, $table); + $response = $this->sendDriveShareInvitation($user, $table->getRowsHash()); $this->featureContext->theHTTPStatusCodeShouldBe(200, "", $response); } @@ -1852,7 +1858,7 @@ class SharingNgContext implements Context { string $user, TableNode $table, ): void { - $response = $this->sendDriveShareInvitation($user, $table); + $response = $this->sendDriveShareInvitation($user, $table->getRowsHash()); $this->featureContext->setResponse($response); } @@ -1869,7 +1875,7 @@ class SharingNgContext implements Context { string $user, TableNode $table, ): void { - $response = $this->sendDriveShareInvitation($user, $table, true); + $response = $this->sendDriveShareInvitation($user, $table->getRowsHash(), true); $this->featureContext->setResponse($response); } @@ -2091,7 +2097,7 @@ class SharingNgContext implements Context { $roleAllowed = GraphHelper::getPermissionNameByPermissionRoleId($role->id); $responseSendInvitation = $this->sendDriveShareInvitation( $user, - new TableNode(array_merge($table->getTable(), [['permissionsRole', $roleAllowed]])), + array_merge($rows, ['permissionsRole' => $roleAllowed]), ); $jsonResponseSendInvitation = $this->featureContext->getJsonDecodedResponseBodyContent( $responseSendInvitation, diff --git a/tests/acceptance/bootstrap/SpacesContext.php b/tests/acceptance/bootstrap/SpacesContext.php index 938d5be09ab..46cebf923ce 100644 --- a/tests/acceptance/bootstrap/SpacesContext.php +++ b/tests/acceptance/bootstrap/SpacesContext.php @@ -2059,7 +2059,11 @@ class SpacesContext implements Context { } } - $encodedName = \rawurlencode(ltrim($fileSource, "/")); + $sourcePath = explode('/', ltrim($fileSource, "/")); + foreach ($sourcePath as $key => $part) { + $sourcePath[$key] = \rawurlencode($part); + } + $encodedName = implode('/', $sourcePath); $baseUrl = $this->featureContext->getBaseUrl(); $davPath = WebdavHelper::getDavPath(WebDavHelper::DAV_VERSION_SPACES, $space["id"]); $fullUrl = "$baseUrl/$davPath/$encodedName";