X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/bc4978479715f11f8413103f870ee9745109c6be..refs/pull/234/head:/tests/Entity/EntitySearchTest.php diff --git a/tests/Entity/EntitySearchTest.php b/tests/Entity/EntitySearchTest.php index a9d9bc047..3f60f9c36 100644 --- a/tests/Entity/EntitySearchTest.php +++ b/tests/Entity/EntitySearchTest.php @@ -15,8 +15,8 @@ class EntitySearchTest extends TestCase ->type($page->name, 'term') ->press('header-search-box-button') ->see('Search Results') - ->see($page->name) - ->click($page->name) + ->seeInElement('.entity-list', $page->name) + ->clickInElement('.entity-list', $page->name) ->seePageIs($page->getUrl()); } @@ -76,6 +76,14 @@ class EntitySearchTest extends TestCase ->see('Chapter Search Results')->seeInElement('.entity-list', $chapter->name); } + public function test_search_quote_term_preparation() + { + $termString = '"192" cat "dog hat"'; + $repo = $this->app[\BookStack\Repos\EntityRepo::class]; + $preparedTerms = $repo->prepareSearchTerms($termString); + $this->assertTrue($preparedTerms === ['"192"','"dog hat"', 'cat']); + } + public function test_books_search_listing() { $book = \BookStack\Book::all()->last(); @@ -83,6 +91,45 @@ class EntitySearchTest extends TestCase ->see('Book Search Results')->see('.entity-list', $book->name); } + public function test_searching_hypen_doesnt_break() + { + $this->visit('/search/all?term=cat+-') + ->seeStatusCode(200); + } + + public function test_tag_search() + { + $newTags = [ + new \BookStack\Tag([ + 'name' => 'animal', + 'value' => 'cat' + ]), + new \BookStack\Tag([ + 'name' => 'color', + 'value' => 'red' + ]) + ]; + + $pageA = \BookStack\Page::first(); + $pageA->tags()->saveMany($newTags); + + $pageB = \BookStack\Page::all()->last(); + $pageB->tags()->create(['name' => 'animal', 'value' => 'dog']); + + $this->asAdmin()->visit('/search/all?term=%5Banimal%5D') + ->seeLink($pageA->name) + ->seeLink($pageB->name); + + $this->visit('/search/all?term=%5Bcolor%5D') + ->seeLink($pageA->name) + ->dontSeeLink($pageB->name); + + $this->visit('/search/all?term=%5Banimal%3Dcat%5D') + ->seeLink($pageA->name) + ->dontSeeLink($pageB->name); + + } + public function test_ajax_entity_search() { $page = \BookStack\Page::all()->last();