X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/6f1bdbf771b00be12db676e6289830d8cdc7ecda..refs/pull/3333/head:/tests/Api/SearchApiTest.php
diff --git a/tests/Api/SearchApiTest.php b/tests/Api/SearchApiTest.php
index 55ca0e009..1f38c7fd9 100644
--- a/tests/Api/SearchApiTest.php
+++ b/tests/Api/SearchApiTest.php
@@ -36,6 +36,38 @@ class SearchApiTest extends TestCase
$resp->assertJsonFragment(['name' => $uniqueTerm, 'type' => 'bookshelf']);
}
+ public function test_all_endpoint_returns_entity_url()
+ {
+ /** @var Page $page */
+ $page = Page::query()->first();
+ $page->update(['name' => 'name with superuniquevalue within']);
+ $page->indexForSearch();
+
+ $resp = $this->actingAsApiAdmin()->getJson($this->baseEndpoint . '?query=superuniquevalue');
+ $resp->assertJsonFragment([
+ 'type' => 'page',
+ 'url' => $page->getUrl(),
+ ]);
+ }
+
+ public function test_all_endpoint_returns_items_with_preview_html()
+ {
+ /** @var Book $book */
+ $book = Book::query()->first();
+ $book->update(['name' => 'name with superuniquevalue within', 'description' => 'Description with superuniquevalue within']);
+ $book->indexForSearch();
+
+ $resp = $this->actingAsApiAdmin()->getJson($this->baseEndpoint . '?query=superuniquevalue');
+ $resp->assertJsonFragment([
+ 'type' => 'book',
+ 'url' => $book->getUrl(),
+ 'preview_html' => [
+ 'name' => 'name with superuniquevalue within',
+ 'content' => 'Description with superuniquevalue within',
+ ],
+ ]);
+ }
+
public function test_all_endpoint_requires_query_parameter()
{
$resp = $this->actingAsApiEditor()->get($this->baseEndpoint);