StandardJavascriptTest.php in Drupal 9
File
core/profiles/standard/tests/src/FunctionalJavascript/StandardJavascriptTest.php
View source
<?php
namespace Drupal\Tests\standard\FunctionalJavascript;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
use Drupal\node\Entity\Node;
class StandardJavascriptTest extends WebDriverTestBase {
protected $profile = 'standard';
public function testBigPipe() {
$this
->drupalLogin($this
->drupalCreateUser([
'access content',
'post comments',
'skip comment approval',
]));
$node = Node::create([
'type' => 'article',
])
->setTitle($this
->randomMachineName())
->setPromoted(TRUE)
->setPublished();
$node
->save();
$this
->drupalGet('');
$this
->assertBigPipePlaceholderReplacementCount(1);
$this
->drupalGet($node
->toUrl());
$this
->assertBigPipePlaceholderReplacementCount(2);
}
protected function assertBigPipePlaceholderReplacementCount($expected_count) {
$web_assert = $this
->assertSession();
$web_assert
->waitForElement('css', 'script[data-big-pipe-event="stop"]');
$page = $this
->getSession()
->getPage();
$this
->assertCount($expected_count, $this
->getDrupalSettings()['bigPipePlaceholderIds']);
$this
->assertCount($expected_count, $page
->findAll('css', 'script[data-big-pipe-replacement-for-placeholder-with-id]'));
}
}