diff --git a/tests/acceptance/bootstrap/CollaborationContext.php b/tests/acceptance/bootstrap/CollaborationContext.php index 006430d206..026a3df94c 100644 --- a/tests/acceptance/bootstrap/CollaborationContext.php +++ b/tests/acceptance/bootstrap/CollaborationContext.php @@ -355,4 +355,79 @@ class CollaborationContext implements Context { } } } + + /** + * @Then the app list response should contain the following information: + * + * @param TableNode $table + * + * @return void + * @throws Exception + */ + public function theAppListResponseShouldContainTheFollowingInformation(TableNode $table): void { + $responseArray = $this->featureContext->getJsonDecodedResponse($this->featureContext->getResponse()); + + if (!isset($responseArray['mime-types'])) { + throw new Exception(__METHOD__ . "The response does not contain a 'mime-types' key."); + } + + $mimeTypes = $responseArray['mime-types']; + + $mimeTypeMap = []; + foreach ($mimeTypes as $mimeType) { + $mimeTypeMap[$mimeType['mime_type']] = $mimeType; + } + + foreach ($table->getColumnsHash() as $row) { + if (!isset($mimeTypeMap[$row['mimeType']])) { + throw new Exception("Mime type '{$row['mimeType']}' not found in the response."); + } + + $mimeType = $mimeTypeMap[$row['mimeType']]; + foreach ($mimeType['app_providers'] as $provider) { + if ($provider['name'] === 'OnlyOffice' && $row['onlyOffice']) { + Assert::assertSame( + $row['onlyOffice'], + $provider['target_ext'], + "Expected target_ext for OnlyOffice in mimeType '{$row['onlyOffice']} but found '{$provider['target_ext']}" + ); + } + if ($provider['name'] === 'Collabora' && $row['collabora']) { + Assert::assertSame( + $row['collabora'], + $provider['target_ext'], + "Expected target_ext for Collabora in mimeType '{$row['collabora']} but found '{$provider['target_ext']}" + ); + } + } + } + } + + /** + * @When user :user has created a file :file in space :space using wopi endpoint + * + * @param string $user + * @param string $file + * @param string $space + * + * @return string + * @throws GuzzleException + */ + public function userHasCreatedAFileInSpaceUsingWopiEndpoint(string $user, string $file, string $space):string { + $spaceId = $this->spacesContext->getSpaceIdByName($user, $space); + $splitSpaceId = explode('$', $spaceId); + $parentContainerId = $splitSpaceId[0] . '$' . $splitSpaceId[1] . '!' . $splitSpaceId[1]; + $response = CollaborationHelper::createFile( + $this->featureContext->getBaseUrl(), + $this->featureContext->getStepLineRef(), + $user, + $this->featureContext->getPasswordForUser($user), + $parentContainerId, + $file + ); + $this->featureContext->theHTTPStatusCodeShouldBe(200, "", $response); + $decodedResponse = json_decode($response->getBody()->getContents(), true); + return $decodedResponse['file_id']; + } + } diff --git a/tests/acceptance/bootstrap/SpacesContext.php b/tests/acceptance/bootstrap/SpacesContext.php index 0695f0c235..f83cd73be2 100644 --- a/tests/acceptance/bootstrap/SpacesContext.php +++ b/tests/acceptance/bootstrap/SpacesContext.php @@ -1971,7 +1971,6 @@ class SpacesContext implements Context { string $fileName, string $spaceName ):void { - $this->getSpaceIdByName($user, $spaceName); $response = $this->featureContext->downloadFileAsUserUsingPassword($user, $fileName, $this->featureContext->getPasswordForUser($user)); Assert::assertGreaterThanOrEqual( 400, diff --git a/tests/acceptance/features/apiCollaboration/checkFileInfo.feature b/tests/acceptance/features/apiCollaboration/checkFileInfo.feature index 477b63c5af..add49e22c0 100644 --- a/tests/acceptance/features/apiCollaboration/checkFileInfo.feature +++ b/tests/acceptance/features/apiCollaboration/checkFileInfo.feature @@ -1862,3 +1862,19 @@ Feature: check file info with different wopi apps Then the HTTP status code should be "200" And the response should not contain the following MIME types: | application/octet-stream | + + + Scenario: check that '/app/list' contain WebOffice template + When user "Alice" sends HTTP method "GET" to URL "/app/list" + Then the HTTP status code should be "200" + And the app list response should contain the following information: + | mimeType | onlyOffice | collabora | + | application/vnd.ms-powerpoint.template.macroenabled.12 | pptx | | + | application/vnd.oasis.opendocument.presentation-template | pptx | odp | + | application/vnd.openxmlformats-officedocument.spreadsheetml.template | xlsx | | + | application/vnd.oasis.opendocument.spreadsheet-template | xlsx | ods | + | application/vnd.openxmlformats-officedocument.presentationml.template | pptx | | + | application/vnd.openxmlformats-officedocument.wordprocessingml.template | docx | | + | application/vnd.ms-word.template.macroenabled.12 | docx | | + | application/vnd.oasis.opendocument.text-template | docx | odt | + | application/vnd.ms-excel.template.macroenabled.12 | xlsx | | diff --git a/tests/acceptance/features/apiCollaboration/wopi.feature b/tests/acceptance/features/apiCollaboration/wopi.feature index 741e003a5a..8cd4e39aa7 100644 --- a/tests/acceptance/features/apiCollaboration/wopi.feature +++ b/tests/acceptance/features/apiCollaboration/wopi.feature @@ -1080,3 +1080,51 @@ Feature: collaboration (wopi) """ And for user "Alice" folder "testFolder" of the space "new-space" should not contain these files: | simple.odt | + + + Scenario Outline: open file with .potx extension and template + Given user "Alice" has uploaded file "filesForUpload/template.xltx" to "template.xltx" + And we save it into "TEMPLATEID" + And user "Alice" has created a file "template.pptx" in space "Personal" using wopi endpoint + And we save it into "FILEID" + When user "Alice" sends HTTP method "POST" to URL "" + Then the HTTP status code should be "200" + And the JSON data of the response should match + """ + { + "type": "object", + "required": [ + "app_url", + "method", + "form_parameters" + ], + "properties": { + "app_url": { + "type": "string", + "pattern": "^.*\\?WOPISrc=.*wopi%2Ffiles%2F[a-fA-F0-9]{64}$" + }, + "method": { + "const": "POST" + }, + "form_parameters": { + "type": "object", + "required": [ + "access_token", + "access_token_ttl" + ], + "properties": { + "access_token": { + "type": "string" + }, + "access_token_ttl": { + "type": "string" + } + } + } + } + } + """ + Examples: + | app-endpoint | + | /app/open?file_id=<>&app_name=Collabora&view_mode=write&template_id=<> | + | /app/open?file_id=<>&app_name=OnlyOffice&view_mode=write&template_id=<> | diff --git a/tests/acceptance/filesForUpload/template.xltx b/tests/acceptance/filesForUpload/template.xltx new file mode 100644 index 0000000000..11611d37e7 Binary files /dev/null and b/tests/acceptance/filesForUpload/template.xltx differ