Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • project/facets
  • issue/facets-3182762
  • issue/facets-2937191
  • issue/facets-3073444
  • issue/facets-3187388
  • issue/facets-3189343
  • issue/facets-3190076
  • issue/facets-3190111
  • issue/facets-3190240
  • issue/facets-3057943
  • issue/facets-3153889
  • issue/facets-3015387
  • issue/facets-3197615
  • issue/facets-3199135
  • issue/facets-3199156
  • issue/facets-3200659
  • issue/facets-3204072
  • issue/facets-3205381
  • issue/facets-3162984
  • issue/facets-3208580
  • issue/facets-3211155
  • issue/facets-3168241
  • issue/facets-3058314
  • issue/facets-3214662
  • issue/facets-3212932
  • issue/facets-2979223
  • issue/facets-3213733
  • issue/facets-3216756
  • issue/facets-3221545
  • issue/facets-3223956
  • issue/facets-3052574
  • issue/facets-3173865
  • issue/facets-3231934
  • issue/facets-3226284
  • issue/facets-3100620
  • issue/facets-3283166
  • issue/facets-3281408
  • issue/facets-3225189
  • issue/facets-3153622
  • issue/facets-3186953
  • issue/facets-3248297
  • issue/facets-3220140
  • issue/facets-3252806
  • issue/facets-3046872
  • issue/facets-3254732
  • issue/facets-3255454
  • issue/facets-3255596
  • issue/facets-3256305
  • issue/facets-3256222
  • issue/facets-3257441
  • issue/facets-3257445
  • issue/facets-3173972
  • issue/facets-3259958
  • issue/facets-3261140
  • issue/facets-3262863
  • issue/facets-3264045
  • issue/facets-3264196
  • issue/facets-3264284
  • issue/facets-3265768
  • issue/facets-2939710
  • issue/facets-3031544
  • issue/facets-3266265
  • issue/facets-3047910
  • issue/facets-2908937
  • issue/facets-3270514
  • issue/facets-3008061
  • issue/facets-3272851
  • issue/facets-2993101
  • issue/facets-3273431
  • issue/facets-3190289
  • issue/facets-2937619
  • issue/facets-3285728
  • issue/facets-3106111
  • issue/facets-3291943
  • issue/facets-3260603
  • issue/facets-3293266
  • issue/facets-3294991
  • issue/facets-3296120
  • issue/facets-2873480
  • issue/facets-3298956
  • issue/facets-3299603
  • issue/facets-3111903
  • issue/facets-3300227
  • issue/facets-3303927
  • issue/facets-3116236
  • issue/facets-3297168
  • issue/facets-3301075
  • issue/facets-3295536
  • issue/facets-3303305
  • issue/facets-3305120
  • issue/facets-2837729
  • issue/facets-3310812
  • issue/facets-3310894
  • issue/facets-3306634
  • issue/facets-3307082
  • issue/facets-3307968
  • issue/facets-3308371
  • issue/facets-3309309
  • issue/facets-3310848
  • issue/facets-3310857
  • issue/facets-3311242
  • issue/facets-3311500
  • issue/facets-3311856
  • issue/facets-3251920
  • issue/facets-3317585
  • issue/facets-3317783
  • issue/facets-2978248
  • issue/facets-3314702
  • issue/facets-3318667
  • issue/facets-3326080
  • issue/facets-3326809
  • issue/facets-3327596
  • issue/facets-3320629
  • issue/facets-3327246
  • issue/facets-3327613
  • issue/facets-3327629
  • issue/facets-3172373
  • issue/facets-3327604
  • issue/facets-3327592
  • issue/facets-3323372
  • issue/facets-3336646
  • issue/facets-3343860
  • issue/facets-3331219
  • issue/facets-3260155
  • issue/facets-3206427
  • issue/facets-3342656
  • issue/facets-3349266
  • issue/facets-3352687
  • issue/facets-3355614
  • issue/facets-3318636
  • issue/facets-3332128
  • issue/facets-3356573
  • issue/facets-2986981
  • issue/facets-2984641
  • issue/facets-3350613
  • issue/facets-3360010
  • issue/facets-3360426
  • issue/facets-3365579
  • issue/facets-3367124
  • issue/facets-3368253
  • issue/facets-3368327
  • issue/facets-3133309
  • issue/facets-3360920
  • issue/facets-3395766
  • issue/facets-3402720
  • issue/facets-3404340
  • issue/facets-3211200
  • issue/facets-3374554
  • issue/facets-3385696
  • issue/facets-2997417
  • issue/facets-3387254
  • issue/facets-3386518
  • issue/facets-3117495
  • issue/facets-3390004
  • issue/facets-3387250
  • issue/facets-3390365
  • issue/facets-3391052
  • issue/facets-3391322
  • issue/facets-3391614
  • issue/facets-3394866
  • issue/facets-3214153
  • issue/facets-3408085
  • issue/facets-3395567
  • issue/facets-3313850
  • issue/facets-3410049
  • issue/facets-3420142
  • issue/facets-3373338
  • issue/facets-3412573
  • issue/facets-3413405
  • issue/facets-3414606
  • issue/facets-3415552
  • issue/facets-3416017
  • issue/facets-3415900
  • issue/facets-3258992
  • issue/facets-3408001
  • issue/facets-3254496
  • issue/facets-3254497
  • issue/facets-3421560
  • issue/facets-3422013
  • issue/facets-3419501
  • issue/facets-3364560
  • issue/facets-3423195
  • issue/facets-3276669
  • issue/facets-3425883
  • issue/facets-3426667
  • issue/facets-3426673
  • issue/facets-3426675
  • issue/facets-3427300
  • issue/facets-3427383
  • issue/facets-3112463
  • issue/facets-3428646
  • issue/facets-3446053
  • issue/facets-3444352
  • issue/facets-3436160
  • issue/facets-3440551
  • issue/facets-3430401
  • issue/facets-3285575
  • issue/facets-3446781
  • issue/facets-3436010
  • issue/facets-3326234
  • issue/facets-3365166
  • issue/facets-3431226
  • issue/facets-3437814
  • issue/facets-3446211
  • issue/facets-3432718
  • issue/facets-3390386
  • issue/facets-3438980
  • issue/facets-3259123
  • issue/facets-3447859
  • issue/facets-3447884
  • issue/facets-3449029
  • issue/facets-3449596
  • issue/facets-3451106
  • issue/facets-3451557
  • issue/facets-3452863
  • issue/facets-3008561
  • issue/facets-3406085
  • issue/facets-3283106
  • issue/facets-3455217
  • issue/facets-3195236
  • issue/facets-3458558
  • issue/facets-3459093
  • issue/facets-3460346
  • issue/facets-3462302
  • issue/facets-3259836
  • issue/facets-3463418
  • issue/facets-3459885
  • issue/facets-3008615
  • issue/facets-3466566
  • issue/facets-2811331
  • issue/facets-3467119
  • issue/facets-3467173
  • issue/facets-3469997
  • issue/facets-2950054
  • issue/facets-3092320
  • issue/facets-3473690
  • issue/facets-3386783
  • issue/facets-3469754
  • issue/facets-3477332
  • issue/facets-3477929
  • issue/facets-3479103
  • issue/facets-3049100
  • issue/facets-3480277
  • issue/facets-3282290
  • issue/facets-3481448
  • issue/facets-3482015
  • issue/facets-3482326
  • issue/facets-3095160
  • issue/facets-3495860
  • issue/facets-3484320
  • issue/facets-3484946
  • issue/facets-3485860
  • issue/facets-3487006
  • issue/facets-3487270
  • issue/facets-3488396
  • issue/facets-3488547
  • issue/facets-3489712
  • issue/facets-3490006
  • issue/facets-3490556
  • issue/facets-3492078
  • issue/facets-3492924
  • issue/facets-3492410
  • issue/facets-3495743
  • issue/facets-3497166
  • issue/facets-3252416
  • issue/facets-3499673
  • issue/facets-3501351
  • issue/facets-3501981
  • issue/facets-3195462
  • issue/facets-3161773
  • issue/facets-3502922
  • issue/facets-3502957
  • issue/facets-3503603
273 results
Show changes
Commits on Source (3)
Showing
with 61 additions and 257 deletions
......@@ -7,7 +7,6 @@
use Drupal\facets\Entity\Facet;
use Drupal\facets\Entity\FacetSource;
use Drupal\block\Entity\Block;
use Drupal\facets\Plugin\facets\facet_source\SearchApiDisplay;
/**
......
......@@ -204,7 +204,7 @@ function facets_entity_predelete(EntityInterface $entity) {
* @see https://www.drupal.org/node/1842756
*/
function facets_preprocess_facets_item_list(array &$variables) {
/** @var FacetInterface $facet */
/** @var \Drupal\facets\Entity\FacetInterface $facet */
$facet = $variables['facet'];
if ($facet !== NULL) {
if ($facet->get('show_title') === TRUE) {
......@@ -335,7 +335,7 @@ function facets_system_breadcrumb_alter(Breadcrumb &$breadcrumb, RouteMatchInter
}
else {
$crumb_text = implode(', ', $facet_crumb_items);
};
}
$link = Link::fromTextAndUrl($crumb_text, $facet_url);
$breadcrumb->addLink($link);
}
......
......@@ -14,7 +14,7 @@ display:
type: none
options: { }
cache:
type: none
type: search_api_none
options: { }
query:
type: search_api_query
......@@ -57,11 +57,9 @@ display:
type: search_api
options:
view_modes:
bundle:
'entity:entity_test':
'article': default
'page': default
datasource:
'entity:entity_test': default
fields:
search_api_id:
table: search_api_index_database_search_index
......
<?php
namespace Drupal\facets_searchbox_widget\tests\FunctionalJavascript;
declare(strict_types=1);
namespace Drupal\Tests\facets_searchbox_widget\FunctionalJavascript;
use Drupal\Tests\facets\FunctionalJavascript\WidgetJSTest;
......
<?php
namespace Drupal\facets_searchbox_widget\tests\Unit\Plugin\widget;
namespace Drupal\Tests\facets_searchbox_widget\Unit\Plugin\widget;
use Drupal\facets\Plugin\facets\widget\CheckboxWidget;
use Drupal\Tests\facets\Unit\Plugin\widget\CheckboxWidgetTest;
......
<?php
namespace Drupal\facets_searchbox_widget\tests\Unit\Plugin\widget;
namespace Drupal\Tests\facets_searchbox_widget\Unit\Plugin\widget;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\facets\Entity\Facet;
use Drupal\facets\FacetSource\FacetSourcePluginManager;
use Drupal\facets\Plugin\facets\widget\LinksWidget;
use Drupal\facets\Result\Result;
use Drupal\facets\UrlProcessor\UrlProcessorInterface;
use Drupal\facets\UrlProcessor\UrlProcessorPluginManager;
......@@ -259,13 +258,15 @@ class SearchboxLinksWidgetTest extends LinksWidgetTest {
$url_processor = $this->createMock(UrlProcessorInterface::class);
$manager = $this->createMock(FacetSourcePluginManager::class);
$manager->expects($this->exactly(1))
$manager->expects($this->atLeastOnce())
->method('createInstance')
->willReturn($url_processor);
$facets_url_generator = $this->createMock(FacetsUrlGenerator::class);
$storage = $this->createMock(EntityStorageInterface::class);
$em = $this->createMock(EntityTypeManagerInterface::class);
$em->expects($this->exactly(1))
$em->expects($this->atLeastOnce())
->method('getStorage')
->willReturn($storage);
......@@ -273,6 +274,7 @@ class SearchboxLinksWidgetTest extends LinksWidgetTest {
$container->set('router.no_access_checks', $router);
$container->set('entity_type.manager', $em);
$container->set('plugin.manager.facets.url_processor', $manager);
$container->set('facets.utility.url_generator', $facets_url_generator);
\Drupal::setContainer($container);
}
......
......@@ -775,12 +775,12 @@ class Facet extends ConfigEntityBase implements FacetInterface {
$storage = \Drupal::entityTypeManager()->getStorage('facets_facet_source');
if ($source_id = str_replace(':', '__', $this->facet_source_id ?? '')) {
// Load and return the facet source config object from the storage.
$facet_source = $storage->load($source_id);
if ($facet_source instanceof FacetSource) {
$this->facetSourceConfig = $facet_source;
return $this->facetSourceConfig;
}
// Load and return the facet source config object from the storage.
$facet_source = $storage->load($source_id);
if ($facet_source instanceof FacetSource) {
$this->facetSourceConfig = $facet_source;
return $this->facetSourceConfig;
}
}
// We didn't have a facet source config entity yet for this facet source
......
......@@ -2,7 +2,6 @@
namespace Drupal\facets\Event;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\facets\FacetInterface;
use Drupal\Component\EventDispatcher\Event;
......
......@@ -358,6 +358,13 @@ class FacetListBuilder extends DraggableListBuilder {
$facet_source_groups = [];
foreach ($facet_sources as $facet_source) {
// For now, we hide the facet sources for views display default.
// They should not be used to attach block facets.
if (substr($facet_source["display_id"], 0, 14) == 'views_default:') {
continue;
}
$facet_source_groups[$facet_source['id']] = [
'facet_source' => $facet_source,
'facets' => [],
......
......@@ -808,7 +808,7 @@ class FacetForm extends EntityForm {
$facet->setHardLimit($form_state->getValue(['facet_settings', 'hard_limit']));
$facet->setExclude($form_state->getValue(['facet_settings', 'exclude']));
$facet_uses_hierarchy = $form_state->getValue(
[
'facet_settings',
......
......@@ -113,6 +113,11 @@ class FacetSettingsForm extends EntityForm {
$facet_sources = [];
foreach ($this->facetSourcePluginManager->getDefinitions() as $facet_source_id => $definition) {
// For now, we hide the facet sources for views display default.
// They should not be used to attach block facets.
if (substr($definition["display_id"], 0, 14) == 'views_default:') {
continue;
}
$facet_sources[$definition['id']] = !empty($definition['label']) ? $definition['label'] : $facet_source_id;
}
......@@ -313,7 +318,7 @@ class FacetSettingsForm extends EntityForm {
$facet->setOnlyVisibleWhenFacetSourceIsVisible(FALSE);
}
$views_cache_type = $view->display_handler->getOption('cache')['type'];
if ($views_cache_type !== 'none') {
if ($views_cache_type !== 'search_api_none') {
$this->messenger()->addMessage($this->t('You may experience issues, because %view use cache. In case you will try to turn set cache plugin to none.', ['%view' => $view->storage->label()]));
}
}
......
......@@ -189,9 +189,8 @@ class FacetBlock extends BlockBase implements ContainerFactoryPluginInterface {
}
/**
* {@inheritDoc}
* Allow to render facet block if one of the following conditions are met.
*
* Allow to render facet block if one of the following conditions are met:
* - facet is allowed to be displayed regardless of the source visibility
* - facet source is rendered in the same request as facet.
*/
......
......@@ -531,7 +531,7 @@ class SearchApiDisplay extends FacetSourcePluginBase implements SearchApiFacetSo
}
/**
* {@inheritDoc}
* Register a facet.
*
* Alter views view cache metadata:
* - When view being re-saved it will collect all cache metadata from its
......@@ -571,6 +571,7 @@ class SearchApiDisplay extends FacetSourcePluginBase implements SearchApiFacetSo
* Set the state, that the display is currently edited and saved.
*
* @param bool $display_edit_in_progress
* True if the display being edited.
*/
public function setDisplayEditInProgress(bool $display_edit_in_progress): void {
$this->display_edit_in_progress = $display_edit_in_progress;
......
......@@ -89,7 +89,7 @@ class QueryString extends UrlProcessorPluginBase {
// When adding/removing a filter the number of pages may have changed,
// possibly resulting in an invalid page parameter.
if ($get_params->has('page')) {
$current_page = $get_params->get('page');
$current_page = $get_params->all()['page'];
$get_params->remove('page');
}
......
......@@ -139,7 +139,8 @@ class FacetsUrlGenerator {
// request path not having a matching route, Url generator will fail with.
try {
$requestUrl = Url::createFromRequest($request);
} catch (ResourceNotFoundException $e) {
}
catch (ResourceNotFoundException $e) {
// Bypass exception if no path available. Should be unreachable in
// default FacetSource implementations, but you never know.
if ($facet_source_path) {
......
......@@ -7,7 +7,6 @@ use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Link;
use Drupal\Core\Plugin\PluginBase;
use Drupal\Core\Url;
use Drupal\facets\FacetInterface;
use Drupal\facets\Result\Result;
use Drupal\facets\Result\ResultInterface;
......
......@@ -113,7 +113,7 @@ display:
type: none
options: { }
cache:
type: none
type: search_api_none
options: { }
empty: { }
sorts:
......@@ -307,11 +307,9 @@ display:
type: search_api
options:
view_modes:
bundle:
'entity:entity_test':
article: default
page: default
datasource:
'entity:entity_test': default
query:
type: search_api_query
options:
......
......@@ -890,7 +890,13 @@ class IntegrationTest extends FacetsTestBase {
$this->drupalGet('admin/config/search/facets/' . $id . '/settings');
$this->submitForm([], 'Save');
$warning = 'You may experience issues, because Search API Test Fulltext search view use cache. In case you will try to turn set cache plugin to none.';
$this->assertSession()->pageTextContains($warning);
if ($display_id === 'page_1') {
$this->assertSession()->pageTextNotContains($warning);
}
else {
// Make sure that user will get a warning about source cache plugin.
$this->assertSession()->pageTextContains($warning);
}
// Check the view's cache settings again to see if they've been updated.
$view = Views::getView('search_api_test_view');
$view->setDisplay($display_id);
......
......@@ -250,7 +250,10 @@ class WidgetIntegrationTest extends FacetsTestBase {
}
/**
* Tests that, when there are multiple facets, the "Show all" link's `is-active` CSS class doesn't leak into subsequent inactive facet links.
* Tests multiple reset links.
*
* Tests that, when there are multiple facets, the "Show all" link's
* `is-active` CSS class doesn't leak into subsequent inactive facet links.
* https://www.drupal.org/project/facets/issues/3295536
*/
public function testMultilpleResetLinks() {
......@@ -270,18 +273,21 @@ class WidgetIntegrationTest extends FacetsTestBase {
$showAllLinks = $this->findFacetLink('Show all');
$this->assertCount(2, $showAllLinks);
for ($i = 0; $i < 2; ++$i)
for ($i = 0; $i < 2; ++$i) {
$this->assertTrue($showAllLinks[$i]->getParent()->hasClass('is-active'), 'The "Show all" link should be active.');
}
$itemLinks = $this->findFacetLink('item');
$this->assertCount(2, $itemLinks);
for ($i = 0; $i < 2; ++$i)
$this->assertTrue(! $itemLinks[$i]->getParent()->hasClass('is-active'), 'The "item" link should not be active.');
for ($i = 0; $i < 2; ++$i) {
$this->assertTrue(!$itemLinks[$i]->getParent()->hasClass('is-active'), 'The "item" link should not be active.');
}
$articleLinks = $this->findFacetLink('article');
$this->assertCount(2, $articleLinks);
for ($i = 0; $i < 2; ++$i)
$this->assertTrue(! $articleLinks[$i]->getParent()->hasClass('is-active'), 'The "article" link should not be active.');
for ($i = 0; $i < 2; ++$i) {
$this->assertTrue(!$articleLinks[$i]->getParent()->hasClass('is-active'), 'The "article" link should not be active.');
}
}
}
<?php
namespace Drupal\Tests\facets\FunctionalJavascript;
use Drupal\views\Entity\View;
/**
* Tests for the JS that powers ajax.
*
* @group facets
*/
class AjaxBehaviorTest extends JsBase {
/**
* {@inheritdoc}
*/
public function setUp(): void {
// @todo Remove this once below issue gets merged
// see: https://www.drupal.org/project/facets/issues/3052574
$this->markTestSkipped('Ajax is not working properly.');
parent::setUp();
// Force ajax.
$view = View::load('search_api_test_view');
$display = $view->getDisplay('page_1');
$display['display_options']['use_ajax'] = TRUE;
$view->save();
}
/**
* Tests ajax links.
*/
public function testAjaxLinks() {
// Create facets.
$this->createFacet('owl');
$this->createFacet('duck', 'keywords');
// Go to the views page.
$this->drupalGet('search-api-test-fulltext');
// Make sure the blocks are shown on the page.
$page = $this->getSession()->getPage();
$block_owl = $page->findById('block-owl-block');
$block_owl->isVisible();
$block_duck = $page->findById('block-duck-block');
$block_duck->isVisible();
/** @var \Drupal\FunctionalJavascriptTests\JSWebAssert $assert_session */
$assert_session = $this->assertSession();
$assert_session->pageTextContains('Displaying 5 search results');
// Check that the article link exists (and is formatted like a facet) link.
$links = $this->xpath('//a//span[normalize-space(text())=:label]', [':label' => 'article']);
$this->assertNotEmpty($links);
// Click the item facet.
$this->clickLink('item');
$assert_session->assertWaitOnAjaxRequest();
$assert_session->pageTextContains('Displaying 3 search results');
// Check that the article facet is now gone.
$links = $this->xpath('//a//span[normalize-space(text())=:label]', [':label' => 'article']);
$this->assertEmpty($links);
// Click the item facet again, and check that the article facet is back.
$this->clickLink('item');
$assert_session->assertWaitOnAjaxRequest();
$assert_session->pageTextContains('Displaying 5 search results');
$links = $this->xpath('//a//span[normalize-space(text())=:label]', [':label' => 'article']);
$this->assertNotEmpty($links);
// Check that the strawberry link disappears when filtering on items.
$links = $this->xpath('//a//span[normalize-space(text())=:label]', [':label' => 'strawberry']);
$this->assertNotEmpty($links);
$this->clickLink('item');
$assert_session->assertWaitOnAjaxRequest();
$links = $this->xpath('//a//span[normalize-space(text())=:label]', [':label' => 'strawberry']);
$this->assertEmpty($links);
}
/**
* Tests ajax dropdown.
*/
public function testAjaxDropdown() {
// Create facets.
$this->createFacet('owl');
$this->createFacet('duck', 'category', 'dropdown', []);
// Go to the views page.
$this->drupalGet('search-api-test-fulltext');
// Make sure the blocks are shown on the page.
$page = $this->getSession()->getPage();
$block_owl = $page->findById('block-owl-block');
$block_owl->isVisible();
$block_duck = $page->findById('block-duck-block');
$block_duck->isVisible();
/** @var \Drupal\FunctionalJavascriptTests\JSWebAssert $assert_session */
$assert_session = $this->assertSession();
$assert_session->pageTextContains('Displaying 5 search results');
// Check that the article_category option disappears when filtering on item.
$dropdown_entry = $this->xpath('//*[@id="block-duck-block"]/div/select/option[normalize-space(text())=:label]', [':label' => 'article_category']);
$this->assertNotEmpty($dropdown_entry);
$block_owl->clickLink('item');
$assert_session->assertWaitOnAjaxRequest();
$dropdown_entry = $this->xpath('//*[@id="block-duck-block"]/div/select/option[normalize-space(text())=:label]', [':label' => 'article_category']);
$this->assertEmpty($dropdown_entry);
// Click the item facet again.
$block_owl->clickLink('item');
$assert_session->assertWaitOnAjaxRequest();
// Select the article_category in the dropdown.
$dropdown = $this->xpath('//*[@id="block-duck-block"]/div/select');
$dropdown[0]->selectOption('article_category');
$assert_session->assertWaitOnAjaxRequest();
$assert_session->pageTextContains('Displaying 2 search results');
// Check that the article link exists (and is formatted like a facet) link.
$links = $this->xpath('//a//span[normalize-space(text())=:label]', [':label' => 'article']);
$this->assertNotEmpty($links);
// Check that the item link didn't exists.
$links = $this->xpath('//a//span[normalize-space(text())=:label]', [':label' => 'item']);
$this->assertEmpty($links);
}
/**
* Tests ajax checkbox.
*/
public function testAjaxCheckbox() {
// Create facets.
$this->createFacet('owl');
$this->createFacet('duck', 'keywords', 'checkbox');
// Go to the views page.
$this->drupalGet('search-api-test-fulltext');
// Make sure the blocks are shown on the page.
$page = $this->getSession()->getPage();
$block_owl = $page->findById('block-owl-block');
$block_owl->isVisible();
$block_duck = $page->findById('block-duck-block');
$block_duck->isVisible();
/** @var \Drupal\FunctionalJavascriptTests\JSWebAssert $assert_session */
$assert_session = $this->assertSession();
$assert_session->pageTextContains('Displaying 5 search results');
// Check that the article link exists (and is formatted like a facet) link.
$links = $this->xpath('//a//span[normalize-space(text())=:label]', [':label' => 'article']);
$this->assertNotEmpty($links);
// Click the item facet.
$this->clickLink('item');
$assert_session->assertWaitOnAjaxRequest();
$assert_session->pageTextContains('Displaying 3 search results');
// Check that the article facet is now gone.
$links = $this->xpath('//a//span[normalize-space(text())=:label]', [':label' => 'article']);
$this->assertEmpty($links);
// Click the item facet again, and check that the article facet is back.
$this->clickLink('item');
$assert_session->assertWaitOnAjaxRequest();
$assert_session->pageTextContains('Displaying 5 search results');
$links = $this->xpath('//a//span[normalize-space(text())=:label]', [':label' => 'article']);
$this->assertNotEmpty($links);
// Check that the strawberry link disappears when filtering on items.
$links = $this->xpath('//a//span[normalize-space(text())=:label]', [':label' => 'strawberry']);
$this->assertNotEmpty($links);
$this->clickLink('item');
$assert_session->assertWaitOnAjaxRequest();
$links = $this->xpath('//a//span[normalize-space(text())=:label]', [':label' => 'strawberry']);
$this->assertEmpty($links);
$this->clickLink('item');
$this->getSession()->getPage()->checkField('strawberry');
// Check that the article link exists (and is formatted like a facet) link.
$links = $this->xpath('//a//span[normalize-space(text())=:label]', [':label' => 'article']);
$this->assertNotEmpty($links);
// Check that the item link didn't exists.
$links = $this->xpath('//a//span[normalize-space(text())=:label]', [':label' => 'item']);
$this->assertEmpty($links);
}
/**
* Tests links with exposed filters.
*/
public function testLinksWithExposedFilter() {
$view = View::load('search_api_test_view');
$display = $view->getDisplay('page_1');
$display['display_options']['filters']['search_api_fulltext']['expose']['required'] = TRUE;
$view->save();
$this->createFacet('owl');
$this->drupalGet('search-api-test-fulltext');
$page = $this->getSession()->getPage();
$block_owl = $page->findById('block-owl-block');
$block_owl->isVisible();
/** @var \Drupal\FunctionalJavascriptTests\JSWebAssert $assert_session */
$assert_session = $this->assertSession();
$assert_session->fieldExists('edit-search-api-fulltext')->setValue('baz');
$this->click('.form-submit');
$assert_session->assertWaitOnAjaxRequest();
$assert_session->pageTextContains('Displaying 3 search results');
$this->clickLink('item');
$assert_session->assertWaitOnAjaxRequest();
$assert_session->pageTextContains('Displaying 1 search results');
}
}