Skip to content
Snippets Groups Projects
Commit 2bd438d2 authored by Demian Katz's avatar Demian Katz Committed by Robert Lange
Browse files

Add basic deferred facet list test.

parent c1fc516c
Branches
Tags
No related merge requests found
...@@ -70,6 +70,36 @@ class SearchFacetsTest extends \VuFindTest\Unit\MinkTestCase ...@@ -70,6 +70,36 @@ class SearchFacetsTest extends \VuFindTest\Unit\MinkTestCase
return $session->getPage(); return $session->getPage();
} }
/**
* Helper function for simple facet application test
*
* @param \Behat\Mink\Element\Element $page Mink page object
*
* @return void
*/
protected function facetApplyProcedure($page)
{
// Confirm that we have 9 results and no filters to begin with:
$time = $this->findCss($page, '.search-query-time');
$stats = $this->findCss($page, '.search-stats');
$this->assertEquals("Showing 1 - 9 results of 9 for search 'building:weird_ids.mrc'" . $time->getText(), $stats->getText());
$items = $page->findAll('css', $this->activeFilterSelector);
$this->assertEquals(0, count($items));
// Facet to Fiction (after making sure we picked the right link):
$facetList = $this->findCss($page, '#side-collapse-genre_facet a[data-title="Fiction"]');
$this->assertEquals('Fiction 7', $facetList->getText());
$facetList->click();
$this->snooze();
// Check that when the page reloads, we have fewer results and a filter:
$time = $this->findCss($page, '.search-query-time');
$stats = $this->findCss($page, '.search-stats');
$this->assertEquals("Showing 1 - 7 results of 7 for search 'building:weird_ids.mrc'" . $time->getText(), $stats->getText());
$items = $page->findAll('css', $this->activeFilterSelector);
$this->assertEquals(1, count($items));
}
/** /**
* Helper function for facets lists * Helper function for facets lists
* *
...@@ -150,25 +180,38 @@ class SearchFacetsTest extends \VuFindTest\Unit\MinkTestCase ...@@ -150,25 +180,38 @@ class SearchFacetsTest extends \VuFindTest\Unit\MinkTestCase
{ {
$page = $this->performSearch('building:weird_ids.mrc'); $page = $this->performSearch('building:weird_ids.mrc');
// Confirm that we have 9 results and no filters to begin with: // Confirm that we are NOT using the AJAX sidebar:
$time = $this->findCss($page, '.search-query-time'); $ajaxContainer = $page->findAll('css', '.side-facets-container-ajax');
$stats = $this->findCss($page, '.search-stats'); $this->assertEquals(0, count($ajaxContainer));
$this->assertEquals("Showing 1 - 9 results of 9 for search 'building:weird_ids.mrc'" . $time->getText(), $stats->getText());
$items = $page->findAll('css', $this->activeFilterSelector);
$this->assertEquals(0, count($items));
// Facet to Fiction (after making sure we picked the right link): // Now run the body of the test procedure:
$facetList = $this->findCss($page, '#side-collapse-genre_facet a[data-title="Fiction"]'); $this->facetApplyProcedure($page);
$this->assertEquals('Fiction 7', $facetList->getText()); }
$facetList->click();
$this->snooze();
// Check that when the page reloads, we have fewer results and a filter: /**
$time = $this->findCss($page, '.search-query-time'); * Test applying a facet to filter results (deferred facet sidebar)
$stats = $this->findCss($page, '.search-stats'); *
$this->assertEquals("Showing 1 - 7 results of 7 for search 'building:weird_ids.mrc'" . $time->getText(), $stats->getText()); * @return void
$items = $page->findAll('css', $this->activeFilterSelector); */
$this->assertEquals(1, count($items)); public function testApplyFacetDeferred()
{
$this->changeConfigs(
[
'searches' => [
'General' => [
'default_side_recommend[]' => 'SideFacetsDeferred:Results:CheckboxFacets',
]
]
]
);
$page = $this->performSearch('building:weird_ids.mrc');
// Confirm that we ARE using the AJAX sidebar:
$ajaxContainer = $page->findAll('css', '.side-facets-container-ajax');
$this->assertEquals(1, count($ajaxContainer));
// Now run the body of the test procedure:
$this->facetApplyProcedure($page);
} }
/** /**
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment