Commit 3a7e8290 authored by catch's avatar catch

Issue #2700495 by ronaldtebrake, droplet, samuel.mortenson, jibran, nod_:...

Issue #2700495 by ronaldtebrake, droplet, samuel.mortenson, jibran, nod_: Method removing expired drupalSettings.ajax tries to remove settings when there is no ajax defined
parent 07704716
<?php
namespace Drupal\Tests\views\FunctionalJavascript;
use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
use Drupal\simpletest\ContentTypeCreationTrait;
use Drupal\simpletest\NodeCreationTrait;
/**
* Tests the basic AJAX functionality of Views exposed forms.
*
* @group views
*/
class ExposedFilterAJAXTest extends JavascriptTestBase {
use ContentTypeCreationTrait;
use NodeCreationTrait;
/**
* {@inheritdoc}
*/
public static $modules = ['node', 'views'];
/**
* Tests if exposed filtering via AJAX works for the "Content" View.
*/
public function testExposedFiltering() {
// Enable AJAX on the /admin/content View.
\Drupal::configFactory()->getEditable('views.view.content')
->set('display.default.display_options.use_ajax', TRUE)
->save();
// Create a Content type and two test nodes.
$this->createContentType(['type' => 'page']);
$this->createNode(['title' => 'Page One']);
$this->createNode(['title' => 'Page Two']);
// Create a user privileged enough to use exposed filters and view content.
$user = $this->drupalCreateUser([
'administer site configuration',
'access content',
'access content overview',
]);
$this->drupalLogin($user);
// 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->assertContains('Page One', $html);
$this->assertContains('Page Two', $html);
// Search for "Page One".
$this->submitForm(['title' => 'Page One'], t('Filter'));
$this->waitForAjaxToFinish();
// Verify that only the "Page One" Node is present.
$html = $session->getPage()->getHtml();
$this->assertContains('Page One', $html);
$this->assertNotContains('Page Two', $html);
// Search for "Page Two".
$this->submitForm(['title' => 'Page Two'], t('Filter'));
$this->waitForAjaxToFinish();
// Verify that only the "Page Two" Node is present.
$html = $session->getPage()->getHtml();
$this->assertContains('Page Two', $html);
$this->assertNotContains('Page One', $html);
}
/**
* Waits for jQuery to become active and animations to complete.
*/
protected function waitForAjaxToFinish() {
$condition = "(0 === jQuery.active && 0 === jQuery(':animated').length)";
$this->assertJsCondition($condition, 10000);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment