function FilterTest::testAddingFilter

Same name and namespace in other branches
  1. 9 core/modules/views/tests/src/FunctionalJavascript/Plugin/views/Handler/FilterTest.php \Drupal\Tests\views\FunctionalJavascript\Plugin\views\Handler\FilterTest::testAddingFilter()
  2. 10 core/modules/views/tests/src/FunctionalJavascript/Plugin/views/Handler/FilterTest.php \Drupal\Tests\views\FunctionalJavascript\Plugin\views\Handler\FilterTest::testAddingFilter()

Tests adding a filter handler.

File

core/modules/views/tests/src/FunctionalJavascript/Plugin/views/Handler/FilterTest.php, line 62

Class

FilterTest
Tests the add filter handler UI.

Namespace

Drupal\Tests\views\FunctionalJavascript\Plugin\views\Handler

Code

public function testAddingFilter() : void {
    $web_assert = $this->assertSession();
    $url = '/admin/structure/views/view/content';
    $this->drupalGet($url);
    $page = $this->getSession()
        ->getPage();
    // Open the 'Add filter dialog'.
    $page->clickLink('views-add-filter');
    // Test filtering by type.
    $web_assert->waitForField('override[controls][group]');
    $page->fillField('override[controls][group]', 'content');
    $only_content_rows = $this->waitForOnlyContentRows();
    $this->assertTrue($only_content_rows);
    // Search for a specific title and test that this is now the only one shown.
    $page->fillField('override[controls][options_search]', 'body (body)');
    $filtering_done = $this->waitForVisibleElementCount(1, 'tr.filterable-option');
    $this->assertTrue($filtering_done);
    // Select the body field and apply the choice.
    $page->checkField('name[node__body.body_value]');
    $page->find('css', '.ui-dialog .ui-dialog-buttonpane')
        ->pressButton('Add and configure filter criteria');
    $web_assert->waitForField('options[expose_button][checkbox][checkbox]');
    // Expose the filter.
    $page->findField('options[expose_button][checkbox][checkbox]')
        ->click();
    $web_assert->waitForField('options[expose][label]');
    $page->find('css', '.ui-dialog .ui-dialog-buttonpane')
        ->pressButton('Apply');
    $web_assert->waitForText('Content: body (exposed)');
    $web_assert->responseContains('Content: body (exposed)');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.