From 8f00e9cb6060133075d85dbccef7f71fde4732a8 Mon Sep 17 00:00:00 2001 From: Salipa-Gurung Date: Mon, 5 Aug 2024 12:41:18 +0545 Subject: [PATCH 1/2] add test to check move activity of file --- .../features/apiGraph/activities.feature | 116 ++++++++++++++++++ 1 file changed, 116 insertions(+) diff --git a/tests/acceptance/features/apiGraph/activities.feature b/tests/acceptance/features/apiGraph/activities.feature index 7abf36c41..6b2f0d031 100644 --- a/tests/acceptance/features/apiGraph/activities.feature +++ b/tests/acceptance/features/apiGraph/activities.feature @@ -367,3 +367,119 @@ Feature: check activities } } """ + + @issue-9712 + Scenario: check move activity for a file + Given user "Alice" has uploaded file with content "ownCloud test text file 0" to "/textfile0.txt" + And user "Alice" has created folder "/New Folder" + And user "Alice" has moved file "textfile0.txt" to "New Folder/textfile0.txt" + When user "Alice" lists the activities for file "New Folder/textfile0.txt" of space "Personal" using the Graph API + Then the HTTP status code should be "200" + And the JSON data of the response should match + """ + { + "type": "object", + "required": ["value"], + "properties": { + "value": { + "type": "array", + "minItems": 2, + "maxItems": 2, + "uniqueItems": true, + "items": { + "oneOf": [ + { + "type": "object", + "required": ["id","template","times"], + "properties": { + "template": { + "type": "object", + "required": ["message","variables"], + "properties": { + "message": { + "const": "{user} added {resource} to {space}" + } + } + } + } + }, + { + "type": "object", + "required": ["id","template","times"], + "properties": { + "id": { + "type": "string", + "pattern": "^%user_id_pattern%$" + }, + "template": { + "type": "object", + "required": ["message","variables"], + "properties": { + "message": { + "const": "{user} moved {resource} to {space}" + }, + "variables": { + "type": "object", + "required": ["resource","space","user"], + "properties": { + "resource": { + "type": "object", + "required": ["id","name"], + "properties": { + "id": { + "type": "string", + "pattern": "^%file_id_pattern%$" + }, + "name": { + "const": "textfile0.txt" + } + } + }, + "space": { + "type": "object", + "required": ["id","name"], + "properties": { + "id": { + "type": "string", + "pattern": "^%user_id_pattern%!%user_id_pattern%$" + }, + "name": { + "const": "Alice Hansen" + } + } + }, + "user": { + "type": "object", + "required": ["id","displayName"], + "properties": { + "id": { + "type": "string", + "pattern": "%user_id_pattern%" + }, + "displayName": { + "const": "Alice" + } + } + } + } + } + } + }, + "times": { + "type": "object", + "required": ["recordedTime"], + "properties": { + "recordedTime": { + "type": "string", + "format": "date-time" + } + } + } + } + } + ] + } + } + } + } + """ From 6c4c8bdffa0a326e893ad715067363727e670536 Mon Sep 17 00:00:00 2001 From: Salipa-Gurung Date: Mon, 12 Aug 2024 16:10:51 +0545 Subject: [PATCH 2/2] refactor test steps --- .../features/apiGraph/activities.feature | 48 ++----------------- .../features/bootstrap/GraphContext.php | 6 +-- 2 files changed, 8 insertions(+), 46 deletions(-) diff --git a/tests/acceptance/features/apiGraph/activities.feature b/tests/acceptance/features/apiGraph/activities.feature index 6b2f0d031..9d299f894 100644 --- a/tests/acceptance/features/apiGraph/activities.feature +++ b/tests/acceptance/features/apiGraph/activities.feature @@ -9,7 +9,7 @@ Feature: check activities @issue-9712 Scenario: check activities after uploading a file Given user "Alice" has uploaded file with content "ownCloud test text file 0" to "/textfile0.txt" - When user "Alice" checks the activities for file "textfile0.txt" in space "Personal" using the Graph API + When user "Alice" lists the activities for file "textfile0.txt" of space "Personal" using the Graph API Then the HTTP status code should be "200" And the JSON data of the response should match """ @@ -103,8 +103,8 @@ Feature: check activities @issue-9712 Scenario: check activities after deleting a file Given user "Alice" has uploaded file with content "ownCloud test text file 0" to "/textfile0.txt" - When user "Alice" deletes file "/textfile0.txt" using the WebDAV API - And user "Alice" lists the activities of space "Personal" using the Graph API + And user "Alice" has deleted file "textfile0.txt" + When user "Alice" lists the activities of space "Personal" using the Graph API Then the HTTP status code should be "200" And the JSON data of the response should match """ @@ -129,27 +129,8 @@ Feature: check activities "properties": { "message": { "const": "{user} added {resource} to {space}" - }, - "variables": { - "type": "object", - "required": ["resource","space","user"], - "properties": { - "resource": { - "type": "object", - "required": ["id", "name"], - "properties": { - "name": { - "const": "textfile0.txt" - } - } - } - } } } - }, - "times": { - "type": "object", - "required": ["recordedTime"] } } }, @@ -237,8 +218,8 @@ Feature: check activities @issue-9712 Scenario: check activities after deleting a folder Given user "Alice" has created folder "/FOLDER" - When user "Alice" deletes folder "/FOLDER" using the WebDAV API - And user "Alice" lists the activities of space "Personal" using the Graph API + And user "Alice" has deleted folder "FOLDER" + When user "Alice" lists the activities of space "Personal" using the Graph API Then the HTTP status code should be "200" And the JSON data of the response should match """ @@ -263,27 +244,8 @@ Feature: check activities "properties": { "message": { "const": "{user} added {resource} to {space}" - }, - "variables": { - "type": "object", - "required": ["resource","space","user"], - "properties": { - "resource": { - "type": "object", - "required": ["id", "name"], - "properties": { - "name": { - "const": "FOLDER" - } - } - } - } } } - }, - "times": { - "type": "object", - "required": ["recordedTime"] } } }, diff --git a/tests/acceptance/features/bootstrap/GraphContext.php b/tests/acceptance/features/bootstrap/GraphContext.php index d01ba2b4e..4da2dd3b7 100644 --- a/tests/acceptance/features/bootstrap/GraphContext.php +++ b/tests/acceptance/features/bootstrap/GraphContext.php @@ -2777,7 +2777,7 @@ class GraphContext implements Context { } /** - * @When /^user "([^"]*)" checks the activities for (?:folder|file) "([^"]*)" in space "([^"]*)" using the Graph API/ + * @When /^user "([^"]*)" lists the activities for (?:folder|file) "([^"]*)" of space "([^"]*)" using the Graph API/ * * @param string $user * @param string $resource @@ -2786,7 +2786,7 @@ class GraphContext implements Context { * @return void * @throws Exception */ - public function userChecksTheActivitiesForResourceInSpaceUsingTheGraphAPI(string $user, string $resource, string $spaceName): void { + public function userListsTheActivitiesForResourceOfSpaceUsingTheGraphAPI(string $user, string $resource, string $spaceName): void { $resourceId = $this->featureContext->spacesContext->getResourceId($user, $spaceName, $resource); $response = GraphHelper::getActivities( $this->featureContext->getBaseUrl(), @@ -2806,7 +2806,7 @@ class GraphContext implements Context { * * @return void */ - public function userListsTheActivitiesInSpaceUsingTheGraphApi(string $user, string $spaceName): void { + public function userListsTheActivitiesOfSpaceUsingTheGraphApi(string $user, string $spaceName): void { $spaceId = ($this->featureContext->spacesContext->getSpaceByName($user, $spaceName))["id"]; $response = GraphHelper::getActivities( $this->featureContext->getBaseUrl(),