You are here

public function ParagraphsGridLayoutPluginTest::testGridSettingsSummary in Paragraphs Collection 8

Tests Grid plugin summary for paragraphs closed mode.

File

tests/src/Functional/ParagraphsGridLayoutPluginTest.php, line 106

Class

ParagraphsGridLayoutPluginTest
Tests the grid layout plugin.

Namespace

Drupal\Tests\paragraphs_collection\Functional

Code

public function testGridSettingsSummary() {
  $this
    ->addParagraphedContentType('paragraphed_test', 'paragraphs_container');
  $this
    ->loginAsAdmin([
    'create paragraphed_test content',
    'edit any paragraphed_test content',
    'edit behavior plugin settings',
  ]);

  // Add a text paragraph type.
  $paragraph_type = 'text_paragraph';
  $this
    ->addParagraphsType($paragraph_type);
  $this
    ->fieldUIAddExistingField('admin/structure/paragraphs_type/' . $paragraph_type, 'paragraphs_text');
  $this
    ->setParagraphsWidgetMode('paragraphed_test', 'paragraphs_container', 'closed');

  // Node edit: add three text into the grid paragraph type, set grid layout.
  $this
    ->drupalGet('node/add/paragraphed_test');
  $this
    ->drupalPostForm(NULL, [], 'paragraphs_container_grid_add_more');
  $this
    ->drupalPostForm(NULL, [], 'paragraphs_container_0_subform_paragraphs_container_paragraphs_text_paragraph_add_more');
  $this
    ->drupalPostForm(NULL, [], 'paragraphs_container_0_subform_paragraphs_container_paragraphs_text_paragraph_add_more');
  $this
    ->drupalPostForm(NULL, [], 'paragraphs_container_0_subform_paragraphs_container_paragraphs_text_paragraph_add_more');
  $edit = [
    'title[0][value]' => 'Grid plugin summary',
    'paragraphs_container[0][subform][paragraphs_container_paragraphs][0][subform][paragraphs_text][0][value]' => 'Text 1',
    'paragraphs_container[0][subform][paragraphs_container_paragraphs][1][subform][paragraphs_text][0][value]' => 'Text 2',
    'paragraphs_container[0][subform][paragraphs_container_paragraphs][2][subform][paragraphs_text][0][value]' => 'Text 3',
    'paragraphs_container[0][behavior_plugins][grid_layout][layout_wrapper][layout]' => 'paragraphs_collection_test_two_column',
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'Save');
  $this
    ->assertText('paragraphed_test Grid plugin summary has been created.');

  // Assert that the summary includes the text of the behavior plugins.
  $this
    ->clickLink('Edit');
  $this
    ->assertRaw('<span class="summary-content">Text 1</span>, <span class="summary-content">Text 2</span>, <span class="summary-content">Text 3</span></div><div class="paragraphs-plugin-wrapper"><span class="summary-plugin"><span class="summary-plugin-label">Layout</span>Two columns');
  $this
    ->assertFieldByXPath('//*[@id="edit-paragraphs-container-0-top-icons"]/span[@class="paragraphs-badge" and @title="3 children"]');
}