at the end of the day, it was inevitable

This commit is contained in:
Mo Elzubeir
2022-12-09 08:36:26 -06:00
commit 1218570914
1768 changed files with 887087 additions and 0 deletions
+232
View File
@@ -0,0 +1,232 @@
<?php
namespace Api\Context;
use Api\Util\ApiConnection;
use Behat\Gherkin\Node\PyStringNode;
use Behat\Gherkin\Node\TableNode;
use Coduo\PHPMatcher\PHPMatcher;
use Common\Context\AbstractContext;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpKernel\Profiler\Profiler;
/**
* Class ApiContext
* @package Api\Context
*/
class ApiContext extends AbstractContext
{
/**
* @var ApiConnection
*/
private $apiConnection;
/**
* @var string
*/
private $authToken;
/**
* @param ContainerInterface $container A ContainerInterface instance.
* @param string $baseUrl Base url to app api.
* @param string $fixturesDir Path to fixtures directory.
*/
public function __construct(
ContainerInterface $container,
$baseUrl,
$fixturesDir
) {
parent::__construct($container, $fixturesDir);
$this->apiConnection = new ApiConnection($baseUrl, $this->debug);
}
/**
* Make request to api.
*
* @Given /^(?:|I )[Mm]ake (?P<method>GET|POST|PUT|DELETE) request to (?P<endpoint>.+)$/
*
* @param string $method HTTP method name.
* @param string $endpoint Relative to base url.
* @param mixed $payload Request parameters.
*
* @return void
*/
public function request($method, $endpoint, $payload = null)
{
switch (true) {
case $payload instanceof TableNode:
$table = $payload->getTable();
$payload = [];
foreach ($table as $row) {
$payload[current($row)] = next($row);
}
break;
case $payload instanceof PyStringNode:
$payload = (array) json_decode($payload->getRaw(), true);
$payload = array_filter($payload);
if (json_last_error() !== JSON_ERROR_NONE) {
throw new \InvalidArgumentException(
'Request error: ' . json_last_error_msg()
);
}
break;
default:
$payload = [];
}
$payload = $this->processor->process($payload);
$this->apiConnection->request($method, $endpoint, $payload, $this->authToken);
}
/**
* @Then /^(?:|I )[Gg]ot response with code (?P<code>\d+)$/
* @Then /^(?:|I )[Gg]ot successful response$/
*
* @param integer $expected Expected response.
*
* @return void
*/
public function checkStatus($expected = 200)
{
self::assertEquals(
$expected,
$this->apiConnection->getLastResponse()->getStatusCode()
);
}
/**
* @Then /^(?:|I )[Gg]ot response with content$/
* @Then /^(?:|[Rr]esponse|[Ii]t's )[Cc]ontains$/
*
* @param PyStringNode $pattern Pattern for coduo/PHPMatcher.
*
* @return void
*/
public function responseMatch(PyStringNode $pattern)
{
$error = '';
self::assertTrue(
$this->match(
$this->apiConnection->getLastResponseData(),
$pattern->getRaw(),
$error
),
$error
);
}
/**
* @Then /^(?:|I )[Gg]ot empty response$/
* @Then /^[Rr]esponse is empty$/
* @Then /^[Ii]t's empty$/
*
* @return void
*/
public function emptyResponse()
{
$error = '';
self::assertTrue(
PHPMatcher::match(
$this->apiConnection->getLastResponseData(),
'',
$error
),
$error
);
}
/**
* @Given /^(?:|I )[Aa]uthenticated as (?P<email>[\w@\.]+) with password (?P<password>.+)$/
*
* @param string $email User email.
* @param string $password User password.
*
* @return void
*/
public function authenticate($email, $password)
{
$this->apiConnection
->request('POST', '/security/token/create', [
'email' => $email,
'password' => $password,
]);
self::assertEquals(
200,
$this->apiConnection->getLastResponse()->getStatusCode()
);
$response = json_decode(
$this->apiConnection->getLastResponseData(),
true
);
self::assertTrue(is_array($response), 'Invalid response from server');
self::assertArrayHasKey('token', $response);
$this->authToken = $response['token'];
}
/**
* @Then /^(?:[Oo]ne|(?P<count>\d+)) [Ee]mail is sent$/
*
* @param integer $count Expected emails count.
*
* @return void
*/
public function emailsCount($count = 1)
{
$mailer = $this->getMailCollector();
self::assertEquals($count, $mailer->getMessageCount());
}
/**
* @Then /^[Nn]o emails sent$/
*
* @return void
*/
public function noEmailsSent()
{
$mailer = $this->getMailCollector();
self::assertEquals(0, $mailer->getMessageCount());
}
/**
* @Then /^(?:|[Ff]irst )[Ee]mail subject is "(?P<subject>[^"]+)"$/
* @Then /^(?P<index>\d+) email subject is "(?P<subject>[^"]+)"$/
*
* @param string $subject Expected email subject.
* @param integer $index Email index.
*
* @return void
*/
public function emailSubject($subject, $index = 0)
{
$mailer = $this->getMailCollector();
/** @var \Swift_Message $message */
$message = $mailer->getMessages()[$index];
self::assertEquals($subject, $message->getSubject());
}
/**
* @return \Symfony\Component\HttpKernel\DataCollector\DataCollectorInterface|\Symfony\Bundle\SwiftmailerBundle\DataCollector\MessageDataCollector
*/
protected function getMailCollector()
{
/** @var Profiler $profiler */
$profiler = $this->container->get('profiler');
$token = current($this->apiConnection->getLastResponse()
->getHeader('X-Debug-Token'));
return $profiler->loadProfile($token)->getCollector('swiftmailer');
}
}
+162
View File
@@ -0,0 +1,162 @@
<?php
namespace Api\Util;
use GuzzleHttp\Client;
use GuzzleHttp\Cookie\CookieJar;
use GuzzleHttp\Exception\BadResponseException;
use GuzzleHttp\Psr7\Response;
/**
* Class ApiConnection
* Helper class. Handle all works with app api.
*
* @package Api\Util
*/
class ApiConnection
{
/**
* Used front controller.
*/
const FRONT_CONTROLLER = 'app_test.php';
/**
* @var Client
*/
private $client;
/**
* @var boolean
*/
private $debug;
/**
* @var Response
*/
private $lastResponse;
/**
* @var null|string
*/
private $lastResponseData;
/**
* ApiConnection constructor.
*
* @param string $baseUrl Base url to app api.
* @param boolean $debug Print debug information if set.
*/
public function __construct($baseUrl, $debug)
{
$cookies = false;
if ($debug) {
$cookies = CookieJar::fromArray([
'XDEBUG_SESSION' => 'PHPSTORM',
], parse_url($baseUrl, PHP_URL_HOST));
}
$this->client = new Client([
'base_uri' => $baseUrl,
'cookies' => $cookies,
]);
$this->debug = $debug;
}
/**
* Make request to api.
*
* @param string $method HTTP method name.
* @param string $endpoint Relative to base url.
* @param array $payload Request payload, may send as query string or as
* json relative to method name.
* @param string $authToken Application authentication token.
*
* @return mixed|\Psr\Http\Message\ResponseInterface
*/
public function request(
$method,
$endpoint,
array $payload = [],
$authToken = null
) {
$method = strtoupper($method);
// Prepare full endpoint url.
$endpoint = self::FRONT_CONTROLLER . '/' . ltrim($endpoint, '/');
// Prepare request options.
$options = [];
// Add authorization token if it provided.
if ($authToken !== null) {
$options['headers'] = [ 'Authorization' => 'Bearer '. $authToken ];
}
// Send payload as query string for 'GET' request.
// For other methods, send in content as json.
$options[($method === 'GET') ? 'query' : 'json'] = $payload;
// Show debug information about request.
if ($this->debug) {
echo 'Request: ' . $this->client->getConfig('base_uri')
. $endpoint. PHP_EOL;
echo 'Request options: ' . PHP_EOL
. json_encode($options, JSON_PRETTY_PRINT)
. PHP_EOL;
}
try {
// Make request to api and save response to class.
$this->lastResponseData = null;
$this->lastResponse =
$this->client->request($method, $endpoint, $options);
} catch (BadResponseException $e) {
$this->lastResponse = $e->getResponse();
}
if ($this->debug) {
$decodedResponse = json_decode($this->getLastResponseData(), true);
if ($decodedResponse) {
// In debug mode dump data received from server to output.
print('Response data: ' . PHP_EOL
. json_encode(
$decodedResponse,
JSON_PRETTY_PRINT
). PHP_EOL
);
} else {
print $this->getLastResponseData().PHP_EOL;
}
}
return $this->lastResponse;
}
/**
* Get last response.
*
* @return Response
*/
public function getLastResponse()
{
return $this->lastResponse;
}
/**
* Get data from last response.
*
* @return null|string
*/
public function getLastResponseData()
{
if (($this->lastResponseData === null) && $this->lastResponse) {
$this->lastResponseData = $this->lastResponse
->getBody()
->getContents();
}
return $this->lastResponseData;
}
}
@@ -0,0 +1,83 @@
Feature: Create authentication token
As an anonymous user
I should be able to obtain authentication token in order to make request
to api
@db-fixtures
Scenario:
I try to create token with proper data
Given I make POST request to /security/token/create
"""
{
"email": "test@email.com",
"password": "test"
}
"""
And I got response with code 200
And it's contains
"""
{
"user": "@object@
.entity('UserBundle:User', 'user, id, recipient, restrictions')
.field('firstName', 'John')
.field('lastName', 'Smith')
",
"token": "@string@",
"refreshToken": "@string@"
}
"""
Scenario Outline:
I try to create token without providing any data .
Given I make POST request to /security/token/create
"""
{
<payload>
}
"""
And I got response with code 400
And it's contains
"""
{
"errors": [
"Credentials not provided."
]
}
"""
Examples:
| payload |
| "email": "test@email.com" |
| "password": "test" |
| |
@db-fixtures
Scenario Outline:
I try to create token with invalid data.
Given I make POST request to /security/token/create
"""
{
"email": "<email>",
"password": "<password>"
}
"""
And I got response with code 401
And it's contains
"""
{
"errors": [
"Bad credentials."
]
}
"""
Examples:
| email | password |
| test@email.com | invalid |
| unknown@mail1.dev | test |
@@ -0,0 +1,67 @@
Feature: Refresh authentication token
As an authenticated user
I should be able to obtain authentication token by using my refresh token
@db-fixtures
Scenario:
I try to refresh authentication token.
Given I make POST request to /security/token/refresh
"""
{
"refreshToken": "user1_token"
}
"""
And I got response with code 200
And it's contains
"""
{
"user": "@object@
.entity('UserBundle:User', 'user, id, recipient, restrictions')
.field('firstName', 'John')
.field('lastName', 'Smith')
",
"token": "@string@",
"refreshToken": "@string@"
}
"""
Scenario:
I try to refresh authentication token without refresh token provided.
Given I make POST request to /security/token/refresh
"""
{
}
"""
And I got response with code 400
And it's contains
"""
{
"errors": [
"refreshToken: This value should not be null."
]
}
"""
@db-fixtures
Scenario:
I try to refresh authentication token by invalid refresh token.
Given I make POST request to /security/token/refresh
"""
{
"refreshToken": "some token"
}
"""
And I got response with code 401
And it's contains
"""
{
"errors": [
"Refresh token \"some token\" does not exist."
]
}
"""
@@ -0,0 +1,78 @@
Feature: Create category
As an authenticated user
I should able to create new category
@db-fixtures
Scenario:
I try to create new category.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/categories
"""
{
"name": "new category",
"parent": 4
}
"""
Then I got successful response
And it's contains
"""
@object@
.entity('CacheBundle:Category', 'category, feed_tree, id')
.field('name', 'new category')
"""
Scenario:
I try to create new category but not provide name.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/categories
"""
{
}
"""
Then I got response with code 400
And it's contains
"""
{
"errors": [
{
"message": "This value should not be blank.",
"transKey": "createCategoryNameEmpty",
"type": "error",
"parameters": {
"current": null
}
}
]
}
"""
@db-fixtures
Scenario:
I try to create new category with already exists name.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/categories
"""
{
"name": "My Content",
"parent": 4
}
"""
Then I got response with code 400
And it's contains
"""
{
"errors": [
{
"message": "User already have category with name \"My Content\".",
"transKey": "createCategoryNameNotUnique",
"type": "error",
"parameters": {
"current": "My Content"
}
}
]
}
"""
@@ -0,0 +1,75 @@
Feature: Delete category
As an authenticated user
I should be able to delete my category
@db-fixtures
Scenario:
I try to delete 'Test' category.
Given I authenticated as test@email.com with password test
When I make DELETE request to /api/v1/categories/6
Then I got response with code 204
And it's empty
And database don't has entity CacheBundle:Category
| id | 6 |
@db-fixtures
Scenario:
I try to delete 'Sub main sub 3' category which have subdirectories.
Given I authenticated as test@email.com with password test
When I make DELETE request to /api/v1/categories/5
Then I got response with code 204
And it's empty
And database don't has entity CacheBundle:Category
| id | 5 |
And don't has entity CacheBundle:Category
| id | 6 |
@db-fixtures
Scenario:
I try to delete category with unknown id.
Given I authenticated as test@email.com with password test
When I make DELETE request to /api/v1/categories/1000
Then I got response with code 404
And it's contains
"""
{
"errors": [
"Can't find category with id 1000."
]
}
"""
@db-fixtures
Scenario:
I try to delete category 'My Content' category.
Given I authenticated as test@email.com with password test
When I make DELETE request to /api/v1/categories/1
Then I got response with code 403
And it's contains
"""
{
"errors": [
"Can't delete internal category."
]
}
"""
@db-fixtures
Scenario:
I try to delete category for another user.
Given I authenticated as test@email.com with password test
When I make DELETE request to /api/v1/categories/10
Then I got response with code 403
And it's contains
"""
{
"errors": [
"Can't delete category owned by other user."
]
}
"""
@@ -0,0 +1,50 @@
Feature: Get category
As an authenticated user
I should be able get information about specified category
@db-fixtures
Scenario:
I try to get 'My Content' category information.
Given I authenticated as test@email.com with password test
When I make GET request to /api/v1/categories/1
Then I got successful response
And it's contains
"""
@object@
.entity('CacheBundle:Category', 'category, feed_tree, id')
.field('id', 1)
.field('name', 'My Content')
"""
@db-fixtures
Scenario:
I try to get category information by unknown id.
Given I authenticated as test@email.com with password test
When I make GET request to /api/v1/categories/1000
Then I got response with code 404
And it's contains
"""
{
"errors": [
"Can't find Category with id 1000."
]
}
"""
@db-fixtures
Scenario:
I try to get category owned by other user.
Given I authenticated as test@email.com with password test
When I make GET request to /api/v1/categories/9
Then I got response with code 403
And it's contains
"""
{
"errors": [
"Can't read category owned by other user."
]
}
"""
@@ -0,0 +1,25 @@
Feature: Get list of categories
As an authenticated
I should be able to get list of my categories
@db-fixtures
Scenario:
I try to get list of categories.
Given I authenticated as test@email.com with password test
When I make GET request to /api/v1/categories
Then I got successful response
And it's contains
"""
{
"data": "@array@
.every(entity('CacheBundle:Category', 'category_tree, feed_tree, id'))
.one(field('name', 'My Content'))
.one(field('name', 'Deleted Content'))
",
"count": "@integer@.greaterThan(1)",
"totalCount": "@integer@.greaterThan(1)",
"page": 1,
"limit": "@integer@.greaterThan(1)"
}
"""
+154
View File
@@ -0,0 +1,154 @@
Feature: Move category
As an authenticated user
I should be able to move my category from one place to another
@db-fixtures
Scenario:
I try to move 'Sub main sub 3' category to another category.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/categories/5/move_to/4
Then I got successful response
And it's contains
"""
{
"data": "@array@
.every(entity('CacheBundle:Category', 'category_tree, feed_tree, id'))
.one(
field('name', 'My Content'),
field('childes',
one(
field('id', 2),
field('childes',
one(
field('id', 4),
field('childes', one(
field('id', 5),
field('childes', one(field('id', 6)))
))
)
)
)
)
)
",
"count": "@integer@.greaterThan(1)",
"totalCount": "@integer@.greaterThan(1)",
"page": 1,
"limit": "@integer@.greaterThan(1)"
}
"""
And database has entity CacheBundle:Category
| id | 5 |
| name | Sub main sub 3 |
| user | 1 |
| parent | 4 |
And database has entity CacheBundle:Category
| id | 6 |
| name | Test |
| user | 1 |
| parent | 5 |
Scenario:
I try to move unknown category.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/categories/1000/move_to/7
Then I got response with code 404
And it's contains
"""
{
"errors": [
"Can't find category with id 1000."
]
}
"""
Scenario:
I try to move my category into unknown.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/categories/5/move_to/1000
Then I got response with code 404
And it's contains
"""
{
"errors": [
"Can't find category with id 1000."
]
}
"""
@db-fixtures
Scenario:
I try to move 'My Content' category which is internal.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/categories/1/move_to/7
Then I got response with code 403
And it's contains
"""
{
"errors": [
"Can't move internal category."
]
}
"""
@db-fixtures
Scenario:
I try to move another user category.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/categories/10/move_to/1
Then I got response with code 404
And it's contains
"""
{
"errors": [
"Can't find category with id 10."
]
}
"""
@db-fixtures
Scenario:
I try to move 'Sub main sub 3' category inside it self.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/categories/5/move_to/5
Then I got response with code 400
And it's contains
"""
{
"errors": [
"Try to place category inside itself."
]
}
"""
And database has entity CacheBundle:Category
| id | 5 |
| name | Sub main sub 3 |
| user | 1 |
| parent | 2 |
@db-fixtures
Scenario:
I try to move 'Sub main sub 3' category inside one of child.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/categories/5/move_to/6
Then I got response with code 400
And it's contains
"""
{
"errors": [
"Try to place category inside it child."
]
}
"""
And database has entity CacheBundle:Category
| id | 5 |
| name | Sub main sub 3 |
| user | 1 |
| parent | 2 |
@@ -0,0 +1,274 @@
Feature: Update category
As an authenticated user
I should be able to update any available properties of my category
@db-fixtures
Scenario:
I try to rename 'Test' category.
Given I authenticated as test@email.com with password test
When I make PUT request to /api/v1/categories/6
"""
{
"name": "Awesome Category",
"parent": 5
}
"""
Then I got response with code 200
And it's contains
"""
@object@
.entity('CacheBundle:Category', 'category, feed_tree, id')
.field('id', 6)
.field('name', 'Awesome Category')
"""
And database has entity CacheBundle:Category
| id | 6 |
| name | Awesome Category |
| user | 1 |
| parent | 5 |
@db-fixtures
Scenario:
I try to move 'Test' category to another category.
Given I authenticated as test@email.com with password test
When I make PUT request to /api/v1/categories/6
"""
{
"name": "Test",
"parent": 4
}
"""
Then I got response with code 200
And it's contains
"""
@object@
.entity('CacheBundle:Category', 'category, feed_tree, id')
.field('id', 6)
.field('name', 'Test')
"""
And database has entity CacheBundle:Category
| id | 6 |
| name | Test |
| user | 1 |
| parent | 4 |
Scenario:
I try to update 'Test' but not provide necessary information.
Given I authenticated as test@email.com with password test
When I make PUT request to /api/v1/categories/6
"""
{
}
"""
Then I got response with code 400
And it's contains
"""
{
"errors": [
{
"message": "This value should not be blank.",
"transKey": "updateCategoryNameEmpty",
"type": "error",
"parameters": {
"current": null
}
}
]
}
"""
@db-fixtures
Scenario:
I try to rename category and set already exists name
Given I authenticated as test@email.com with password test
When I make PUT request to /api/v1/categories/6
"""
{
"name": "My Content",
"parent": 5
}
"""
Then I got response with code 400
And it's contains
"""
{
"errors": [
{
"message": "User already have category with name \"My Content\".",
"transKey": "updateCategoryNameNotUnique",
"type": "error",
"parameters": {
"current": "My Content"
}
}
]
}
"""
@db-fixtures
Scenario:
I try to update category with unknown id.
Given I authenticated as test@email.com with password test
When I make PUT request to /api/v1/categories/1000
"""
{
"name": "Awesome Category",
"parent": 5
}
"""
Then I got response with code 404
And it's contains
"""
{
"errors": [
"Can't find Category with id 1000."
]
}
"""
@db-fixtures
Scenario:
I try to update 'My Content' category which is internal.
Given I authenticated as test@email.com with password test
When I make PUT request to /api/v1/categories/1
"""
{
"name": "Awesome category"
}
"""
Then I got response with code 403
And it's contains
"""
{
"errors": [
"Can't update internal category."
]
}
"""
@db-fixtures
Scenario:
I try to update category for another user.
Given I authenticated as test@email.com with password test
When I make PUT request to /api/v1/categories/10
"""
{
"name": "Awesome category",
"parent": 4
}
"""
Then I got response with code 403
And it's contains
"""
{
"errors": [
"Can't update category owned by other user."
]
}
"""
@db-fixtures
Scenario:
I try to move 'Test' category inside it self.
Given I authenticated as test@email.com with password test
When I make PUT request to /api/v1/categories/6
"""
{
"name": "Test",
"parent": 6
}
"""
Then I got response with code 400
And it's contains
"""
{
"errors": [
{
"message": "Try to place category inside itself.",
"transKey": "updateCategoryParent",
"type": "error",
"parameters": []
}
]
}
"""
And database has entity CacheBundle:Category
| id | 6 |
| name | Test |
| user | 1 |
| parent | 5 |
@db-fixtures
Scenario:
I try to move 'Test' category inside unknown category.
Given I authenticated as test@email.com with password test
When I make PUT request to /api/v1/categories/6
"""
{
"name": "Test",
"parent": 1000
}
"""
Then I got response with code 400
And it's contains
"""
{
"errors": [
{
"message": "This value is not valid.",
"transKey": "updateCategoryParentInvalid",
"type": "error",
"parameters": {
"current": "1000",
"available": null
}
}
]
}
"""
And database has entity CacheBundle:Category
| id | 6 |
| name | Test |
| user | 1 |
| parent | 5 |
@db-fixtures
Scenario:
I try to move 'Sub main sub 3' category inside one of child.
Given I authenticated as test@email.com with password test
When I make PUT request to /api/v1/categories/5
"""
{
"name": "Sub main sub 3",
"parent": 6
}
"""
Then I got response with code 400
And it's contains
"""
{
"errors": [
{
"message": "Try to place category inside it child.",
"transKey": "updateCategoryParent",
"type": "error",
"parameters": []
}
]
}
"""
And database has entity CacheBundle:Category
| id | 5 |
| name | Sub main sub 3 |
| user | 1 |
| parent | 2 |
@@ -0,0 +1,266 @@
Feature: Create simple notification
As an authenticated user
I should be able to create new simple notification
@db-fixtures
Scenario:
I try to create new simple notification.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/notifications
"""
{
"name": "New notification",
"recipients": [ 1 ],
"notificationType": "alert",
"themeType": "plain",
"theme": 1,
"subject": "Some subject",
"published": true,
"automatedSubject": false,
"allowUnsubscribe": true,
"unsubscribeNotification": true,
"sources": [
{
"type": "feed",
"id": 1
}
],
"sendWhenEmpty": false,
"timezone": "Asia/Novosibirsk",
"automatic": [
{
"type": "daily",
"time": "15m",
"days": "all"
},
{
"type": "weekly",
"period": "third",
"day": "monday",
"hour": 11,
"minute": 45
},
{
"type": "monthly",
"day": 3,
"hour": 11,
"minute": 0
},
{
"type": "monthly",
"day": "last",
"hour": 0,
"minute": 55
}
],
"sendUntil": "2017-10-01",
"plainDiff": {},
"enhancedDiff": {}
}
"""
Then I got successful response
And it's contains
"""
@object@
.entity('UserBundle:Notification', 'notification, schedule, id')
.field('type', 'alert')
.field('name', 'New notification')
.field('subject', 'Some subject')
.field('owner', field('id', 1))
.field('sources',
count(1),
one(field('type', 'feed'), field('id', 1), field('name', 'test1'))
)
"""
And database has entity UserBundle:Notification\Notification
| name | New notification |
| notificationType | alert |
| owner | 1 |
| subject | Some subject |
| automatedSubject | false |
| published | true |
| allowUnsubscribe | true |
| unsubscribeNotification | true |
| sendWhenEmpty | false |
| timezone | Asia/Novosibirsk |
| sendUntil | 2017-10-01 |
| active | true |
@db-fixtures
Scenario:
I try to create new simple notification without sources, recipients and scheduling.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/notifications
"""
{
"name": "New notification",
"recipients": [],
"notificationType": "alert",
"themeType": "plain",
"theme": 1,
"subject": "Some subject",
"published": true,
"automatedSubject": false,
"allowUnsubscribe": true,
"unsubscribeNotification": true,
"sources": [],
"sendWhenEmpty": false,
"timezone": "Asia/Novosibirsk",
"automatic": [],
"sendUntil": "2017-10-01",
"plainDiff": {},
"enhancedDiff": {}
}
"""
Then I got successful response
And it's contains
"""
@object@
.entity('UserBundle:Notification', 'notification, schedule, id')
.field('type', 'alert')
.field('name', 'New notification')
.field('subject', 'Some subject')
.field('owner', field('id', 1))
.field('recipients', count(0))
.field('sources', count(0))
.field('automatic', count(0))
"""
And database has entity UserBundle:Notification\Notification
| name | New notification |
| notificationType | alert |
| owner | 1 |
| subject | Some subject |
| automatedSubject | false |
| published | true |
| allowUnsubscribe | true |
| unsubscribeNotification | true |
| sendWhenEmpty | false |
| timezone | Asia/Novosibirsk |
| sendUntil | 2017-10-01 |
| active | true |
@db-fixtures
Scenario:
I try to create new simple notification with invalid recipient.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/notifications
"""
{
"name": "New notification",
"recipients": [ 1000 ],
"notificationType": "alert",
"themeType": "plain",
"theme": 1,
"subject": "Some subject",
"published": true,
"automatedSubject": false,
"allowUnsubscribe": true,
"unsubscribeNotification": true,
"sources": [],
"sendWhenEmpty": false,
"timezone": "Asia/Novosibirsk",
"automatic": [],
"sendUntil": "2017-10-01",
"plainDiff": {},
"enhancedDiff": {}
}
"""
Then I got response with code 400
And it's contains
"""
{
"errors": [
{
"message": "This value is not valid.",
"transKey": "createNotificationRecipientsInvalid",
"type": "error",
"parameters": {
"current": [ 1000 ],
"available": null
}
}
]
}
"""
And database don't has entity UserBundle:Notification\Notification
| name | New notification |
| notificationType | alert |
| owner | 1 |
| subject | Some subject |
| automatedSubject | false |
| published | true |
| allowUnsubscribe | true |
| unsubscribeNotification | true |
| sendWhenEmpty | false |
| timezone | Asia/Novosibirsk |
| sendUntil | 2017-10-01 |
| active | true |
@db-fixtures
Scenario Outline:
I try to create new simple notification with invalid source.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/notifications
"""
{
"name": "New notification",
"recipients": [],
"notificationType": "alert",
"themeType": "plain",
"theme": 1,
"subject": "Some subject",
"published": true,
"automatedSubject": false,
"allowUnsubscribe": true,
"unsubscribeNotification": true,
"sources": [
{
<payload>
}
],
"sendWhenEmpty": false,
"timezone": "Asia/Novosibirsk",
"automatic": [],
"sendUntil": "2017-10-01",
"plainDiff": {},
"enhancedDiff": {}
}
"""
Then I got response with code 400
And it's contains
"""
{
"errors": "@array@
.one(
field('message', '<message>'),
field('transKey', '<transKey>'),
field('type', 'error')
)
"
}
"""
And database don't has entity UserBundle:Notification\Notification
| name | New notification |
| notificationType | alert |
| owner | 1 |
| subject | Some subject |
| automatedSubject | false |
| published | true |
| allowUnsubscribe | true |
| unsubscribeNotification | true |
| sendWhenEmpty | false |
| timezone | Asia/Novosibirsk |
| sendUntil | 2017-10-01 |
| active | true |
Examples:
| payload | message | transKey |
| | Some of sources has invalid id. | createNotificationSources |
| "type": "feed" | This value should not be blank. | createNotificationSourcesIdEmpty |
| "id": 1 | This value should not be blank. | createNotificationSourcesTypeEmpty |
| "type": "some", "id": 1 | This value is not valid. | createNotificationSourcesTypeInvalid |
| "type": "feed", "id": 1000 | Some of sources has invalid id. | createNotificationSources |
@@ -0,0 +1,58 @@
Feature: Get list of notifications
As an authenticated user
I should be able to get list of my notifications
@db-fixtures
Scenario:
I get list of my notification's.
Given I authenticated as test@email.com with password test
When I make GET request to /api/v1/notifications
Then I got successful response
And it's contains
"""
{
"notifications": {
"data": "@array@.every(
entity('UserBundle:Notification', 'notification_list, schedule, id'),
field('owner', field('id', 1))
)",
"count": "@integer@",
"totalCount": "@integer@",
"page": "@integer@",
"limit": "@integer@"
},
"meta": {
"sort": {
"field": "name",
"direction": "asc"
}
}
}
"""
When I make GET request to /api/v1/notifications
| onlyPublished | true |
Then I got successful response
And it's contains
"""
{
"notifications": {
"data": "@array@.every(
entity('UserBundle:Notification', 'notification_list, schedule, id'),
field('owner', field('id', 1)),
field('published', true)
)",
"count": "@integer@",
"totalCount": "@integer@",
"page": "@integer@",
"limit": "@integer@"
},
"meta": {
"sort": {
"field": "name",
"direction": "asc"
}
}
}
"""
@@ -0,0 +1,188 @@
Feature: Use 'Article Date' advanced filter
As an authenticated user
I should be able to use 'Article Date' for filtering search results
@external-index-fixtures @db-fixtures
Scenario:
I search 'cat' which appears in documents from US and use `Article Date`
advanced filters with value '31 Days'.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"filters": {
"country": {
"include": [ "US" ]
}
},
"advancedFilters": {
"articleDate": "31 Days"
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": "@array@.every(
entity('CacheBundle:Document', 'document, id'),
field('source', field('country', 'US')),
field('published', gte('#now().modify(\"- 31 Days\").format(\"c\")#'))
)",
"count": "@integer@.greaterThan(0)",
"totalCount": "@integer@.greaterThan(0)",
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {
"country": {
"include": [ "US" ]
}
},
"advancedFilters": {
"articleDate": "31 Days"
}
},
"sources": [],
"sourceLists": []
}
}
"""
And database has 1 entity CacheBundle:Query\SimpleQuery
| id | 4 |
| raw | cat |
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"filters": {
"country": {
"include": [ "US" ]
}
},
"advancedFilters": {
"articleDate": "31 Days"
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": "@array@.every(
entity('CacheBundle:Document', 'document, id'),
field('source', field('country', 'US')),
field('published', gte('#now().modify(\"- 31 Days\").format(\"c\")#'))
)",
"count": "@integer@.greaterThan(0)",
"totalCount": "@integer@.greaterThan(0)",
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {
"country": {
"include": [ "US" ]
}
},
"advancedFilters": {
"articleDate": "31 Days"
}
},
"sources": [],
"sourceLists": []
}
}
"""
And database has 1 entity CacheBundle:Query\SimpleQuery
| id | 4 |
| raw | cat |
And database don't has entity CacheBundle:Query\SimpleQuery
| id | 5 |
| raw | cat |
@db-fixtures
Scenario:
I search 'cat' which appears in documents from US and also use `Article Date`
advanced filters with empty value.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"filters": {
"country": {
"include": [ "US" ]
}
},
"advancedFilters": {
"articleDate": ""
}
}
"""
Then I got response with code 400
And it's contains
"""
{
"errors": "@array@"
}
"""
And database don't has entity CacheBundle:Query\SimpleQuery
| id | 4 |
| raw | cat |
@external-index-fixtures @db-fixtures
Scenario:
I search 'cat' which appears in documents from US and use `Article Date`
advanced filters with invalid value.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"filters": {
"country": {
"include": [ "US" ]
}
},
"advancedFilters": {
"articleDate": "111"
}
}
"""
Then I got response with code 400
And it's contains
"""
{
"errors": "@array@"
}
"""
And database don't has entity CacheBundle:Query\SimpleQuery
| id | 4 |
| raw | cat |
@@ -0,0 +1,198 @@
Feature: Use 'Article Language' advanced filter
As an authenticated user
I should be able to use 'Article Language' for filtering search results
@external-index-fixtures @db-fixtures
Scenario:
I search 'cat' and use `Article Language` advanced filters with value
'en'.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"advancedFilters": {
"articleLanguage": "en"
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": "@array@.every(
entity('CacheBundle:Document', 'document, id'),
field('language', 'en')
)",
"count": "@integer@.greaterThan(0)",
"totalCount": "@integer@.greaterThan(0)",
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {},
"advancedFilters": {
"articleLanguage": "en"
}
},
"sources": [],
"sourceLists": []
}
}
"""
And database has 1 entity CacheBundle:Query\SimpleQuery
| id | 4 |
| raw | cat |
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"advancedFilters": {
"articleLanguage": "en"
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": "@array@.every(
entity('CacheBundle:Document', 'document, id'),
field('language', 'en')
)",
"count": "@integer@.greaterThan(0)",
"totalCount": "@integer@.greaterThan(0)",
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {},
"advancedFilters": {
"articleLanguage": "en"
}
},
"sources": [],
"sourceLists": []
}
}
"""
And database has 1 entity CacheBundle:Query\SimpleQuery
| id | 4 |
| raw | cat |
And database don't has entity CacheBundle:Query\SimpleQuery
| id | 5 |
| raw | cat |
@db-fixtures
Scenario:
I search 'cat' and use `Article Language` advanced filters with empty
value.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"advancedFilters": {
"articleLanguage": ""
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": "@array@.every(entity('CacheBundle:Document', 'document, id'))",
"count": "@integer@",
"totalCount": "@integer@",
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {},
"advancedFilters": {
"articleLanguage": ""
}
},
"sources": [],
"sourceLists": []
}
}
"""
And database has entity CacheBundle:Query\SimpleQuery
| id | 4 |
| raw | cat |
@external-index-fixtures @db-fixtures
Scenario:
I search 'cat' and use `Article Language` advanced filters with invalid
value.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"advancedFilters": {
"articleLanguage": "some"
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": [],
"count": 0,
"totalCount": 0,
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {},
"advancedFilters": {
"articleLanguage": "some"
}
},
"sources": [],
"sourceLists": []
}
}
"""
And database has entity CacheBundle:Query\SimpleQuery
| id | 4 |
| raw | cat |
@@ -0,0 +1,240 @@
Feature: Use 'Author' advanced filter
As an authenticated user
I should be able to use 'Author' for filtering search results
@external-index-fixtures @db-fixtures
Scenario:
I search 'cat' which appears in documents from US and use `Author`
advanced filters with value 'Gracie Pfeffer'.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"filters": {
"country": {
"include": [ "US" ]
}
},
"advancedFilters": {
"author": "Gracie Pfeffer"
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": "@array@.every(
entity('CacheBundle:Document', 'document, id'),
field('source', field('country', 'US')),
field('author', field('name', 'Gracie Pfeffer'))
)",
"count": "@integer@.greaterThan(0)",
"totalCount": "@integer@.greaterThan(0)",
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {
"country": {
"include": [ "US" ]
}
},
"advancedFilters": {
"author": "Gracie Pfeffer"
}
},
"sources": [],
"sourceLists": []
}
}
"""
And database has 1 entity CacheBundle:Query\SimpleQuery
| id | 4 |
| raw | cat |
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"filters": {
"country": {
"include": [ "US" ]
}
},
"advancedFilters": {
"author": "Gracie Pfeffer"
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": "@array@.every(
entity('CacheBundle:Document', 'document, id'),
field('source', field('country', 'US')),
field('author', field('name', 'Gracie Pfeffer'))
)",
"count": "@integer@.greaterThan(0)",
"totalCount": "@integer@.greaterThan(0)",
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {
"country": {
"include": [ "US" ]
}
},
"advancedFilters": {
"author": "Gracie Pfeffer"
}
},
"sources": [],
"sourceLists": []
}
}
"""
And database has 1 entity CacheBundle:Query\SimpleQuery
| id | 4 |
| raw | cat |
And database don't has entity CacheBundle:Query\SimpleQuery
| id | 5 |
| raw | cat |
@db-fixtures
Scenario:
I search 'cat' which appears in documents from US and use `Author`
advanced filters with empty value.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"filters": {
"country": {
"include": [ "US" ]
}
},
"advancedFilters": {
"author": ""
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": "@array@.every(
entity('CacheBundle:Document', 'document, id'),
field('source', field('country', 'US'))
)",
"count": "@integer@.greaterThan(0)",
"totalCount": "@integer@.greaterThan(0)",
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {
"country": {
"include": [ "US" ]
}
},
"advancedFilters": {
"author": ""
}
},
"sources": [],
"sourceLists": []
}
}
"""
And database has entity CacheBundle:Query\SimpleQuery
| id | 4 |
| raw | cat |
@external-index-fixtures @db-fixtures
Scenario:
I search 'cat' which appears in documents from US and use `Author`
advanced filters with invalid value.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"filters": {
"country": {
"include": [ "US" ]
}
},
"advancedFilters": {
"author": "some"
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": [],
"count": 0,
"totalCount": 0,
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {
"country": {
"include": [ "US" ]
}
},
"advancedFilters": {
"author": "some"
}
},
"sources": [],
"sourceLists": []
}
}
"""
And database has entity CacheBundle:Query\SimpleQuery
| id | 4 |
| raw | cat |
@@ -0,0 +1,198 @@
Feature: Use 'Publisher' advanced filter
As an authenticated user
I should be able to use 'Publisher' for filtering search results
@external-index-fixtures @db-fixtures
Scenario:
I search 'cat' and use `Publisher` advanced filters with value 'msnbc'.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"advancedFilters": {
"publisher": "msnbc"
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": "@array@.every(
entity('CacheBundle:Document', 'document, id'),
field('publisher', contains('msnbc', true))
)",
"count": "@integer@.greaterThan(0)",
"totalCount": "@integer@.greaterThan(0)",
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {},
"advancedFilters": {
"publisher": "msnbc"
}
},
"sources": [],
"sourceLists": []
}
}
"""
And database has 1 entity CacheBundle:Query\SimpleQuery
| id | 4 |
| raw | cat |
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"advancedFilters": {
"publisher": "msnbc"
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": "@array@.every(
entity('CacheBundle:Document', 'document, id'),
field('publisher', contains('msnbc', true))
)",
"count": "@integer@.greaterThan(0)",
"totalCount": "@integer@.greaterThan(0)",
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {},
"advancedFilters": {
"publisher": "msnbc"
}
},
"sources": [],
"sourceLists": []
}
}
"""
And database has 1 entity CacheBundle:Query\SimpleQuery
| id | 4 |
| raw | cat |
And database don't has entity CacheBundle:Query\SimpleQuery
| id | 5 |
| raw | cat |
@db-fixtures
Scenario:
I search 'cat' and use `Publisher` advanced filters with empty value.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"advancedFilters": {
"publisher": ""
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": "@array@.every(
entity('CacheBundle:Document', 'document, id')
)",
"count": "@integer@.greaterThan(0)",
"totalCount": "@integer@.greaterThan(0)",
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {},
"advancedFilters": {
"publisher": ""
}
},
"sources": [],
"sourceLists": []
}
}
"""
And database has entity CacheBundle:Query\SimpleQuery
| id | 4 |
| raw | cat |
@external-index-fixtures @db-fixtures
Scenario:
I search 'cat' and use `Publisher` advanced filters with invalid value.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"advancedFilters": {
"publisher": "some"
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": [],
"count": 0,
"totalCount": 0,
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {},
"advancedFilters": {
"publisher": "some"
}
},
"sources": [],
"sourceLists": []
}
}
"""
And database has entity CacheBundle:Query\SimpleQuery
| id | 4 |
| raw | cat |
@@ -0,0 +1,154 @@
Feature: Use 'Reach' advanced filter
As an authenticated user
I should be able to use 'Reach' for filtering search results
@external-index-fixtures @db-fixtures
Scenario:
I search 'cat' and use `Reach` advanced filters with value '10000+'.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"advancedFilters": {
"reach": "10000+"
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": "@array@.every(
entity('CacheBundle:Document', 'document, id'),
field('views', greaterThan(10000), lowerThan(25000))
)",
"count": "@integer@.greaterThan(0)",
"totalCount": "@integer@.greaterThan(0)",
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {},
"advancedFilters": {
"reach": "10000+"
}
},
"sources": [],
"sourceLists": []
}
}
"""
And database has 1 entity CacheBundle:Query\SimpleQuery
| id | 4 |
| raw | cat |
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"advancedFilters": {
"reach": "10000+"
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": "@array@.every(
entity('CacheBundle:Document', 'document, id'),
field('views', greaterThan(10000), lowerThan(25000))
)",
"count": "@integer@.greaterThan(0)",
"totalCount": "@integer@.greaterThan(0)",
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {},
"advancedFilters": {
"reach": "10000+"
}
},
"sources": [],
"sourceLists": []
}
}
"""
And database has 1 entity CacheBundle:Query\SimpleQuery
| id | 4 |
| raw | cat |
And database don't has entity CacheBundle:Query\SimpleQuery
| id | 5 |
| raw | cat |
@db-fixtures
Scenario:
I search 'cat' and use `Reach` advanced filters with empty value.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"advancedFilters": {
"reach": ""
}
}
"""
Then I got response with code 400
And it's contains
"""
{
"errors": "@array@"
}
"""
And database don't has entity CacheBundle:Query\SimpleQuery
| id | 4 |
| raw | cat |
@external-index-fixtures @db-fixtures
Scenario:
I search 'cat' and use `Reach` advanced filters with invalid value.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"advancedFilters": {
"reach": "111"
}
}
"""
Then I got response with code 400
And it's contains
"""
{
"errors": "@array@"
}
"""
And database don't has entity CacheBundle:Query\SimpleQuery
| id | 3 |
| raw | cat |
@@ -0,0 +1,246 @@
Feature: Use 'Source' advanced filter
As an authenticated user
I should be able to use 'Source' for filtering search results
@external-index-fixtures @db-fixtures
Scenario:
I search 'cat' which appears in documents from US and after it add `source`
advanced filters with value 'CNN'.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"filters": {
"country": {
"include": [ "US" ]
}
},
"advancedFilters": {
"source": "CNN"
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": "@array@.every(
entity('CacheBundle:Document', 'document, id'),
field('source',
field('country', 'US'),
field('title', 'CNN')
)
)",
"count": "@integer@.greaterThan(0)",
"totalCount": "@integer@.greaterThan(0)",
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {
"country": {
"include": [ "US" ]
}
},
"advancedFilters": {
"source": "CNN"
}
},
"sources": [],
"sourceLists": []
}
}
"""
And database has 1 entity CacheBundle:Query\SimpleQuery
| id | 4 |
| raw | cat |
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"filters": {
"country": {
"include": [ "US" ]
}
},
"advancedFilters": {
"source": "CNN"
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": "@array@.every(
entity('CacheBundle:Document', 'document, id'),
field('source',
field('country', 'US'),
field('title', 'CNN')
)
)",
"count": "@integer@.greaterThan(0)",
"totalCount": "@integer@.greaterThan(0)",
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {
"country": {
"include": [ "US" ]
}
},
"advancedFilters": {
"source": "CNN"
}
},
"sources": [],
"sourceLists": []
}
}
"""
And database has 1 entity CacheBundle:Query\SimpleQuery
| id | 4 |
| raw | cat |
And database don't has entity CacheBundle:Query\SimpleQuery
| id | 5 |
| raw | cat |
@db-fixtures
Scenario:
I search 'cat' which appears in documents from US and after it add `source`
advanced filters with empty value.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"filters": {
"country": {
"include": [ "US" ]
}
},
"advancedFilters": {
"source": ""
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": "@array@.every(
entity('CacheBundle:Document', 'document, id'),
field('source',
field('country', 'US')
)
)",
"count": "@integer@.greaterThan(0)",
"totalCount": "@integer@.greaterThan(0)",
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {
"country": {
"include": [ "US" ]
}
},
"advancedFilters": {
"source": ""
}
},
"sources": [],
"sourceLists": []
}
}
"""
And database has entity CacheBundle:Query\SimpleQuery
| id | 4 |
| raw | cat |
@db-fixtures
Scenario:
I search 'cat' and use `Source` advanced filters with unknown value.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"filters": {
"country": {
"include": [ "US" ]
}
},
"advancedFilters": {
"source": "some"
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": [],
"count": 0,
"totalCount": 0,
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {
"country": {
"include": [ "US" ]
}
},
"advancedFilters": {
"source": "some"
}
},
"sources": [],
"sourceLists": []
}
}
"""
And database has entity CacheBundle:Query\SimpleQuery
| id | 4 |
| raw | cat |
@@ -0,0 +1,198 @@
Feature: Use 'Source City' advanced filter
As an authenticated user
I should be able to use 'Source City' for filtering search results
@external-index-fixtures @db-fixtures
Scenario:
I search 'cat' and use `Source City` advanced filters with value 'Arizona'.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"advancedFilters": {
"sourceCity": "Amazing City"
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": "@array@.every(
entity('CacheBundle:Document', 'document, id'),
field('source', field('city', 'Amazing City'))
)",
"count": "@integer@.greaterThan(0)",
"totalCount": "@integer@.greaterThan(0)",
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {},
"advancedFilters": {
"sourceCity": "Amazing City"
}
},
"sources": [],
"sourceLists": []
}
}
"""
And database has 1 entity CacheBundle:Query\SimpleQuery
| id | 4 |
| raw | cat |
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"advancedFilters": {
"sourceCity": "Amazing City"
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": "@array@.every(
entity('CacheBundle:Document', 'document, id'),
field('source', field('city', 'Amazing City'))
)",
"count": "@integer@.greaterThan(0)",
"totalCount": "@integer@.greaterThan(0)",
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {},
"advancedFilters": {
"sourceCity": "Amazing City"
}
},
"sources": [],
"sourceLists": []
}
}
"""
And database has 1 entity CacheBundle:Query\SimpleQuery
| id | 4 |
| raw | cat |
And database don't has entity CacheBundle:Query\SimpleQuery
| id | 5 |
| raw | cat |
@db-fixtures
Scenario:
I search 'cat' and use `Source City` advanced filters with empty value.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"advancedFilters": {
"sourceCity": ""
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": "@array@.every(
entity('CacheBundle:Document', 'document, id')
)",
"count": "@integer@.greaterThan(0)",
"totalCount": "@integer@.greaterThan(0)",
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {},
"advancedFilters": {
"sourceCity": ""
}
},
"sources": [],
"sourceLists": []
}
}
"""
And database has entity CacheBundle:Query\SimpleQuery
| id | 4 |
| raw | cat |
@external-index-fixtures @db-fixtures
Scenario:
I search 'cat' and after it add `sourceCity` advanced filters with invalid
value.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"advancedFilters": {
"sourceCity": "some"
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": [],
"count": 0,
"totalCount": 0,
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {},
"advancedFilters": {
"sourceCity": "some"
}
},
"sources": [],
"sourceLists": []
}
}
"""
And database has 1 entity CacheBundle:Query\SimpleQuery
| id | 4 |
| raw | cat |
@@ -0,0 +1,197 @@
Feature: Use 'Source Country' advanced filter
As an authenticated user
I should be able to use 'Source Country' for filtering search results
@external-index-fixtures @db-fixtures
Scenario:
I search 'cat' and use `Source Country` advanced filters with value 'US'.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"advancedFilters": {
"sourceCountry": "US"
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": "@array@.every(
entity('CacheBundle:Document', 'document, id'),
field('source', field('country', 'US'))
)",
"count": "@integer@.greaterThan(0)",
"totalCount": "@integer@.greaterThan(0)",
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {},
"advancedFilters": {
"sourceCountry": "US"
}
},
"sources": [],
"sourceLists": []
}
}
"""
And database has 1 entity CacheBundle:Query\SimpleQuery
| id | 4 |
| raw | cat |
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"advancedFilters": {
"sourceCountry": "US"
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": "@array@.every(
entity('CacheBundle:Document', 'document, id'),
field('source', field('country', 'US'))
)",
"count": "@integer@.greaterThan(0)",
"totalCount": "@integer@.greaterThan(0)",
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {},
"advancedFilters": {
"sourceCountry": "US"
}
},
"sources": [],
"sourceLists": []
}
}
"""
And database has 1 entity CacheBundle:Query\SimpleQuery
| id | 4 |
| raw | cat |
And database don't has entity CacheBundle:Query\SimpleQuery
| id | 5 |
| raw | cat |
@db-fixtures
Scenario:
I search 'cat' and use `Source Country` advanced filters with empty value.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"advancedFilters": {
"sourceCountry": ""
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": "@array@.every(
entity('CacheBundle:Document', 'document, id')
)",
"count": "@integer@.greaterThan(0)",
"totalCount": "@integer@.greaterThan(0)",
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {},
"advancedFilters": {
"sourceCountry": ""
}
},
"sources": [],
"sourceLists": []
}
}
"""
And database has entity CacheBundle:Query\SimpleQuery
| id | 4 |
| raw | cat |
@external-index-fixtures @db-fixtures
Scenario:
I search 'cat' use `Source Country` advanced filters with invalid value.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"advancedFilters": {
"sourceCountry": "some"
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": [],
"count": 0,
"totalCount": 0,
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {},
"advancedFilters": {
"sourceCountry": "some"
}
},
"sources": [],
"sourceLists": []
}
}
"""
And database has entity CacheBundle:Query\SimpleQuery
| id | 4 |
| raw | cat |
@@ -0,0 +1,197 @@
Feature: Use 'Source Section' advanced filter
As an authenticated user
I should be able to use 'Source Section' for filtering search results
@external-index-fixtures @db-fixtures
Scenario:
I search 'cat' and use `Source Section` advanced filters with value 'Lifestyle'.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"advancedFilters": {
"sourceSection": "Lifestyle"
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": "@array@.every(
entity('CacheBundle:Document', 'document, id'),
field('source', field('section', 'Lifestyle'))
)",
"count": "@integer@.greaterThan(0)",
"totalCount": "@integer@.greaterThan(0)",
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {},
"advancedFilters": {
"sourceSection": "Lifestyle"
}
},
"sources": [],
"sourceLists": []
}
}
"""
And database has 1 entity CacheBundle:Query\SimpleQuery
| id | 4 |
| raw | cat |
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"advancedFilters": {
"sourceSection": "Lifestyle"
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": "@array@.every(
entity('CacheBundle:Document', 'document, id'),
field('source', field('section', 'Lifestyle'))
)",
"count": "@integer@.greaterThan(0)",
"totalCount": "@integer@.greaterThan(0)",
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {},
"advancedFilters": {
"sourceSection": "Lifestyle"
}
},
"sources": [],
"sourceLists": []
}
}
"""
And database has 1 entity CacheBundle:Query\SimpleQuery
| id | 4 |
| raw | cat |
And don't has entity CacheBundle:Query\SimpleQuery
| id | 5 |
| raw | cat |
@db-fixtures
Scenario:
I search 'cat' and use `Source Section` advanced filters with empty value.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"advancedFilters": {
"sourceSection": ""
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": "@array@.every(
entity('CacheBundle:Document', 'document, id')
)",
"count": "@integer@.greaterThan(0)",
"totalCount": "@integer@.greaterThan(0)",
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {},
"advancedFilters": {
"sourceSection": ""
}
},
"sources": [],
"sourceLists": []
}
}
"""
And database has entity CacheBundle:Query\SimpleQuery
| id | 4 |
| raw | cat |
@external-index-fixtures @db-fixtures
Scenario:
I search 'cat' and use `Source Section` advanced filters with invalid value.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"advancedFilters": {
"sourceSection": "some"
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": [],
"count": 0,
"totalCount": 0,
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {},
"advancedFilters": {
"sourceSection": "some"
}
},
"sources": [],
"sourceLists": []
}
}
"""
And database has 1 entity CacheBundle:Query\SimpleQuery
| id | 4 |
| raw | cat |
@@ -0,0 +1,197 @@
Feature: Use 'Source State' advanced filter
As an authenticated user
I should be able to use 'Source State' for filtering search results
@external-index-fixtures @db-fixtures
Scenario:
I search 'cat' and use `Source State` advanced filters with value 'Arizona'.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"advancedFilters": {
"sourceState": "Arizona"
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": "@array@.every(
entity('CacheBundle:Document', 'document, id'),
field('source', field('state', 'Arizona'))
)",
"count": "@integer@.greaterThan(0)",
"totalCount": "@integer@.greaterThan(0)",
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {},
"advancedFilters": {
"sourceState": "Arizona"
}
},
"sources": [],
"sourceLists": []
}
}
"""
And database has 1 entity CacheBundle:Query\SimpleQuery
| id | 4 |
| raw | cat |
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"advancedFilters": {
"sourceState": "Arizona"
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": "@array@.every(
entity('CacheBundle:Document', 'document, id'),
field('source', field('state', 'Arizona'))
)",
"count": "@integer@.greaterThan(0)",
"totalCount": "@integer@.greaterThan(0)",
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {},
"advancedFilters": {
"sourceState": "Arizona"
}
},
"sources": [],
"sourceLists": []
}
}
"""
And database has 1 entity CacheBundle:Query\SimpleQuery
| id | 4 |
| raw | cat |
And don't has entity CacheBundle:Query\SimpleQuery
| id | 5 |
| raw | cat |
@db-fixtures
Scenario:
I search 'cat' and use `Source State` advanced filters with empty value.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"advancedFilters": {
"sourceState": ""
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": "@array@.every(
entity('CacheBundle:Document', 'document, id')
)",
"count": "@integer@.greaterThan(0)",
"totalCount": "@integer@.greaterThan(0)",
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {},
"advancedFilters": {
"sourceState": ""
}
},
"sources": [],
"sourceLists": []
}
}
"""
And database has entity CacheBundle:Query\SimpleQuery
| id | 4 |
| raw | cat |
@external-index-fixtures @db-fixtures
Scenario:
I search 'cat' and use `Source State` advanced filters with invalid value.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"advancedFilters": {
"sourceState": "some"
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": [],
"count": 0,
"totalCount": 0,
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {},
"advancedFilters": {
"sourceState": "some"
}
},
"sources": [],
"sourceLists": []
}
}
"""
And database has 1 entity CacheBundle:Query\SimpleQuery
| id | 4 |
| raw | cat |
@@ -0,0 +1,207 @@
Feature: Use 'Country' filter
As an authenticated user
I should be able to use 'Country' for filtering search results
@external-index-fixtures @db-fixtures
Scenario:
I search 'cat' which appears in documents with US language.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"filters": {
"country": {
"include": [ "US" ]
}
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": "@array@.every(
entity('CacheBundle:Document', 'document, id'),
field('source', field('country', 'US'))
)",
"count": "@integer@.greaterThan(0)",
"totalCount": "@integer@.greaterThan(0)",
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {
"country": {
"include": [ "US" ]
}
},
"advancedFilters": {}
},
"sources": [],
"sourceLists": []
}
}
"""
@external-index-fixtures @db-fixtures
Scenario:
I search 'cat' which appears in documents not with US language.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"filters": {
"country": {
"exclude": [ "US" ]
}
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": "@array@.every(
entity('CacheBundle:Document', 'document, id'),
not(field('source', field('country', 'US')))
)",
"count": "@integer@.greaterThan(0)",
"totalCount": "@integer@.greaterThan(0)",
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {
"country": {
"exclude": [ "US" ]
}
},
"advancedFilters": {}
},
"sources": [],
"sourceLists": []
}
}
"""
@external-index-fixtures @db-fixtures
Scenario:
I search 'cat' which appears in documents with US and RU languages.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"filters": {
"country": {
"include": [ "US", "RU" ]
}
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": "@array@.every(
entity('CacheBundle:Document', 'document, id'),
field('source', oneOf(
field('country', 'US'),
field('country', 'RU')
))
)",
"count": "@integer@.greaterThan(0)",
"totalCount": "@integer@.greaterThan(0)",
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {
"country": {
"include": [ "US", "RU" ]
}
},
"advancedFilters": {}
},
"sources": [],
"sourceLists": []
}
}
"""
Scenario:
I search 'cat' which appears in documents with unknown language.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"filters": {
"country": {
"include": [ "unknown" ]
}
}
}
"""
Then I got response with code 400
And it's contains
"""
{
"errors": "@array@"
}
"""
Scenario:
I search 'cat' which appears in documents not with unknown language.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"filters": {
"country": {
"exclude": [ "unknown" ]
}
}
}
"""
Then I got response with code 400
And it's contains
"""
{
"errors": "@array@"
}
"""
@@ -0,0 +1,255 @@
Feature: Use 'Date' filter
As an authenticated user
I should be able to use 'Date' for filtering search results
@external-index-fixtures @db-fixtures
Scenario:
I search 'cat' in documents which found maximum 10 days ago.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"filters": {
"date": {
"type": "last"
"days": 10
}
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": "@array@.every(
entity('CacheBundle:Document', 'document, id'),
oneOf(
field('title', contains('cat', true)),
field('content', contains('cat', true))
),
field('published', gte('#now().modify(\"- 10 days\").format(\"c\")#'))
)",
"count": "@integer@.greaterThan(0)",
"totalCount": "@integer@.greaterThan(0)",
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@"
}
"""
@external-index-fixtures @db-fixtures
Scenario:
I search 'cat' in documents which found between some period.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"filters": {
"date": {
"type": "between",
"start": "#now().modify(\"- 30 days\").format(\"Y-m-d\")#",
"end": "#now().modify(\"- 1 days\").format(\"Y-m-d\")#"
}
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": "@array@.every(
entity('CacheBundle:Document', 'document, id'),
oneOf(
field('title', contains('cat', true)),
field('content', contains('cat', true))
),
field('published', between(
'#now().modify(\"- 30 days\").format(\"c\")#',
'#now().modify(\"- 1 days\").format(\"c\")#'
))
)",
"count": "@integer@.greaterThan(0)",
"totalCount": "@integer@.greaterThan(0)",
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@"
}
"""
Scenario:
I search 'cat' in documents which filtered by date filter with invalid type.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"filters": {
"date": {
"type": "invalid"
}
}
}
"""
Then I got response with code 400
And it's contains
"""
{
"errors": "@array@"
}
"""
Scenario:
I search 'cat' in documents which filtered by date filter with 'last' type
but not provide 'days' field.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"filters": {
"date": {
"type": "last"
}
}
}
"""
Then I got response with code 400
And it's contains
"""
{
"errors": "@array@"
}
"""
Scenario Outline:
I search 'cat' in documents which filtered by date filter with 'last' type
but provide invalid 'days' values.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"filters": {
"date": {
"type": "last",
"days": <value>
}
}
}
"""
Then I got response with code 400
And it's contains
"""
{
"errors": "@array@"
}
"""
Examples:
| value |
| "invalid" |
| 0 |
| -10 |
Scenario:
I search 'cat' in documents which filtered by date filter with 'between' type
but not provide 'start' and 'end' values.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"filters": {
"date": {
"type": "between"
}
}
}
"""
Then I got response with code 400
And it's contains
"""
{
"errors": "@array@"
}
"""
Scenario Outline:
I search 'cat' in documents which filtered by date filter with 'between' type
but provide invalid 'start' and 'end' values.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"filters": {
"date": {
"type": "between",
"start": "<date>",
"end": "<date>"
}
}
}
"""
Then I got response with code 400
And it's contains
"""
{
"errors": "@array@"
}
"""
Examples:
| date |
| 2017-13-20 |
| some |
| 2017-01-40 |
Scenario:
I search 'cat' in documents which filtered by date filter with 'between' type
but provide 'start' greater than 'end'.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"filters": {
"date": {
"type": "between",
"start": "#now().modify(\"- 15 days\").format(\"Y-m-d\")#",
"end": "#now().modify(\"- 30 days\").format(\"Y-m-d\")#"
}
}
}
"""
Then I got response with code 400
And it's contains
"""
{
"errors": "@array@"
}
"""
@@ -0,0 +1,129 @@
Feature: Use 'Has Image' filter
As an authenticated user
I should be able to use 'Has Image' for filtering search results
@external-index-fixtures @db-fixtures
Scenario:
I search 'cat' which appears in documents which have image.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"filters": {
"hasImage": true
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": "@array@.every(
entity('CacheBundle:Document', 'document, id'),
field('image', isNotEmpty())
)",
"count": "@integer@.greaterThan(0)",
"totalCount": "@integer@.greaterThan(0)",
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {
"hasImage": true
},
"advancedFilters": {}
},
"sources": [],
"sourceLists": []
}
}
"""
@external-index-fixtures @db-fixtures
Scenario:
I search 'cat' which appears in documents which is may have images.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"filters": {
"hasImage": false
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": "@array@.every(
entity('CacheBundle:Document', 'document, id'),
oneOf(
field('image', isEmpty()),
field('image', isNotEmpty())
)
)",
"count": "@integer@.greaterThan(0)",
"totalCount": "@integer@.greaterThan(0)",
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {
"hasImage": false
},
"advancedFilters": {}
},
"sources": [],
"sourceLists": []
}
}
"""
Scenario Outline:
I search 'cat' which appears in documents which filtered by hasImage filters
with invalid value.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"filters": {
"hasImage": <value>
}
}
"""
Then I got response with code 400
And it's contains
"""
{
"errors": "@array@"
}
"""
Examples:
| value |
| "some" |
| 10 |
| "true" |
@@ -0,0 +1,344 @@
Feature: Use 'Headline' filter
As an authenticated user
I should be able to use 'Headline' for filtering search results
@external-index-fixtures @db-fixtures
Scenario:
I search 'cat'.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"filters": {}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": "@array@.every(
entity('CacheBundle:Document', 'document, id'),
oneOf(
field('title', contains('cat', true)),
field('title', contains('dog', true)),
field('title', contains('fish', true)),
field('content', contains('cat', true)),
field('content', contains('dog', true)),
field('content', contains('fish', true))
)
)",
"count": "@integer@.greaterThan(0)",
"totalCount": "@integer@.greaterThan(0)",
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {},
"advancedFilters": {}
},
"sources": [],
"sourceLists": []
}
}
"""
@external-index-fixtures @db-fixtures
Scenario:
I search 'cat', and also include 'dog' in headline.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"filters": {
"headline": {
"include": "dog"
}
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": "@array@.every(
entity('CacheBundle:Document', 'document, id'),
oneOf(
field('title', contains('cat', true)),
field('content', contains('cat', true))
),
field('title',
contains('cat', true),
contains('dog', true)
)
)",
"count": "@integer@.greaterThan(0)",
"totalCount": "@integer@.greaterThan(0)",
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {
"headline": {
"include": "dog"
}
},
"advancedFilters": {}
},
"sources": [],
"sourceLists": []
}
}
"""
@external-index-fixtures @db-fixtures
Scenario:
I search 'cat' which not include 'cat' in headline.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"filters": {
"headline": {
"exclude": "cat"
}
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": "@array@.every(
entity('CacheBundle:Document', 'document, id'),
oneOf(
field('title', contains('cat', true)),
field('content', contains('cat', true))
),
field('title',
not(contains('cat', true)),
contains('some', true)
),
field('content', contains('cat', true))
)",
"count": "@integer@.greaterThan(0)",
"totalCount": "@integer@.greaterThan(0)",
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {
"headline": {
"exclude": "cat"
}
},
"advancedFilters": {}
},
"sources": [],
"sourceLists": []
}
}
"""
@external-index-fixtures @db-fixtures
Scenario:
I search 'cat' without 'dog' and 'fish' in headline.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"filters": {
"headline": {
"exclude": "dog, fish"
}
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": "@array@.every(
entity('CacheBundle:Document', 'document, id'),
oneOf(
field('title', contains('cat', true)),
field('content', contains('cat', true))
),
field('title',
not(contains('dog', true)),
not(contains('fish', true))
)
)",
"count": "@integer@.greaterThan(0)",
"totalCount": "@integer@.greaterThan(0)",
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {
"headline": {
"exclude": "dog, fish"
}
},
"advancedFilters": {}
},
"sources": [],
"sourceLists": []
}
}
"""
@external-index-fixtures @db-fixtures
Scenario:
I search 'cat' with 'dog' but without 'fish' in headline.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"filters": {
"headline": {
"include": "dog",
"exclude": "fish"
}
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": "@array@.every(
entity('CacheBundle:Document', 'document, id'),
oneOf(
field('title', contains('cat', true)),
field('content', contains('cat', true))
),
field('title',
contains('cat', true),
contains('dog', true),
not(contains('fish', true))
)
)",
"count": "@integer@.greaterThan(0)",
"totalCount": "@integer@.greaterThan(0)",
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {
"headline": {
"include": "dog",
"exclude": "fish"
}
},
"advancedFilters": {}
},
"sources": [],
"sourceLists": []
}
}
"""
@external-index-fixtures @db-fixtures
Scenario:
I search documents 'fish' without 'cat' in headline.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "fish",
"page": 1,
"filters": {
"headline": {
"exclude": "cat"
}
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": "@array@.every(
entity('CacheBundle:Document', 'document, id'),
oneOf(
field('title', contains('fish', true)),
field('content', contains('fish', true))
),
field('title', not(contains('cat', true)))
)",
"count": "@integer@.greaterThan(0)",
"totalCount": "@integer@.greaterThan(0)",
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "fish",
"filters": {
"headline": {
"exclude": "cat"
}
},
"advancedFilters": {}
},
"sources": [],
"sourceLists": []
}
}
"""
@@ -0,0 +1,168 @@
Feature: Use 'Language' filter
As an authenticated user
I should be able to use 'Language' for filtering search results
@external-index-fixtures @db-fixtures
Scenario:
I search 'cat' which appears in documents with english language.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"filters": {
"language": [ "en" ]
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": "@array@.every(
entity('CacheBundle:Document', 'document, id'),
field('language', 'en')
)",
"count": "@integer@.greaterThan(0)",
"totalCount": "@integer@.greaterThan(0)",
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {
"language": [ "en" ]
},
"advancedFilters": {}
},
"sources": [],
"sourceLists": []
}
}
"""
@external-index-fixtures @db-fixtures
Scenario:
I search 'cat' which appears in documents with english and russian languages.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"filters": {
"language": [ "en", "ru" ]
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": "@array@.every(
entity('CacheBundle:Document', 'document, id'),
oneOf(
field('language', 'en'),
field('language', 'ru')
)
)",
"count": "@integer@.greaterThan(0)",
"totalCount": "@integer@.greaterThan(0)",
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {
"language": [ "en", "ru" ]
},
"advancedFilters": {}
},
"sources": [],
"sourceLists": []
}
}
"""
Scenario:
I search 'cat' which appears in documents with unknown languages.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"filters": {
"language": [ "unknown" ]
}
}
"""
Then I got response with code 400
And it's contains
"""
{
"errors": "@array@"
}
"""
@external-index-fixtures @db-fixtures
Scenario:
I search 'cat' which appears in documents with empty language filters.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"filters": {
"language": [ ]
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": "@array@.every(
entity('CacheBundle:Document', 'document, id')
)",
"count": "@integer@.greaterThan(0)",
"totalCount": "@integer@.greaterThan(0)",
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {
"language": []
},
"advancedFilters": {}
},
"sources": [],
"sourceLists": []
}
}
"""
@@ -0,0 +1,207 @@
Feature: Use 'State' filter
As an authenticated user
I should be able to use 'State' for filtering search results
@external-index-fixtures @db-fixtures
Scenario:
I search 'cat' which appears in documents from state Arizona.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"filters": {
"state": {
"include": [ "AZ" ]
}
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": "@array@.every(
entity('CacheBundle:Document', 'document, id'),
field('source', field('state', 'Arizona'))
)",
"count": "@integer@.greaterThan(0)",
"totalCount": "@integer@.greaterThan(0)",
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {
"state": {
"include": [ "AZ" ]
}
},
"advancedFilters": {}
},
"sources": [],
"sourceLists": []
}
}
"""
@external-index-fixtures @db-fixtures
Scenario:
I search 'cat' which appears in documents not from state Arizona.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"filters": {
"state": {
"exclude": [ "AZ" ]
}
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": "@array@.every(
entity('CacheBundle:Document', 'document, id'),
not(field('source', field('state', 'Arizona')))
)",
"count": "@integer@.greaterThan(0)",
"totalCount": "@integer@.greaterThan(0)",
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {
"state": {
"exclude": [ "AZ" ]
}
},
"advancedFilters": {}
},
"sources": [],
"sourceLists": []
}
}
"""
@external-index-fixtures @db-fixtures
Scenario:
I search 'cat' which appears in documents not from Louisiana and Maryland.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"filters": {
"state": {
"include": [ "LA", "MD" ]
}
}
}
"""
Then I got successful response
And it's contains
"""
{
"documents": {
"data": "@array@.every(
entity('CacheBundle:Document', 'document, id'),
field('source', oneOf(
field('state', 'Louisiana'),
field('state', 'Maryland')
))
)",
"count": "@integer@.greaterThan(0)",
"totalCount": "@integer@.greaterThan(0)",
"page": 1,
"limit": 100
},
"advancedFilters": "@array@",
"stats": "@object@",
"meta": {
"type": "query",
"status": "synced",
"search": {
"query": "cat",
"filters": {
"state": {
"include": [ "LA", "MD" ]
}
},
"advancedFilters": {}
},
"sources": [],
"sourceLists": []
}
}
"""
Scenario:
I search 'cat' which appears in documents from unknown state.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"filters": {
"state": {
"include": [ "unknown" ]
}
}
}
"""
Then I got response with code 400
And it's contains
"""
{
"errors": "@array@"
}
"""
Scenario:
I search 'cat' which appears in documents not from unknown state.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/query/search
"""
{
"query": "cat",
"page": 1,
"filters": {
"state": {
"exclude": [ "unknown" ]
}
}
}
"""
Then I got response with code 400
And it's contains
"""
{
"errors": "@array@"
}
"""
@@ -0,0 +1,34 @@
Feature: Create recipient group
As an master
I should be able to create group of recipients
@db-fixtures
Scenario:
I try to create recipient group.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/recipients/groups
"""
{
"name": "Test Group",
"description": "some group",
"active": true,
"recipients": [],
"notifications": []
}
"""
Then I got successful response
And it's contains
"""
@object@
.entity('UserBundle:GroupRecipient', 'recipient, id')
.field('name', 'Test Group')
.field('description', 'some group')
.field('active', true)
.field('recipients', [])
.field('notifications', [])
"""
And database has entity UserBundle:GroupRecipient
| name | Test Group |
| description | some group |
| active | true |
@@ -0,0 +1,36 @@
Feature: Create recipient
As an master
I must be able to create new person recipient
@db-fixtures
Scenario:
I try to create new recipient.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/recipients
"""
{
"firstName": "Test",
"lastName": "User",
"email": "test.user@email.com",
"active": true,
"notifications": [],
"groups": []
}
"""
Then I got successful response
And it's contains
"""
@object@
.entity('UserBundle:PersonRecipient', 'recipient, id')
.field('firstName', 'Test')
.field('lastName', 'User')
.field('email', 'test.user@email.com')
.field('active', true)
.field('groups', [])
"""
And database has entity UserBundle:PersonRecipient
| firstName | Test |
| lastName | User |
| email | test.user@email.com |
| active | true |
@@ -0,0 +1,63 @@
Feature: Add sources to list
As an authenticated user
I should be able to place sources in my lists
@db-fixtures @source-index-fixtures
Scenario:
I make empty request.
Given I authenticated as test@email.com with password test
And I make POST request to /api/v1/source-index/add-to-sources-list
"""
{
"sources": [ 1, 2 ],
"sourceLists": [ 1, 3, 5, 7, 9, 11 ]
}
"""
Then I got response with code 204
# Check database.
And database has entity CacheBundle:SourceToSourceList
| source | 1 |
| list | 1 |
And has entity CacheBundle:SourceToSourceList
| source | 1 |
| list | 3 |
And has entity CacheBundle:SourceToSourceList
| source | 1 |
| list | 5 |
And has entity CacheBundle:SourceToSourceList
| source | 1 |
| list | 7 |
And has entity CacheBundle:SourceToSourceList
| source | 1 |
| list | 9 |
And has entity CacheBundle:SourceToSourceList
| source | 1 |
| list | 11 |
And has entity CacheBundle:SourceToSourceList
| source | 2 |
| list | 1 |
And has entity CacheBundle:SourceToSourceList
| source | 2 |
| list | 3 |
And has entity CacheBundle:SourceToSourceList
| source | 2 |
| list | 5 |
And has entity CacheBundle:SourceToSourceList
| source | 2 |
| list | 7 |
And has entity CacheBundle:SourceToSourceList
| source | 2 |
| list | 9 |
And has entity CacheBundle:SourceToSourceList
| source | 2 |
| list | 11 |
And I wait 1000 milliseconds
# Check index.
And source index has 2 documents
| _id | in | 1, 2 |
| list_ids | in | 1, 3, 5, 7, 9, 11 |
+120
View File
@@ -0,0 +1,120 @@
Feature: Get list of sources
As an authenticated user
I should be able to get list of sources
@db-fixtures @source-index-fixtures
Scenario:
I make empty request.
Given I authenticated as test@email.com with password test
And I make POST request to /api/v1/source-index/
"""
{
}
"""
Then I got successful response
And it's contains
"""
{
"sources": {
"data": "@array@",
"count": "@integer@",
"totalCount": "@integer@",
"page": 1,
"limit": 20
},
"filters": "@object@"
}
"""
@db-fixtures @source-index-fixtures
Scenario:
I search for source with 'CNN' in title or url.
Given I authenticated as test@email.com with password test
And I make POST request to /api/v1/source-index/
"""
{
"query": "CNN"
}
"""
Then I got successful response
And it's contains
"""
{
"sources": {
"data": "@array@
.every(field('title', contains('CNN')))
",
"count": "@integer@",
"totalCount": "@integer@",
"page": 1,
"limit": 20
},
"filters": "@object@"
}
"""
@db-fixtures @source-index-fixtures
Scenario Outline:
I should be able to get more or less source per page.
Given I authenticated as test@email.com with password test
And I make POST request to /api/v1/source-index/
"""
{
"limit": <limit>
}
"""
Then I got successful response
And it's contains
"""
{
"sources": {
"data": "@array@",
"count": "@integer@",
"totalCount": "@integer@",
"page": 1,
"limit": <limit>
},
"filters": "@object@"
}
"""
Examples:
| limit |
| 10 |
| 1 |
| 200 |
@db-fixtures @source-index-fixtures
Scenario Outline:
I should'nt be able change requested page.
Given I authenticated as test@email.com with password test
And I make POST request to /api/v1/source-index/
"""
{
"page": <page>
}
"""
Then I got successful response
And it's contains
"""
{
"sources": {
"data": "@array@",
"count": "@integer@",
"totalCount": "@integer@",
"page": <page>,
"limit": 20
},
"filters": "@object@"
}
"""
Examples:
| page |
| 2 |
| 3 |
| 20 |
@@ -0,0 +1,133 @@
Feature: Replace used lists for source
As an authenticated user
I should be able to replace used lists for specified source
@db-fixtures @source-index-fixtures
Scenario:
I replace lists for one of source.
Given I authenticated as test@email.com with password test
And I make POST request to /api/v1/source-index/1/list
"""
{
"sourceLists": [ 1, 3, 5, 7, 9, 11 ]
}
"""
Then I got response with code 204
# Check database.
And database has entity CacheBundle:SourceToSourceList
| source | 1 |
| list | 1 |
And has entity CacheBundle:SourceToSourceList
| source | 1 |
| list | 3 |
And has entity CacheBundle:SourceToSourceList
| source | 1 |
| list | 5 |
And has entity CacheBundle:SourceToSourceList
| source | 1 |
| list | 7 |
And has entity CacheBundle:SourceToSourceList
| source | 1 |
| list | 9 |
And has entity CacheBundle:SourceToSourceList
| source | 1 |
| list | 11 |
And I wait 1000 milliseconds
# Check index.
And source index has 1 documents
| _id | in | 1 |
| list_ids | in | 1, 3, 5, 7, 9, 11 |
@db-fixtures @source-index-fixtures
Scenario:
I replace lists for unknown source.
Given I authenticated as test@email.com with password test
And I make POST request to /api/v1/source-index/10000/list
"""
{
"sourceLists": [ 1, 3, 5, 7, 9, 11 ]
}
"""
Then I got response with code 404
And it's contains
"""
{
"errors": [
{
"message": "Can't find source with id 10000",
"transKey": "replaceSourceUnknown",
"type": "error",
"parameters": {
"current": "10000"
}
}
]
}
"""
@db-fixtures @source-index-fixtures
Scenario:
I make empty request.
Given I authenticated as test@email.com with password test
And I make POST request to /api/v1/source-index/1/list
"""
{
}
"""
Then I got response with code 400
And it's contains
"""
{
"errors": [
{
"message": "sourceLists: This value should not be empty.",
"transKey": "replaceSourceListsEmpty",
"type": "error",
"parameters": {
"current": null
}
}
]
}
"""
@db-fixtures @source-index-fixtures
Scenario Outline:
I replace lists for unknown or not owned lists.
Given I authenticated as test@email.com with password test
And I make POST request to /api/v1/source-index/1/list
"""
{
"sourceLists": [ <list_id> ]
}
"""
Then I got response with code 400
And it's contains
"""
{
"errors": [
{
"message": "sourceLists: This value is invalid.",
"transKey": "replaceSourceListInvalid",
"type": "error",
"parameters": {
"current": [ <list_id> ],
"invalid": [ <list_id> ]
}
}
]
}
"""
Examples:
| list_id |
| 1000 |
| 2 |