3 namespace Drupal\Tests\standard\FunctionalJavascript;
5 use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
6 use Drupal\node\Entity\Node;
9 * Tests Standard installation profile JavaScript expectations.
13 class StandardJavascriptTest extends JavascriptTestBase {
18 protected $profile = 'standard';
21 * Tests BigPipe accelerates particular Standard installation profile routes.
23 public function testBigPipe() {
24 $this->drupalLogin($this->drupalCreateUser([
27 'skip comment approval',
30 $node = Node::create(['type' => 'article'])
31 ->setTitle($this->randomMachineName())
36 // Front page: one placeholder, for messages.
38 $this->assertBigPipePlaceholderReplacementCount(1);
40 // Node page: 3 placeholders:
42 // 2. local tasks block
44 $this->drupalGet($node->toUrl());
45 $this->assertBigPipePlaceholderReplacementCount(3);
49 * Asserts the number of BigPipe placeholders that are replaced on the page.
51 * @param int $expected_count
52 * The expected number of BigPipe placeholders.
54 protected function assertBigPipePlaceholderReplacementCount($expected_count) {
55 $web_assert = $this->assertSession();
56 $web_assert->waitForElement('css', 'script[data-big-pipe-event="stop"]');
57 $page = $this->getSession()->getPage();
58 $this->assertCount($expected_count, $this->getDrupalSettings()['bigPipePlaceholderIds']);
59 $this->assertCount($expected_count, $page->findAll('css', 'script[data-big-pipe-replacement-for-placeholder-with-id]'));