Skip to content
Snippets Groups Projects
Commit 0a702672 authored by Demian Katz's avatar Demian Katz
Browse files

Add new test for exclude facets + lightbox.

parent cea5e8fa
No related merge requests found
......@@ -203,21 +203,41 @@ class SearchActionsTest extends \VuFindTest\Unit\MinkTestCase
/**
* Helper function for facets lists
*
* @param \Behat\Mink\Element\Element $page Mink page object
* @param integer $limit Configured lightbox length
* @param \Behat\Mink\Element\Element $page Mink page object
* @param int $limit Configured lightbox length
* @param bool $exclusionActive Is facet exclusion on?
*
* @return void
*/
protected function facetListProcedure($page, $limit)
protected function facetListProcedure($page, $limit, $exclusionActive = false)
{
$this->snooze();
$items = $page->findAll('css', '#modal #facet-list-count .js-facet-item');
$this->assertEquals($limit, count($items));
$excludes = $page
->findAll('css', '#modal #facet-list-count .badge .fa-times');
$this->assertEquals($exclusionActive ? $limit : 0, count($excludes));
// more
$this->findCss($page, '#modal .js-facet-next-page')->click();
$this->snooze();
$items = $page->findAll('css', '#modal #facet-list-count .js-facet-item');
$this->assertEquals($limit * 2, count($items));
$this->assertEquals(
'Weird IDs 9 '
. 'Fiction 7 '
. 'The Study Of P|pes 1 '
. 'The Study and Scor_ng of Dots.and-Dashes:Colons 1 '
. 'The Study of "Important" Things 1 '
. 'The Study of %\'s? 1 '
. 'The Study of +\'s? 1 '
. 'The Study of @Twitter #test 1 '
. 'more ...',
$this->findCss($page, '#modal #facet-list-count')->getText()
);
$excludes = $page
->findAll('css', '#modal #facet-list-count .badge .fa-times');
$this->assertEquals($exclusionActive ? $limit * 2 : 0, count($excludes));
// sort by title
$this->findCss($page, '[data-sort="index"]')->click();
$this->snooze();
......@@ -231,13 +251,20 @@ class SearchActionsTest extends \VuFindTest\Unit\MinkTestCase
. 'more ...',
$this->findCss($page, '#modal #facet-list-index')->getText()
);
$excludes = $page
->findAll('css', '#modal #facet-list-index .badge .fa-times');
$this->assertEquals($exclusionActive ? $limit : 0, count($excludes));
// sort by index again
$this->findCss($page, '[data-sort="count"]')->click();
$this->snooze();
$items = $page->findAll('css', '#modal #facet-list-count .js-facet-item');
$this->assertEquals($limit * 2, count($items)); // maintain number of items
$weirdIDs = $this->findAndAssertLink($page, 'Weird IDs 9');
$this->assertEquals('Weird IDs 9', $weirdIDs->getText());
// When exclusion is active, the result count is outside of the link tag:
$expectedLinkText = $exclusionActive ? 'Weird IDs' : 'Weird IDs 9';
$weirdIDs = $this->findAndAssertLink(
$page->findById('modal'), $expectedLinkText
);
$this->assertEquals($expectedLinkText, $weirdIDs->getText());
// apply US facet
$weirdIDs->click();
$this->snooze();
......@@ -305,6 +332,33 @@ class SearchActionsTest extends \VuFindTest\Unit\MinkTestCase
$this->assertNull($page->find('css', '.list-group.filters'));
}
/**
* Test that exclusion works properly deep in lightbox results.
*
* @return void
*/
public function testFacetLightboxExclusion()
{
$limit = 4;
$this->changeConfigs(
[
'facets' => [
'Results_Settings' => [
'showMoreInLightbox[*]' => true,
'lightboxLimit' => $limit,
'exclude' => '*',
]
]
]
);
$page = $this->performSearch('building:weird_ids.mrc');
// Open the geographic facet
$genreMore = $this->findCss($page, '#more-narrowGroupHidden-genre_facet');
$genreMore->click();
$this->facetListProcedure($page, $limit, true);
$this->assertEquals(1, count($page->find('css', '.list-group.filters')));
}
/**
* Standard teardown method.
*
......
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