add test coverage for /app/ endpoint

This commit is contained in:
Prajwol Amatya
2024-08-23 16:15:04 +05:45
parent b53500835c
commit b398cb1b4b
3 changed files with 72 additions and 0 deletions
+7
View File
@@ -414,6 +414,13 @@ default:
- TagContext:
- TrashbinContext:
apiAppProvider:
paths:
- "%paths.base%/../features/apiAppProvider"
context: *common_ldap_suite_context
contexts:
- FeatureContext: *common_feature_context_params
extensions:
rdx\behatvars\BehatVariablesExtension: ~
@@ -0,0 +1,43 @@
Feature: App Provider
Scenario: open file with Collabora
Given user "Alice" has been created with default attributes and without skeleton files
And user "Alice" has uploaded file "filesForUpload/simple.odt" to "simple.odt"
When user "Alice" opens file "simple.odt" with Collabora service
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": "^https:\\/\\/host\\.docker\\.internal:9980\\/browser\\/8ec5fda\\/cool\\.html\\?WOPISrc=https%3A%2F%2Fhost\\.docker\\.internal%3A9300%2Fwopi%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"
}
}
}
}
}
"""
@@ -4131,4 +4131,26 @@ class SpacesContext implements Context {
)
);
}
/**
* @When user :user opens file :filename with Collabora service
*
* @param string $user
* @param string $filename
*
* @return void
*/
public function userOpensFileWithCollaboraService(string $user, string $filename): void
{
$fileId = $this->getFileId($user, "Personal", $filename);
$url = $this->featureContext->getBaseUrl() . "/app/open?file_id=$fileId&app_name=Collabora";
$this->featureContext->setResponse(
HttpRequestHelper::post(
$url,
$this->featureContext->getStepLineRef(),
$user,
$this->featureContext->getPasswordForUser($user)
)
);
}
}