You are here

public function ContextualFilterTest::testAddContextualFilterUI in Drupal 8

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. 10 core/modules/views/tests/src/FunctionalJavascript/Plugin/views/Handler/ContextualFilterTest.php \Drupal\Tests\views\FunctionalJavascript\Plugin\views\Handler\ContextualFilterTest::testAddContextualFilterUI()

Test adding a contextual filter handler through the UI.

File

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

Class

ContextualFilterTest
Tests the contextual filter handler UI.

Namespace

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

Code

public function testAddContextualFilterUI() {
  $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);
}