From 0a70267201bd90fd7014dd94200f7e66737c5a3e Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Mon, 13 Jun 2016 13:21:13 -0400 Subject: [PATCH] Add new test for exclude facets + lightbox. --- .../src/VuFindTest/Mink/SearchActionsTest.php | 64 +++++++++++++++++-- 1 file changed, 59 insertions(+), 5 deletions(-) diff --git a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/SearchActionsTest.php b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/SearchActionsTest.php index 9b499c02bbd..28f790b84a0 100644 --- a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/SearchActionsTest.php +++ b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/SearchActionsTest.php @@ -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. * -- GitLab