function FrameworkTest::testLazyLoadOverriddenCSS

Same name in other branches
  1. 9 core/modules/system/tests/src/FunctionalJavascript/FrameworkTest.php \Drupal\Tests\system\FunctionalJavascript\FrameworkTest::testLazyLoadOverriddenCSS()
  2. 10 core/modules/system/tests/src/FunctionalJavascript/FrameworkTest.php \Drupal\Tests\system\FunctionalJavascript\FrameworkTest::testLazyLoadOverriddenCSS()
  3. 11.x core/modules/system/tests/src/FunctionalJavascript/FrameworkTest.php \Drupal\Tests\system\FunctionalJavascript\FrameworkTest::testLazyLoadOverriddenCSS()

Tests that overridden CSS files are not added during lazy load.

File

core/modules/system/tests/src/FunctionalJavascript/FrameworkTest.php, line 103

Class

FrameworkTest
Tests the off-canvas dialog functionality.

Namespace

Drupal\Tests\system\FunctionalJavascript

Code

public function testLazyLoadOverriddenCSS() {
    // The test theme overrides js.module.css without an implementation,
    // thereby removing it.
    \Drupal::service('theme_installer')->install([
        'test_theme',
    ]);
    $this->config('system.theme')
        ->set('default', 'test_theme')
        ->save();
    // This gets the form, and does an Ajax submission on it.
    $this->drupalGet('ajax_forms_test_lazy_load_form');
    $page = $this->getSession()
        ->getPage();
    $assert = $this->assertSession();
    $page->checkField('add_files');
    $page->pressButton('Submit');
    $assert->assertWaitOnAjaxRequest();
    // Verify that the resulting HTML does not load the overridden CSS file.
    // We add a "?" to the assertion, because drupalSettings may include
    // information about the file; we only really care about whether it appears
    // in a LINK or STYLE tag, for which Drupal always adds a query string for
    // cache control.
    $assert->responseNotContains('js.module.css?', 'Ajax lazy loading does not add overridden CSS files.');
}

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