You are here

public function AjaxPageStateTest::testDrupalSettingsIsNotLoaded in Drupal 10

Same name and namespace in other branches
  1. 9 core/modules/system/tests/src/Functional/Render/AjaxPageStateTest.php \Drupal\Tests\system\Functional\Render\AjaxPageStateTest::testDrupalSettingsIsNotLoaded()

Give ajax_page_state[libraries]=core/drupalSettings to exclude the library.

When called with ajax_page_state[libraries]=core/drupalSettings the library should be excluded as it is already loaded. This should not affect other libraries so test if active-link is still available.

File

core/modules/system/tests/src/Functional/Render/AjaxPageStateTest.php, line 64

Class

AjaxPageStateTest
Performs tests for the effects of the ajax_page_state query parameter.

Namespace

Drupal\Tests\system\Functional\Render

Code

public function testDrupalSettingsIsNotLoaded() {
  $this
    ->drupalGet('node', [
    "query" => [
      'ajax_page_state' => [
        'libraries' => 'core/drupalSettings',
      ],
    ],
  ]);

  // The drupalSettings library from core should be excluded from loading.
  $this
    ->assertSession()
    ->responseNotContains('/core/misc/drupalSettingsLoader.js');

  // The active-link library from core should be loaded.
  $this
    ->assertSession()
    ->responseContains('/core/misc/active-link.js');
}