function WorkspaceTest::testToolbarSwitcherDynamicPageCache

Tests that the toolbar workspace switcher doesn't disable the page cache.

File

core/modules/toolbar/tests/src/FunctionalJavascript/workspaces/WorkspaceTest.php, line 128

Class

WorkspaceTest
Test the workspace entity.

Namespace

Drupal\Tests\toolbar\FunctionalJavascript\workspaces

Code

public function testToolbarSwitcherDynamicPageCache() : void {
  $node_type = $this->drupalCreateContentType();
  $node = $this->drupalCreateNode([
    'type' => $node_type->id(),
  ]);
  $this->drupalLogin($this->drupalCreateUser([
    'access toolbar',
    'view any workspace',
  ]));
  $this->drupalGet($node->toUrl());
  $this->assertSession()
    ->responseHeaderEquals(DynamicPageCacheSubscriber::HEADER, 'MISS');
  // Reload the page, it should be cached now.
  $this->drupalGet($node->toUrl());
  $this->assertSession()
    ->elementExists('css', '.workspaces-toolbar-tab');
  $this->assertSession()
    ->responseHeaderEquals(DynamicPageCacheSubscriber::HEADER, 'HIT');
}

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