public function ExposedFilterAJAXTest::testExposedFiltering in Drupal 9
Same name and namespace in other branches
- 8 core/modules/views/tests/src/FunctionalJavascript/ExposedFilterAJAXTest.php \Drupal\Tests\views\FunctionalJavascript\ExposedFilterAJAXTest::testExposedFiltering()
Tests if exposed filtering via AJAX works for the "Content" View.
File
- core/
modules/ views/ tests/ src/ FunctionalJavascript/ ExposedFilterAJAXTest.php, line 58
Class
- ExposedFilterAJAXTest
- Tests the basic AJAX functionality of Views exposed forms.
Namespace
Drupal\Tests\views\FunctionalJavascriptCode
public function testExposedFiltering() {
// Visit the View page.
$this
->drupalGet('admin/content');
$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".
$this
->submitForm([
'title' => 'Page One',
], '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);
// Search for "Page Two".
$this
->submitForm([
'title' => 'Page Two',
], 'Filter');
$this
->assertSession()
->assertWaitOnAjaxRequest();
// Verify that only the "Page Two" Node is present.
$html = $session
->getPage()
->getHtml();
$this
->assertStringContainsString('Page Two', $html);
$this
->assertStringNotContainsString('Page One', $html);
// Submit bulk actions form to ensure that the previous AJAX submit does not
// break it.
$this
->submitForm([
'action' => 'node_make_sticky_action',
'node_bulk_form[0]' => TRUE,
], 'Apply to selected items');
// Verify that the action was performed.
$this
->assertSession()
->pageTextContains('Make content sticky was applied to 1 item.');
// Reset the form.
$this
->submitForm([], 'Reset');
$this
->assertSession()
->assertWaitOnAjaxRequest();
$this
->assertSession()
->pageTextContains('Page One');
$this
->assertSession()
->pageTextContains('Page Two');
$this
->assertFalse($session
->getPage()
->hasButton('Reset'));
}