You are here

public function ParagraphSplitTest::testParagraphSplitDataLoss in Thunder 8.3

Same name and namespace in other branches
  1. 8.5 tests/src/FunctionalJavascript/Integration/ParagraphSplitTest.php \Drupal\Tests\thunder\FunctionalJavascript\Integration\ParagraphSplitTest::testParagraphSplitDataLoss()
  2. 8.2 tests/src/FunctionalJavascript/Integration/ParagraphSplitTest.php \Drupal\Tests\thunder\FunctionalJavascript\Integration\ParagraphSplitTest::testParagraphSplitDataLoss()
  3. 8.4 tests/src/FunctionalJavascript/Integration/ParagraphSplitTest.php \Drupal\Tests\thunder\FunctionalJavascript\Integration\ParagraphSplitTest::testParagraphSplitDataLoss()
  4. 6.2.x tests/src/FunctionalJavascript/Integration/ParagraphSplitTest.php \Drupal\Tests\thunder\FunctionalJavascript\Integration\ParagraphSplitTest::testParagraphSplitDataLoss()
  5. 6.0.x tests/src/FunctionalJavascript/Integration/ParagraphSplitTest.php \Drupal\Tests\thunder\FunctionalJavascript\Integration\ParagraphSplitTest::testParagraphSplitDataLoss()
  6. 6.1.x tests/src/FunctionalJavascript/Integration/ParagraphSplitTest.php \Drupal\Tests\thunder\FunctionalJavascript\Integration\ParagraphSplitTest::testParagraphSplitDataLoss()

Test if a deleted paragraph leads to data loss.

File

tests/src/FunctionalJavascript/Integration/ParagraphSplitTest.php, line 63

Class

ParagraphSplitTest
Tests the paragraph split module integration.

Namespace

Drupal\Tests\thunder\FunctionalJavascript\Integration

Code

public function testParagraphSplitDataLoss() {
  $firstParagraphContent = '<p>Content that will be in the first paragraph after the split.</p>';
  $secondParagraphContent = '<p>Content that will be in the second paragraph after the split.</p>';
  $this
    ->articleFillNew([]);

  // Create first paragraph.
  $this
    ->addTextParagraph(static::$paragraphsField, '');

  // Remove the paragraph.
  $driver = $this
    ->getSession()
    ->getDriver();
  $driver
    ->executeScript("jQuery('[name=\"field_paragraphs_0_remove\"]').trigger('mousedown')");
  $this
    ->assertSession()
    ->assertWaitOnAjaxRequest();

  // Create second paragraph.
  $this
    ->addTextParagraph(static::$paragraphsField, $firstParagraphContent . $secondParagraphContent);

  // Select second element in editor.
  $this
    ->selectCkEditorElement($this
    ->getCkEditorCssSelector(1), 1);

  // Split text paragraph.
  $this
    ->clickParagraphSplitButton();
  $this
    ->assertSession()
    ->assertWaitOnAjaxRequest();

  // Test if all texts are in the correct paragraph.
  $this
    ->assertCkEditorContent($this
    ->getCkEditorCssSelector(1), $firstParagraphContent . PHP_EOL);
  $this
    ->assertCkEditorContent($this
    ->getCkEditorCssSelector(2), $secondParagraphContent . PHP_EOL);
}