function ExposedFilterAJAXTest::testExposedFiltersInModal

Same name and namespace in other branches
  1. 8.9.x core/modules/views/tests/src/FunctionalJavascript/ExposedFilterAJAXTest.php \Drupal\Tests\views\FunctionalJavascript\ExposedFilterAJAXTest::testExposedFiltersInModal()
  2. 10 core/modules/views/tests/src/FunctionalJavascript/ExposedFilterAJAXTest.php \Drupal\Tests\views\FunctionalJavascript\ExposedFilterAJAXTest::testExposedFiltersInModal()
  3. 11.x core/modules/views/tests/src/FunctionalJavascript/ExposedFilterAJAXTest.php \Drupal\Tests\views\FunctionalJavascript\ExposedFilterAJAXTest::testExposedFiltersInModal()

Tests if exposed filtering via AJAX works in a modal.

File

core/modules/views/tests/src/FunctionalJavascript/ExposedFilterAJAXTest.php, line 128

Class

ExposedFilterAJAXTest
Tests the basic AJAX functionality of Views exposed forms.

Namespace

Drupal\Tests\views\FunctionalJavascript

Code

public function testExposedFiltersInModal() {
    $this->drupalGet('views-test-modal/modal');
    $assert = $this->assertSession();
    $assert->elementExists('named', [
        'link',
        'Administer content',
    ])
        ->click();
    $dialog = $assert->waitForElementVisible('css', '.views-test-modal');
    $session = $this->getSession();
    // Ensure that the Content we're testing for is present.
    $html = $session->getPage()
        ->getHtml();
    $this->assertStringContainsString('Page One', $html);
    $this->assertStringContainsString('Page Two', $html);
    // Search for "Page One".
    $session->getPage()
        ->fillField('title', 'Page One');
    $assert->elementExists('css', '.ui-dialog-buttonpane')
        ->pressButton('Filter');
    $this->assertSession()
        ->assertWaitOnAjaxRequest();
    // Verify that only the "Page One" Node is present.
    $html = $session->getPage()
        ->getHtml();
    $this->assertStringContainsString('Page One', $html);
    $this->assertStringNotContainsString('Page Two', $html);
    // Close and re-open the modal.
    $assert->buttonExists('Close', $dialog)
        ->press();
    $assert->elementExists('named', [
        'link',
        'Administer content',
    ])
        ->click();
    $assert->waitForElementVisible('css', '.views-test-modal');
    // Ensure that the Content we're testing for is present.
    $html = $session->getPage()
        ->getHtml();
    $this->assertStringContainsString('Page One', $html);
    $this->assertStringContainsString('Page Two', $html);
    // Search for "Page One".
    $session->getPage()
        ->fillField('title', 'Page One');
    $assert->elementExists('css', '.ui-dialog-buttonpane')
        ->pressButton('Filter');
    $this->assertSession()
        ->assertWaitOnAjaxRequest();
    // Verify that only the "Page One" Node is present.
    $html = $session->getPage()
        ->getHtml();
    $this->assertStringContainsString('Page One', $html);
    $this->assertStringNotContainsString('Page Two', $html);
}

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