mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-04-24 21:18:19 -05:00
Merge pull request #10609 from owncloud/add-template-tests
[tests-only][full-ci]Add test for template
This commit is contained in:
@@ -355,4 +355,75 @@ class CollaborationContext implements Context {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then the app list response should contain the following template information for office :app:
|
||||
*
|
||||
* @param string $app
|
||||
* @param TableNode $table
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function theAppListResponseShouldContainTheFollowingTemplateInformationForOffice(string $app, TableNode $table): void {
|
||||
$responseArray = $this->featureContext->getJsonDecodedResponse($this->featureContext->getResponse());
|
||||
|
||||
Assert::assertArrayHasKey("mime-types", $responseArray, "Expected 'mime-types' in the response but not found.\n" . print_r($responseArray, true));
|
||||
|
||||
$mimeTypes = $responseArray['mime-types'];
|
||||
|
||||
$mimeTypeMap = [];
|
||||
foreach ($mimeTypes as $mimeType) {
|
||||
$mimeTypeMap[$mimeType['mime_type']] = $mimeType;
|
||||
}
|
||||
|
||||
foreach ($table->getColumnsHash() as $row) {
|
||||
Assert::assertArrayHasKey($row['mime-type'], $mimeTypeMap, "Expected mime-type '{$row['mime-type']}' to exist in the response but it doesn't.\n" . print_r($mimeTypeMap, true));
|
||||
|
||||
$mimeType = $mimeTypeMap[$row['mime-type']];
|
||||
$found = false;
|
||||
|
||||
foreach ($mimeType['app_providers'] as $provider) {
|
||||
if ($provider['name'] === $app && isset($row['target-extension'])) {
|
||||
Assert::assertSame(
|
||||
$row['target-extension'],
|
||||
$provider['target_ext'],
|
||||
"Expected 'target_ext' for $app to be '{$row['target-extension']}' but found '{$provider['target_ext']}'"
|
||||
);
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$found) {
|
||||
Assert::fail(
|
||||
"Expected response to contain app-provider '$app' with target-extension '{$row['target-extension']}' for mime-type '{$row['mime-type']}', but no matching provider was found.\n" .
|
||||
"App Providers Found: " . print_r($mimeType['app_providers'], true)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @When user :user has created a file :file using wopi endpoint
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $file
|
||||
*
|
||||
* @return string
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function userHasCreatedAFileInSpaceUsingWopiEndpoint(string $user, string $file):string {
|
||||
$parentContainerId = $this->featureContext->getFileIdForPath($user, "/");
|
||||
$response = CollaborationHelper::createFile(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$this->featureContext->getStepLineRef(),
|
||||
$user,
|
||||
$this->featureContext->getPasswordForUser($user),
|
||||
$parentContainerId,
|
||||
$file
|
||||
);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(200, "", $response);
|
||||
$decodedResponse[] = $this->featureContext->getJsonDecodedResponseBodyContent($response);
|
||||
return $decodedResponse[0]->file_id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -1862,3 +1862,24 @@ 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 target extensions for template mime types
|
||||
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 template information for office "OnlyOffice":
|
||||
| mime-type | target-extension |
|
||||
| application/vnd.oasis.opendocument.spreadsheet-template | xlsx |
|
||||
| application/vnd.oasis.opendocument.text-template | docx |
|
||||
| application/vnd.oasis.opendocument.presentation-template | pptx |
|
||||
| application/vnd.openxmlformats-officedocument.spreadsheetml.template | xlsx |
|
||||
| application/vnd.openxmlformats-officedocument.presentationml.template | pptx |
|
||||
| application/vnd.openxmlformats-officedocument.wordprocessingml.template | docx |
|
||||
| application/vnd.ms-word.template.macroenabled.12 | docx |
|
||||
| application/vnd.ms-powerpoint.template.macroenabled.12 | pptx |
|
||||
| application/vnd.ms-excel.template.macroenabled.12 | xlsx |
|
||||
And the app list response should contain the following template information for office "Collabora":
|
||||
| mime-type | target-extension |
|
||||
| application/vnd.oasis.opendocument.spreadsheet-template | ods |
|
||||
| application/vnd.oasis.opendocument.text-template | odt |
|
||||
| application/vnd.oasis.opendocument.presentation-template | odp |
|
||||
|
||||
@@ -1080,3 +1080,52 @@ Feature: collaboration (wopi)
|
||||
"""
|
||||
And for user "Alice" folder "testFolder" of the space "new-space" should not contain these files:
|
||||
| simple.odt |
|
||||
|
||||
|
||||
Scenario Outline: create a file using a template
|
||||
Given using spaces DAV path
|
||||
And user "Alice" has uploaded file "filesForUpload/<template>" to "<template>"
|
||||
And we save it into "TEMPLATEID"
|
||||
And user "Alice" has created a file "<target>" using wopi endpoint
|
||||
And we save it into "FILEID"
|
||||
When user "Alice" sends HTTP method "POST" to URL "<app-endpoint>"
|
||||
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 | template | target |
|
||||
| /app/open?file_id=<<FILEID>>&app_name=Collabora&view_mode=write&template_id=<<TEMPLATEID>> | template.ott | template.odt |
|
||||
| /app/open?file_id=<<FILEID>>&app_name=OnlyOffice&view_mode=write&template_id=<<TEMPLATEID>> | template.dotx | template.docx |
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user