From 0f31ed196a038720e133a1d738fc203cfaf7a3b5 Mon Sep 17 00:00:00 2001 From: Swikriti Tripathi <41103328+SwikritiT@users.noreply.github.com> Date: Fri, 10 Feb 2023 16:30:07 +0545 Subject: [PATCH] fix flaky test apiSpacesShares/shareSpaces.feature:42 (#5545) --- .../features/bootstrap/SpacesContext.php | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/tests/acceptance/features/bootstrap/SpacesContext.php b/tests/acceptance/features/bootstrap/SpacesContext.php index 7b7e5deaea..3221397ab2 100644 --- a/tests/acceptance/features/bootstrap/SpacesContext.php +++ b/tests/acceptance/features/bootstrap/SpacesContext.php @@ -3278,17 +3278,13 @@ class SpacesContext implements Context { ); Assert::assertIsArray($spaceAsArray = $this->getSpaceByNameFromResponse($spaceName), "No space with name $spaceName found"); $recipientType === 'user' ? $recipientId = $this->getUserIdByUserName($recipient) : $recipientId = $this->getGroupIdByGroupName($recipient); - - $recipientId = $this->getUserIdByUserName($user); + $foundRoleInResponse = false; foreach ($spaceAsArray['root']['permissions'] as $permission) { - $foundRoleInResponse = false; - if (\array_key_exists($recipientType, $permission['grantedToIdentities'][0])) { - if ($permission['roles'][0] === $role || $permission['grantedToIdentities'][0][$recipientType]['id'] === $recipientId) { - $foundRoleInResponse = true; - break; - } - Assert::assertTrue($foundRoleInResponse, "the response does not contain the $recipientType $recipient"); + if (isset($permission['grantedToIdentities'][0][$recipientType]) && $permission['roles'][0] === $role && $permission['grantedToIdentities'][0][$recipientType]['id'] === $recipientId) { + $foundRoleInResponse = true; + break; } } + Assert::assertTrue($foundRoleInResponse, "the response does not contain the $recipientType $recipient"); } }