Add test for unified comments search
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
@@ -8,4 +8,5 @@ default:
|
|||||||
baseUrl: http://localhost:8080/
|
baseUrl: http://localhost:8080/
|
||||||
- RequestContext
|
- RequestContext
|
||||||
- BoardContext
|
- BoardContext
|
||||||
|
- CommentContext
|
||||||
- SearchContext
|
- SearchContext
|
||||||
|
|||||||
@@ -27,6 +27,10 @@ class BoardContext implements Context {
|
|||||||
$this->serverContext = $environment->getContext('ServerContext');
|
$this->serverContext = $environment->getContext('ServerContext');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getLastUsedCard() {
|
||||||
|
return $this->card;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Given /^creates a board named "([^"]*)" with color "([^"]*)"$/
|
* @Given /^creates a board named "([^"]*)" with color "([^"]*)"$/
|
||||||
*/
|
*/
|
||||||
|
|||||||
31
tests/integration/features/bootstrap/CommentContext.php
Normal file
31
tests/integration/features/bootstrap/CommentContext.php
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Behat\Behat\Context\Context;
|
||||||
|
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../vendor/autoload.php';
|
||||||
|
|
||||||
|
class CommentContext implements Context {
|
||||||
|
use RequestTrait;
|
||||||
|
|
||||||
|
/** @var BoardContext */
|
||||||
|
protected $boardContext;
|
||||||
|
|
||||||
|
/** @BeforeScenario */
|
||||||
|
public function gatherContexts(BeforeScenarioScope $scope) {
|
||||||
|
$environment = $scope->getEnvironment();
|
||||||
|
|
||||||
|
$this->boardContext = $environment->getContext('BoardContext');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Given /^post a comment with content "([^"]*)" on the card$/
|
||||||
|
*/
|
||||||
|
public function postACommentWithContentOnTheCard($content) {
|
||||||
|
$card = $this->boardContext->getLastUsedCard();
|
||||||
|
$this->requestContext->sendOCSRequest('POST', '/apps/deck/api/v1.0/cards/' . $card['id'] . '/comments', [
|
||||||
|
'message' => $content,
|
||||||
|
'parentId' => null
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,6 +13,7 @@ class SearchContext implements Context {
|
|||||||
protected $boardContext;
|
protected $boardContext;
|
||||||
|
|
||||||
private $searchResults;
|
private $searchResults;
|
||||||
|
private $unifiedSearchResult;
|
||||||
|
|
||||||
/** @BeforeScenario */
|
/** @BeforeScenario */
|
||||||
public function gatherContexts(BeforeScenarioScope $scope) {
|
public function gatherContexts(BeforeScenarioScope $scope) {
|
||||||
@@ -32,6 +33,18 @@ class SearchContext implements Context {
|
|||||||
$this->searchResults = json_decode($data, true);
|
$this->searchResults = json_decode($data, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @When /^searching for "([^"]*)" in comments in unified search$/
|
||||||
|
* @param string $term
|
||||||
|
* https://cloud.nextcloud.com/ocs/v2.php/search/providers/talk-conversations/search?term=an&from=%2Fapps%2Fdashboard%2F
|
||||||
|
*/
|
||||||
|
public function searchingForComments(string $term) {
|
||||||
|
$this->requestContext->sendOCSRequest('GET', '/search/providers/deck-comment/search?term=' . urlencode($term), []);
|
||||||
|
$this->requestContext->getResponse()->getBody()->seek(0);
|
||||||
|
$data = (string)$this->getResponse()->getBody();
|
||||||
|
$this->unifiedSearchResult = json_decode($data, true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @When /^searching for '([^']*)'$/
|
* @When /^searching for '([^']*)'$/
|
||||||
* @param string $term
|
* @param string $term
|
||||||
@@ -78,4 +91,33 @@ class SearchContext implements Context {
|
|||||||
public function theCardIsNotFound($arg1) {
|
public function theCardIsNotFound($arg1) {
|
||||||
Assert::assertFalse($this->cardIsFound($arg1), 'Card can not be found');
|
Assert::assertFalse($this->cardIsFound($arg1), 'Card can not be found');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Then /^the comment with "([^"]*)" is found$/
|
||||||
|
*/
|
||||||
|
public function theCommentWithIsFound($arg1) {
|
||||||
|
$ocsData = $this->unifiedSearchResult['ocs']['data']['entries'];
|
||||||
|
$found = null;
|
||||||
|
foreach ($ocsData as $result) {
|
||||||
|
if ($result['subline'] === $arg1) {
|
||||||
|
$found = $result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Assert::assertNotNull($found, 'Comment was expected but was not found');
|
||||||
|
Assert::assertEquals('admin on Card with comment', $found['title']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Then /^the comment with "([^"]*)" is not found$/
|
||||||
|
*/
|
||||||
|
public function theCommentWithIsNotFound($arg1) {
|
||||||
|
$ocsData = $this->unifiedSearchResult['ocs']['data']['entries'];
|
||||||
|
$found = null;
|
||||||
|
foreach ($ocsData as $result) {
|
||||||
|
if ($result['subline'] === $arg1) {
|
||||||
|
$found = $result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Assert::assertNull($found, 'Comment was found but not expected');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -257,3 +257,10 @@ Feature: Searching for cards
|
|||||||
Then the card "Example task 1" is not found
|
Then the card "Example task 1" is not found
|
||||||
And the card "Labeled card" is not found
|
And the card "Labeled card" is not found
|
||||||
And the card "Multi labeled card" is found
|
And the card "Multi labeled card" is found
|
||||||
|
|
||||||
|
Scenario: Search for a card comment
|
||||||
|
Given create a card named "Card with comment"
|
||||||
|
And post a comment with content "My first comment" on the card
|
||||||
|
When searching for "My first comment" in comments in unified search
|
||||||
|
Then the comment with "My first comment" is found
|
||||||
|
Then the comment with "Any other" is not found
|
||||||
|
|||||||
Reference in New Issue
Block a user