function ContextualFilterTest::testAddContextualFilterUI

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

Tests adding a contextual filter handler through the UI.

File

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

Class

ContextualFilterTest
Tests the contextual filter handler UI.

Namespace

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

Code

public function testAddContextualFilterUI() : void {
    $this->drupalGet('/admin/structure/views/view/test_field_body');
    $web_assert = $this->assertSession();
    $page = $this->getSession()
        ->getPage();
    $page->clickLink('views-add-argument');
    $field = $web_assert->waitForField('name[node_field_data.nid]');
    $this->assertNotEmpty($field);
    $field->check();
    $add_button = $page->find('css', '.ui-dialog-buttonset .button--primary');
    $add_button->click();
    $field_action = $web_assert->waitForField('options[default_action]');
    $this->assertNotEmpty($field_action);
    $field_action->setValue('default');
    $page->selectFieldOption('options[default_argument_type]', 'node');
    $add_button = $page->find('css', '.ui-dialog-buttonset .button--primary');
    $add_button->click();
    // Wait for the dialog to close.
    $page->waitFor(10, function () use ($page) {
        $field = $page->find('css', '.ui-dialog-buttonset .button--primary');
        return empty($field);
    });
    $page->pressButton('edit-actions-submit');
    $page->clickLink('Content: ID');
    // Check that the dialog opens.
    $field_action = $web_assert->waitForField('options[default_action]');
    $this->assertNotEmpty($field_action);
}

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