mirror of
https://github.com/owncloud/ocis
synced 2026-04-25 17:25:21 +02:00
review addressed
This commit is contained in:
@@ -357,19 +357,17 @@ class CollaborationContext implements Context {
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then the app list response should contain the following information:
|
||||
* @Then the app list response should contain the following template information for office :app:
|
||||
*
|
||||
* @param string $app
|
||||
* @param TableNode $table
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function theAppListResponseShouldContainTheFollowingInformation(TableNode $table): void {
|
||||
public function theAppListResponseShouldContainTheFollowingTemplateInformationForOffice(string $app, 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.");
|
||||
}
|
||||
Assert::assertArrayHasKey("mime-types", $responseArray, "Expected 'mime-types' in the response but not found.\n" . print_r($responseArray, true));
|
||||
|
||||
$mimeTypes = $responseArray['mime-types'];
|
||||
|
||||
@@ -379,44 +377,43 @@ class CollaborationContext implements Context {
|
||||
}
|
||||
|
||||
foreach ($table->getColumnsHash() as $row) {
|
||||
if (!isset($mimeTypeMap[$row['mimeType']])) {
|
||||
throw new Exception("Mime type '{$row['mimeType']}' not found in the response.");
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
$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']}"
|
||||
);
|
||||
}
|
||||
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 in space :space using wopi endpoint
|
||||
* @When user :user has created a file :file 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];
|
||||
public function userHasCreatedAFileInSpaceUsingWopiEndpoint(string $user, string $file):string {
|
||||
$parentContainerId = $this->featureContext->getFileIdForPath($user, "/");
|
||||
$response = CollaborationHelper::createFile(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$this->featureContext->getStepLineRef(),
|
||||
@@ -426,8 +423,7 @@ class CollaborationContext implements Context {
|
||||
$file
|
||||
);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(200, "", $response);
|
||||
$decodedResponse = json_decode($response->getBody()->getContents(), true);
|
||||
return $decodedResponse['file_id'];
|
||||
$decodedResponse[] = $this->featureContext->getJsonDecodedResponseBodyContent($response);
|
||||
return $decodedResponse[0]->file_id;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1864,17 +1864,22 @@ Feature: check file info with different wopi apps
|
||||
| application/octet-stream |
|
||||
|
||||
|
||||
Scenario: check that '/app/list' contain WebOffice template
|
||||
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 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 | |
|
||||
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 |
|
||||
|
||||
@@ -1082,10 +1082,11 @@ Feature: collaboration (wopi)
|
||||
| simple.odt |
|
||||
|
||||
|
||||
Scenario Outline: open file with .potx extension and template
|
||||
Given user "Alice" has uploaded file "filesForUpload/template.xltx" to "template.xltx"
|
||||
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 "template.pptx" in space "Personal" using wopi endpoint
|
||||
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"
|
||||
@@ -1125,6 +1126,6 @@ Feature: collaboration (wopi)
|
||||
}
|
||||
"""
|
||||
Examples:
|
||||
| app-endpoint |
|
||||
| /app/open?file_id=<<FILEID>>&app_name=Collabora&view_mode=write&template_id=<<TEMPLATEID>> |
|
||||
| /app/open?file_id=<<FILEID>>&app_name=OnlyOffice&view_mode=write&template_id=<<TEMPLATEID>> |
|
||||
| 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 |
|
||||
|
||||
BIN
tests/acceptance/filesForUpload/template.dotx
Normal file
BIN
tests/acceptance/filesForUpload/template.dotx
Normal file
Binary file not shown.
BIN
tests/acceptance/filesForUpload/template.ott
Normal file
BIN
tests/acceptance/filesForUpload/template.ott
Normal file
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user