From 86105b86af08e3c082628cfb5244a2f39fd65bee Mon Sep 17 00:00:00 2001 From: Nalem7 <61624650+nabim777@users.noreply.github.com> Date: Fri, 14 Aug 2026 12:11:34 +0545 Subject: [PATCH] [tests-only][full-ci] test: add retry once for space creation wherever required (#12785) test: add retry once for space creation Signed-off-by: nabim777 --- tests/acceptance/bootstrap/SpacesContext.php | 15 ++++++++++++++- .../features/apiCollaboration/wopi.feature | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/tests/acceptance/bootstrap/SpacesContext.php b/tests/acceptance/bootstrap/SpacesContext.php index 8be3fec2367..3a788654b2a 100644 --- a/tests/acceptance/bootstrap/SpacesContext.php +++ b/tests/acceptance/bootstrap/SpacesContext.php @@ -1929,11 +1929,12 @@ class SpacesContext implements Context { } /** - * @Given /^user "([^"]*)" has created a space "([^"]*)"(| in vault)? with the default quota using the Graph API$/ + * @Given /^user "([^"]*)" has created a space "([^"]*)"(| in vault)?(| with retry) with the default quota using the Graph API$/ * * @param string $user * @param string $spaceName * @param string $isVault + * @param string $withRetry * * @return void * @@ -1944,10 +1945,22 @@ class SpacesContext implements Context { string $user, string $spaceName, string $isVault, + string $withRetry, ): void { $space = ["name" => $spaceName]; $isVault = trim($isVault) === "in vault"; + $withRetry = trim($withRetry) === "with retry"; + + // The user role may take some time to update + // This can cause an unauthorized error + // Retry once after 1 second $response = $this->createSpace($user, $space, $isVault); + + if ($withRetry && $response->getStatusCode() === 401) { + sleep(1); // Wait 1 second before retrying. + $response = $this->createSpace($user, $space, $isVault); + } + $this->featureContext->theHTTPStatusCodeShouldBe( 201, "Expected response status code should be 201 (Created)", diff --git a/tests/acceptance/features/apiCollaboration/wopi.feature b/tests/acceptance/features/apiCollaboration/wopi.feature index 4170951de8b..860fe81f4e3 100644 --- a/tests/acceptance/features/apiCollaboration/wopi.feature +++ b/tests/acceptance/features/apiCollaboration/wopi.feature @@ -834,7 +834,7 @@ Feature: collaboration (wopi) Scenario: user with Viewer role tries to create a odt file inside shared project space using wopi endpoint Given using spaces DAV path And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API - And user "Alice" has created a space "new-space" with the default quota using the Graph API + And user "Alice" has created a space "new-space" with retry with the default quota using the Graph API And user "Alice" has created a folder "testFolder" in space "new-space" And user "Alice" has sent the following space share invitation: | space | new-space |