Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tests-only][full-ci]add edge case for check file info #10091

Merged
merged 2 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions tests/acceptance/bootstrap/CollaborationContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -33,6 +34,7 @@
class CollaborationContext implements Context {
private FeatureContext $featureContext;
private SpacesContext $spacesContext;
private string $lastAppOpenData;

/**
* This will run before EVERY scenario.
Expand All @@ -52,6 +54,22 @@ public function before(BeforeScenarioScope $scope): void {
$this->spacesContext = $environment->getContext('SpacesContext');
}

/**
* @param string $data
*
* @return void
*/
public function setLastAppOpenData(string $data): void {
$this->lastAppOpenData = $data;
}

/**
* @return string
*/
public function getLastAppOpenData(): string {
return $this->lastAppOpenData;
}

/**
* @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
Expand Down Expand Up @@ -255,4 +273,53 @@ public function userTriesToCreateAFileInsideDeletedFolderUsingWopiEndpoint(strin
)
);
}

/**
* @Given user :user has sent the following app-open request:
*
* @param string $user
* @param TableNode $properties
*
* @return void
* @throws GuzzleException
*/
public function userHasSentTheFollowingAppOpenRequest(string $user, TableNode $properties): void {
$rows = $properties->getRowsHash();
$appResponse = CollaborationHelper::sendPOSTRequestToAppOpen(
$this->spacesContext->getFileId($user, $rows['space'], $rows['resource']),
$rows['app'],
$this->featureContext->getActualUsername($user),
$this->featureContext->getPasswordForUser($user),
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef()
);
$this->featureContext->theHTTPStatusCodeShouldBe(200, '', $appResponse);
$this->setLastAppOpenData($appResponse->getBody()->getContents());
}

/**
* @When user :user tries to get the information of the last opened file using wopi endpoint
* @When user :user gets the information of the last opened file using wopi endpoint
*
* @param string $user
*
* @return void
* @throws GuzzleException
*/
public function userGetsTheInformationOfTheLastOpenedFileUsingWopiEndpoint(string $user): void {
$response = json_decode($this->getLastAppOpenData());
$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()
)
);
}
}
1 change: 1 addition & 0 deletions tests/acceptance/config/behat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ default:
- FeatureContext: *common_feature_context_params
- SharingNgContext:
- CollaborationContext:
- TrashbinContext:


cliCommands:
Expand Down
Loading