From 16e75767d65dedd64b6dbaf58e5d5b2e4feaff75 Mon Sep 17 00:00:00 2001 From: nirajacharya2 Date: Wed, 28 Jun 2023 16:03:56 +0545 Subject: [PATCH] added test for mail notification if space admin delete access to space --- .../apiNotification/emailNotification.feature | 21 +++++++++++++++++++ .../bootstrap/NotificationContext.php | 4 ++-- .../features/bootstrap/SpacesContext.php | 18 ++++++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/tests/acceptance/features/apiNotification/emailNotification.feature b/tests/acceptance/features/apiNotification/emailNotification.feature index 98e097107ed..391d3289c45 100644 --- a/tests/acceptance/features/apiNotification/emailNotification.feature +++ b/tests/acceptance/features/apiNotification/emailNotification.feature @@ -70,3 +70,24 @@ Feature: Email notification Click here to view it: %base_url%/f/%space_id% """ + + + Scenario: user gets an email notification when space admin unshares a space + Given 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 GraphApi + And user "Alice" shares a space "new-space" with settings: + | shareWith | Brian | + | role | Editor | + And the HTTP status code should be "200" + When user "Alice" unshares a space "new-space" to user "Brian" + Then the HTTP status code should be "200" + And user "Brian" should have received the following email from user "Alice" about the share of project space "new-space" + """ + Hello Brian Murphy, + + %displayname% has removed you from "new-space". + + You might still have access through your other groups or direct membership. + + Click here to check it: %base_url%/f/%space_id% + """ diff --git a/tests/acceptance/features/bootstrap/NotificationContext.php b/tests/acceptance/features/bootstrap/NotificationContext.php index 4c6fa61994c..6836096a02c 100644 --- a/tests/acceptance/features/bootstrap/NotificationContext.php +++ b/tests/acceptance/features/bootstrap/NotificationContext.php @@ -217,8 +217,8 @@ public function userShouldHaveReceivedTheFollowingEmailFromUserAboutTheShareOfPr [ "code" => "%space_id%", "function" => - [$this->spacesContext, "getSpaceIdByNameFromResponse"], - "parameter" => [$spaceName] + [$this->spacesContext, "getSpaceIdByName"], + "parameter" => [$sender, $spaceName] ], ], null, diff --git a/tests/acceptance/features/bootstrap/SpacesContext.php b/tests/acceptance/features/bootstrap/SpacesContext.php index 3c446abc63b..4e49fd7f82c 100644 --- a/tests/acceptance/features/bootstrap/SpacesContext.php +++ b/tests/acceptance/features/bootstrap/SpacesContext.php @@ -204,6 +204,24 @@ public function getSpaceByName(string $user, string $spaceName): array { return $spaces[$spaceName]; } + /** + * The method finds available spaces to the user and returns the space by spaceId + * + * @param string $user + * @param string $spaceName + * + * @return string + * @throws GuzzleException + */ + public function getSpaceIdByName(string $user, string $spaceName): string { + $space = $this->getSpaceByName($user, $spaceName); + Assert::assertIsArray($space, "Space with name $spaceName not found"); + if (!isset($space["id"])) { + throw new Exception(__METHOD__ . " space with name $spaceName not found"); + } + return $space["id"]; + } + /** * 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