add edge case for check file info

This commit is contained in:
amrita
2024-09-24 09:47:51 +05:45
parent aeecc3cc09
commit 0568224192
3 changed files with 685 additions and 0 deletions
@@ -22,6 +22,7 @@
use Behat\Behat\Context\Context;
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
use Behat\Gherkin\Node\TableNode;
use GuzzleHttp\Exception\GuzzleException;
use TestHelpers\HttpRequestHelper;
use TestHelpers\WebDavHelper;
@@ -33,6 +34,7 @@ use TestHelpers\CollaborationHelper;
class CollaborationContext implements Context {
private FeatureContext $featureContext;
private SpacesContext $spacesContext;
private string $storeLastAppEndpointResponse;
/**
* This will run before EVERY scenario.
@@ -52,6 +54,22 @@ class CollaborationContext implements Context {
$this->spacesContext = $environment->getContext('SpacesContext');
}
/**
* @param string $appData
*
* @return void
*/
public function storeLastAppEndpointResponse(string $appData): void {
$this->storeLastAppEndpointResponse = $appData;
}
/**
* @return string
*/
public function getLastAppEndpointResponse(): string {
return $this->storeLastAppEndpointResponse;
}
/**
* @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
@@ -255,4 +273,53 @@ class CollaborationContext implements Context {
)
);
}
/**
* @Given user :user has sent POST request on app endpoint:
*
* @param string $user
* @param TableNode $items
*
* @return void
* @throws GuzzleException
*/
public function userHasSentPostRequestOnAppEndpoint(string $user, TableNode $items): void {
$rows = $items->getRowsHash();
$appResponse = CollaborationHelper::sendPOSTRequestToAppOpen(
$this->spacesContext->getFileId($user, $rows['space'], $rows['resource']),
$rows['suites'],
$this->featureContext->getActualUsername($user),
$this->featureContext->getPasswordForUser($user),
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef()
);
$this->featureContext->theHTTPStatusCodeShouldBe(200, '', $appResponse);
$this->storeLastAppEndpointResponse($appResponse->getBody()->getContents());
}
/**
* @When user :user tries to get the file information of file using wopi endpoint
* @When user :user gets the file information of file using wopi endpoint
*
* @param string $user
*
* @return void
* @throws GuzzleException
*/
public function userTriesToCheckTheInformationOfDeletedFileUsingWopiEndpoint(string $user):void {
$response = json_decode($this->getLastAppEndpointResponse());
$accessToken = $response->form_parameters->access_token;
// Extract the WOPISrc from the app_url
$parsedUrl = parse_url($response->app_url);
parse_str($parsedUrl['query'], $queryParams);
$wopiSrc = $queryParams['WOPISrc'];
$this->featureContext->setResponse(
HttpRequestHelper::get(
$wopiSrc . "?access_token=$accessToken",
$this->featureContext->getStepLineRef()
)
);
}
}