Skip to content

Commit

Permalink
Fix tests.
Browse files Browse the repository at this point in the history
Co-authored by: Chris Hallberg <[email protected]>
  • Loading branch information
EreMaijala committed Aug 23, 2023
1 parent d735c6c commit 4a0d57b
Showing 1 changed file with 58 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* PHP version 8
*
* Copyright (C) Villanova University 2011.
* Copyright (C) The National Library of Finland 2023.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
Expand All @@ -23,6 +24,7 @@
* @category VuFind
* @package Tests
* @author Demian Katz <[email protected]>
* @author Ere Maijala <[email protected]>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org Main Page
*/
Expand All @@ -35,19 +37,62 @@
* @category VuFind
* @package Tests
* @author Demian Katz <[email protected]>
* @author Ere Maijala <[email protected]>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org Main Page
* @retry 4
*/
class SearchFacetsTest extends \VuFindTest\Integration\MinkTestCase
{
/**
* CSS selector for finding active filters
* CSS selector for finding the active filter values
*
* @var string
*/
protected $activeFilterSelector = '.active-filters.hidden-xs .filters .filter-value';

/**
* CSS selector for finding the active filter labels
*
* @var string
*/
protected $activeFilterLabelSelector = '.active-filters.hidden-xs .filters .filters-title';

/**
* CSS selector for finding the first collapsed hierarchical facet
*
* @var string
*/
protected $facetExpandSelector = '.facet-tree .facet-tree__icon-container .facet-tree__closed';

/**
* CSS selector for finding the first expanded hierarchical facet
*
* @var string
*/
protected $facetExpandedSelector = '.facet-tree details[open]';

/**
* CSS selector for finding the first second level hierarchical facet
*
* @var string
*/
protected $facetSecondLevelLinkSelector = '.facet-tree details[open] ul a';

/**
* CSS selector for finding the first active second level hierarchical facet
*
* @var string
*/
protected $facetSecondLevelActiveLinkSelector = '.facet-tree details[open] ul a.active';

/**
* CSS selector for finding the first second level hierarchical facet
*
* @var string
*/
protected $facetSecondLevelExcludeLinkSelector = '.facet-tree details[open] ul a.exclude';

/**
* Get filtered search
*
Expand Down Expand Up @@ -305,14 +350,19 @@ public function testFacetLightboxExclusion()
*/
protected function clickHierarchyFacet($page)
{
$this->clickCss($page, '#j1_1.jstree-closed .jstree-icon');
$this->findCss($page, '#j1_1.jstree-open .jstree-icon');
$this->clickCss($page, '#j1_2 a');
// Open second level:
$this->clickCss($page, $this->facetExpandSelector);
// Check results:
$this->findCss($page, $this->facetExpandedSelector);
// Click second level facet:
$this->clickCss($page, $this->facetSecondLevelLinkSelector);
// Check the active filter:
$filter = $this->findCss($page, $this->activeFilterSelector);
$label = $this->findCss($page, '.filters .filters-title');
$label = $this->findCss($page, $this->activeFilterLabelSelector);
$this->assertEquals('hierarchy:', $label->getText());
$this->assertEquals('Remove Filter level1a/level2a', $filter->getText());
$this->findCss($page, '#j1_2 .applied');
// Check that the applied facet is displayed properly:
$this->findCss($page, $this->facetSecondLevelActiveLinkSelector);
}

/**
Expand Down Expand Up @@ -370,9 +420,8 @@ public function testHierarchicalFacetExclude()
'Showing 1 - 10 results of 10 for search \'building:"hierarchy.mrc"\'',
$extractCount($stats->getText())
);
$this->clickCss($page, '#j1_1.jstree-closed .jstree-icon');
$this->findCss($page, '#j1_1.jstree-open .jstree-icon');
$this->clickCss($page, '#j1_2 a.exclude');
$this->clickCss($page, $this->facetExpandSelector);
$this->clickCss($page, $this->facetSecondLevelExcludeLinkSelector);
$filter = $this->findCss($page, $this->activeFilterSelector);
$label = $this->findCss($page, '.filters .filters-title');
$this->assertEquals('hierarchy:', $label->getText());
Expand Down

0 comments on commit 4a0d57b

Please sign in to comment.