From 05fca6b0130004894fd535213ac5b4809728521b Mon Sep 17 00:00:00 2001 From: amrita Date: Wed, 11 Sep 2024 16:13:38 +0545 Subject: [PATCH] add test coverage for wopi with different view mode --- .../bootstrap/CollaborationContext.php | 13 +- .../apiCollaboration/checkFileInfo.feature | 299 ++++++++++++++++++ 2 files changed, 309 insertions(+), 3 deletions(-) diff --git a/tests/acceptance/bootstrap/CollaborationContext.php b/tests/acceptance/bootstrap/CollaborationContext.php index 8f7e30e6aa..d005827aa1 100644 --- a/tests/acceptance/bootstrap/CollaborationContext.php +++ b/tests/acceptance/bootstrap/CollaborationContext.php @@ -52,22 +52,29 @@ class CollaborationContext implements Context { /** * @When user :user checks the information of file :file of space :space using office :app + * @When user :user checks the information of file :file of space :space using office :app with view mode :view * * @param string $user * @param string $file * @param string $space * @param string $app + * @param string|null $viewMode * * @return void * * @throws GuzzleException - * @throws JsonException */ - public function userChecksTheInformationOfFileOfSpaceUsingOffice(string $user, string $file, string $space, string $app): void { + public function userChecksTheInformationOfFileOfSpaceUsingOffice(string $user, string $file, string $space, string $app, string $viewMode = null): void { $fileId = $this->spacesContext->getFileId($user, $space, $file); + $url = $this->featureContext->getBaseUrl() . "/app/open?app_name=$app&file_id=$fileId"; + + if ($viewMode) { + $url .= "&view_mode=$viewMode"; + } + $response = \json_decode( HttpRequestHelper::post( - $this->featureContext->getBaseUrl() . "/app/open?app_name=$app&file_id=$fileId", + $url, $this->featureContext->getStepLineRef(), $this->featureContext->getActualUsername($user), $this->featureContext->getPasswordForUser($user), diff --git a/tests/acceptance/features/apiCollaboration/checkFileInfo.feature b/tests/acceptance/features/apiCollaboration/checkFileInfo.feature index b375069c5d..e243dd259d 100644 --- a/tests/acceptance/features/apiCollaboration/checkFileInfo.feature +++ b/tests/acceptance/features/apiCollaboration/checkFileInfo.feature @@ -289,3 +289,302 @@ Feature: check file info with different wopi apps } } """ + + + Scenario Outline: check file info with different mode (onlyOffice) + Given user "Alice" has uploaded file with content "hello world" to "/textfile0.txt" + When user "Alice" checks the information of file "textfile0.txt" of space "Personal" using office "OnlyOffice" with view mode "" + Then the HTTP status code should be "200" + And the JSON data of the response should match + """ + { + "type": "object", + "required": [ + "BaseFileName", + "Version", + "BreadcrumbDocName", + "BreadcrumbFolderName", + "BreadcrumbFolderUrl", + "PostMessageOrigin", + "DisablePrint", + "UserFriendlyName", + "UserId", + "ReadOnly", + "UserCanNotWriteRelative", + "UserCanRename", + "UserCanWrite", + "SupportsLocks", + "SupportsRename", + "SupportsUpdate" + ], + "properties": { + "BaseFileName": { + "const": "textfile0.txt" + }, + "UserId": { + "type": "string" + }, + "Version": { + "type": "string" + }, + "SupportsLocks": { + "const": true + }, + "SupportsRename": { + "const": true + }, + "SupportsUpdate": { + "const": true + }, + "UserFriendlyName": { + "const": "Alice Hansen" + }, + "ReadOnly": { + "const": false + }, + "UserCanNotWriteRelative": { + "const": false + }, + "UserCanRename": { + "const": + }, + "UserCanWrite": { + "const": + }, + "DisablePrint": { + "const": + }, + "BreadcrumbDocName": { + "const": "textfile0.txt" + }, + "BreadcrumbFolderName": { + "const": "Alice Hansen" + }, + "BreadcrumbFolderUrl": { + "type": "string" + }, + "PostMessageOrigin": { + "type": "string" + } + } + } + """ + Examples: + | mode | disable-print | user-can-write | user-can-rename | + | view | true | false | false | + | read | false | false | false | + | write | false | true | true | + + + Scenario Outline: check file info with different mode (fakeOffice) + Given user "Alice" has uploaded file with content "hello world" to "/textfile0.txt" + When user "Alice" checks the information of file "textfile0.txt" of space "Personal" using office "FakeOffice" with view mode "" + Then the HTTP status code should be "200" + And the JSON data of the response should match + """ + { + "type": "object", + "required": [ + "BaseFileName", + "OwnerId", + "Size", + "UserId", + "Version", + "SupportsCobalt", + "SupportsContainers", + "SupportsDeleteFile", + "SupportsEcosystem", + "SupportsExtendedLockLength", + "SupportsFolders", + "SupportsGetLock", + "SupportsLocks", + "SupportsRename", + "SupportsUpdate", + "SupportsUserInfo", + "UserFriendlyName", + "ReadOnly", + "RestrictedWebViewOnly", + "UserCanAttend", + "UserCanNotWriteRelative", + "UserCanPresent", + "UserCanRename", + "UserCanWrite", + "AllowAdditionalMicrosoftServices", + "AllowExternalMarketplace", + "DisablePrint", + "DisableTranslation", + "BreadcrumbDocName" + ], + "properties": { + "BaseFileName": { + "const": "textfile0.txt" + }, + "OwnerId": { + "type": "string" + }, + "Size": { + "const": 11 + }, + "UserId": { + "type": "string" + }, + "Version": { + "type": "string" + }, + "SupportsCobalt": { + "const": false + }, + "SupportsContainers": { + "const": false + }, + "SupportsDeleteFile": { + "const": true + }, + "SupportsEcosystem": { + "const": false + }, + "SupportsExtendedLockLength": { + "const": true + }, + "SupportsFolders": { + "const": false + }, + "SupportsGetLock": { + "const": true + }, + "SupportsLocks": { + "const": true + }, + "SupportsRename": { + "const": true + }, + "SupportsUpdate": { + "const": true + }, + "SupportsUserInfo": { + "const": false + }, + "UserFriendlyName": { + "const": "Alice Hansen" + }, + "ReadOnly": { + "const": false + }, + "RestrictedWebViewOnly": { + "const": false + }, + "UserCanAttend": { + "const": false + }, + "UserCanNotWriteRelative": { + "const": false + }, + "UserCanPresent": { + "const": false + }, + "UserCanRename": { + "const": + }, + "UserCanWrite": { + "const": + }, + "AllowAdditionalMicrosoftServices": { + "const": false + }, + "AllowExternalMarketplace": { + "const": false + }, + "DisablePrint": { + "const": + }, + "DisableTranslation": { + "const": false + }, + "BreadcrumbDocName": { + "const": "textfile0.txt" + } + } + } + """ + Examples: + | mode | disable-print | user-can-write | user-can-rename | + | view | true | false | false | + | read | false | false | false | + | write | false | true | true | + + + Scenario Outline: check file info with different view-mode (collabora) + Given user "Alice" has uploaded file with content "hello world" to "/textfile0.txt" + When user "Alice" checks the information of file "textfile0.txt" of space "Personal" using office "Collabora" with view mode "" + Then the HTTP status code should be "200" + And the JSON data of the response should match + """ + { + "type": "object", + "required": [ + "BaseFileName", + "DisablePrint", + "OwnerId", + "PostMessageOrigin", + "Size", + "UserCanWrite", + "UserCanNotWriteRelative", + "UserId", + "UserFriendlyName", + "EnableOwnerTermination", + "SupportsLocks", + "SupportsRename", + "UserCanRename", + "BreadcrumbDocName" + ], + "properties": { + "BaseFileName": { + "const": "textfile0.txt" + }, + "PostMessageOrigin": { + "const": "https://localhost:9200" + }, + "DisablePrint": { + "const": + }, + "OwnerId": { + "type": "string" + }, + "Size": { + "const": 11 + }, + "UserCanWrite": { + "const": + }, + "UserCanNotWriteRelative": { + "const": false + }, + "EnableOwnerTermination": { + "const": true + }, + "UserId": { + "type": "string" + }, + "SupportsLocks": { + "const": true + }, + "SupportsRename": { + "const": true + }, + "UserFriendlyName": { + "const": "Alice Hansen" + }, + "UserCanRename": { + "const": + }, + "BreadcrumbDocName": { + "const": "textfile0.txt" + } + } + } + """ + Examples: + | mode | disable-print | user-can-write | user-can-rename | + | view | true | false | false | + | read | false | false | false | + | write | false | true | true |