From 17602408c64bd64cb6f681b41f8276699386483e Mon Sep 17 00:00:00 2001 From: amrita Date: Wed, 24 May 2023 14:41:54 +0545 Subject: [PATCH] Extend notification tests scenario for different language --- .../apiNotification/notification.feature | 43 +++++++++++++++++++ .../bootstrap/NotificationContext.php | 12 ++++++ .../acceptance/features/bootstrap/WebDav.php | 16 +++---- 3 files changed, 62 insertions(+), 9 deletions(-) diff --git a/tests/acceptance/features/apiNotification/notification.feature b/tests/acceptance/features/apiNotification/notification.feature index a0a364df324..3f4ef2d4811 100644 --- a/tests/acceptance/features/apiNotification/notification.feature +++ b/tests/acceptance/features/apiNotification/notification.feature @@ -240,3 +240,46 @@ Feature: Notification | resource | | textfile1.txt | | my_data | + + + Scenario Outline: user gets a notification of personal resource sharing in different languages + Given user "Brian" has switched the system language to "" + And user "Alice" has shared entry "textfile1.txt" with user "Brian" with permissions "17" + When user "Brian" lists all notifications + Then the HTTP status code should be "200" + And the JSON response should contain a notification message with the subject "" and the message-details should match + """ + { + "type": "object", + "required": [ + "message" + ], + "properties": { + "message": { + "type": "string", + "enum": [ + "" + ] + } + } + } + """ + Examples: + | language | subject | message | + | de | Neue Freigabe | Alice Hansen hat textfile1.txt mit Ihnen geteilt | + | en | Resource shared | Alice Hansen shared textfile1.txt with you | + | es | Recurso compartido | Alice Hansen compartió textfile1.txt contigo | + + + Scenario Outline: all notification related to certain resources gets deleted when sharer deletes shared resource + Given user "Alice" has shared entry "" with user "Brian" + And user "Brian" has accepted share "/" offered by user "Alice" + And user "Alice" has unshared entity "" shared to "Brian" + And user "Alice" has deleted entity "/" + When user "Brian" lists all notifications + Then the HTTP status code should be "200" + And the JSON response should not contain any notification + Examples: + | resource | + | textfile1.txt | + | my_data | diff --git a/tests/acceptance/features/bootstrap/NotificationContext.php b/tests/acceptance/features/bootstrap/NotificationContext.php index 011faa688cf..38951bad62f 100644 --- a/tests/acceptance/features/bootstrap/NotificationContext.php +++ b/tests/acceptance/features/bootstrap/NotificationContext.php @@ -104,6 +104,18 @@ public function userListAllNotifications(string $user):void { $this->featureContext->setResponse($response); } + /** + * @Then the JSON response should not contain any notification + * + * @return void + * @throws Exception + */ + public function theJsonResponseShouldNotContainNotification(): void { + if ($this->featureContext->getJsonDecodedResponseBodyContent()->ocs->data !== null) { + throw new Exception("response should not contain any notification"); + } + } + /** * @Then /^the JSON response should contain a notification message with the subject "([^"]*)" and the message-details should match$/ * diff --git a/tests/acceptance/features/bootstrap/WebDav.php b/tests/acceptance/features/bootstrap/WebDav.php index 49c3a0ad6f5..2bf82133033 100644 --- a/tests/acceptance/features/bootstrap/WebDav.php +++ b/tests/acceptance/features/bootstrap/WebDav.php @@ -3354,16 +3354,16 @@ public function userDeletesFile(string $user, string $file):void { } /** - * @Given /^user "([^"]*)" has (deleted|unshared) (file|folder) "([^"]*)"$/ + * @Given /^user "([^"]*)" has (deleted|unshared) (?:file|folder|entity) "([^"]*)"$/ * * @param string $user * @param string $deletedOrUnshared - * @param string $fileOrFolder * @param string $entry * * @return void + * @throws Exception */ - public function userHasDeletedFile(string $user, string $deletedOrUnshared, string $fileOrFolder, string $entry):void { + public function userHasDeletedFile(string $user, string $deletedOrUnshared, string $entry):void { $user = $this->getActualUsername($user); $this->userDeletesFile($user, $entry); // If the file or folder was there and got deleted then we get a 204 @@ -3380,30 +3380,28 @@ public function userHasDeletedFile(string $user, string $deletedOrUnshared, stri $this->theHTTPStatusCodeShouldBe( ["204"], - "HTTP status code was not 204 while trying to $deleteText $fileOrFolder '$entry' for user '$user'" + "HTTP status code was not 204 while trying to $deleteText resource '$entry' for user '$user'" ); $this->emptyLastHTTPStatusCodesArray(); } /** - * @Given /^user "([^"]*)" has (deleted|unshared) the following (files|folders|resources)$/ + * @Given /^user "([^"]*)" has (deleted|unshared) the following (?:files|folders|resources)$/ * * @param string $user * @param string $deletedOrUnshared - * @param string $fileOrFolder * @param TableNode $table * * @return void * @throws Exception */ - public function userHasDeletedFollowingFiles(string $user, string $deletedOrUnshared, string $fileOrFolder, TableNode $table):void { + public function userHasDeletedFollowingFiles(string $user, string $deletedOrUnshared, TableNode $table):void { $this->verifyTableNodeColumns($table, ["path"]); $paths = $table->getHash(); foreach ($paths as $file) { - $this->userHasDeletedFile($user, $deletedOrUnshared, $fileOrFolder, $file["path"]); + $this->userHasDeletedFile($user, $deletedOrUnshared, $file["path"]); } - $this->emptyLastHTTPStatusCodesArray(); } /**