mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-30 07:32:39 +01:00
Added testing to cover search result highlighting
This commit is contained in:
parent
339518e2a6
commit
63d8d72d7e
@ -383,4 +383,32 @@ class EntitySearchTest extends TestCase
|
||||
$this->assertEquals(3, $scoreByTerm->get('Animal'));
|
||||
$this->assertEquals(3, $scoreByTerm->get('SuperImportant'));
|
||||
}
|
||||
|
||||
public function test_matching_terms_in_search_results_are_highlighted()
|
||||
{
|
||||
$this->newPage(['name' => 'My Meowie Cat', 'html' => '<p>A superimportant page about meowieable animals</p>', 'tags' => [
|
||||
['name' => 'Animal', 'value' => 'MeowieCat'],
|
||||
['name' => 'SuperImportant'],
|
||||
]]);
|
||||
|
||||
$search = $this->asEditor()->get('/search?term=SuperImportant+Meowie');
|
||||
// Title
|
||||
$search->assertSee('My <strong>Meowie</strong> Cat', false);
|
||||
// Content
|
||||
$search->assertSee('A <strong>superimportant</strong> page about <strong>meowie</strong>able animals', false);
|
||||
// Tag name
|
||||
$search->assertElementContains('.tag-name.highlight', 'SuperImportant');
|
||||
// Tag value
|
||||
$search->assertElementContains('.tag-value.highlight', 'MeowieCat');
|
||||
}
|
||||
|
||||
public function test_html_entities_in_item_details_remains_escaped_in_search_results()
|
||||
{
|
||||
$this->newPage(['name' => 'My <cool> TestPageContent', 'html' => '<p>My supercool <great> TestPageContent page</p>']);
|
||||
|
||||
$search = $this->asEditor()->get('/search?term=TestPageContent');
|
||||
$search->assertSee('My <cool> <strong>TestPageContent</strong>', false);
|
||||
$search->assertSee('My supercool <great> <strong>TestPageContent</strong> page', false);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user