mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-08-29 21:52:35 +00:00
![Dan Brown](/assets/img/avatar_default.png)
Added search result pages for pages, chapters and books. Limited the results on the global search as it just listed out an infinate amount. Fixed styling on new detailed page listings and also removed the 'bars' from the side to create a cleaner view. Fixed bad sql fulltext query format that may have thrown off searches. Reduced the number of database queries down a thousand or so.
86 lines
2.4 KiB
PHP
86 lines
2.4 KiB
PHP
<?php
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class EntitySearchTest extends TestCase
|
|
{
|
|
|
|
public function test_page_search()
|
|
{
|
|
$book = \BookStack\Book::all()->first();
|
|
$page = $book->pages->first();
|
|
|
|
$this->asAdmin()
|
|
->visit('/')
|
|
->type($page->name, 'term')
|
|
->press('header-search-box-button')
|
|
->see('Search Results')
|
|
->see($page->name)
|
|
->click($page->name)
|
|
->seePageIs($page->getUrl());
|
|
}
|
|
|
|
public function test_invalid_page_search()
|
|
{
|
|
$this->asAdmin()
|
|
->visit('/')
|
|
->type('<p>test</p>', 'term')
|
|
->press('header-search-box-button')
|
|
->see('Search Results')
|
|
->seeStatusCode(200);
|
|
}
|
|
|
|
public function test_empty_search_redirects_back()
|
|
{
|
|
$this->asAdmin()
|
|
->visit('/')
|
|
->visit('/search/all')
|
|
->seePageIs('/');
|
|
}
|
|
|
|
public function test_book_search()
|
|
{
|
|
$book = \BookStack\Book::all()->first();
|
|
$page = $book->pages->last();
|
|
$chapter = $book->chapters->last();
|
|
|
|
$this->asAdmin()
|
|
->visit('/search/book/' . $book->id . '?term=' . urlencode($page->name))
|
|
->see($page->name)
|
|
|
|
->visit('/search/book/' . $book->id . '?term=' . urlencode($chapter->name))
|
|
->see($chapter->name);
|
|
}
|
|
|
|
public function test_empty_book_search_redirects_back()
|
|
{
|
|
$book = \BookStack\Book::all()->first();
|
|
$this->asAdmin()
|
|
->visit('/books')
|
|
->visit('/search/book/' . $book->id . '?term=')
|
|
->seePageIs('/books');
|
|
}
|
|
|
|
|
|
public function test_pages_search_listing()
|
|
{
|
|
$page = \BookStack\Page::all()->last();
|
|
$this->asAdmin()->visit('/search/pages?term=' . $page->name)
|
|
->see('Page Search Results')->see('.entity-list', $page->name);
|
|
}
|
|
|
|
public function test_chapters_search_listing()
|
|
{
|
|
$chapter = \BookStack\Chapter::all()->last();
|
|
$this->asAdmin()->visit('/search/chapters?term=' . $chapter->name)
|
|
->see('Chapter Search Results')->seeInElement('.entity-list', $chapter->name);
|
|
}
|
|
|
|
public function test_books_search_listing()
|
|
{
|
|
$book = \BookStack\Book::all()->last();
|
|
$this->asAdmin()->visit('/search/books?term=' . $book->name)
|
|
->see('Book Search Results')->see('.entity-list', $book->name);
|
|
}
|
|
}
|