You are here

public function TextareaWithSummaryTest::testTextSummaryBehavior in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/text/tests/src/FunctionalJavascript/TextareaWithSummaryTest.php \Drupal\Tests\text\FunctionalJavascript\TextareaWithSummaryTest::testTextSummaryBehavior()

Tests the textSummary javascript behavior.

File

core/modules/text/tests/src/FunctionalJavascript/TextareaWithSummaryTest.php, line 64

Class

TextareaWithSummaryTest
Tests the JavaScript functionality of the text_textarea_with_summary widget.

Namespace

Drupal\Tests\text\FunctionalJavascript

Code

public function testTextSummaryBehavior() {

  // Test with field defaults.
  $this
    ->assertSummaryToggle();

  // Repeat test with non-empty field description.
  $body_field = FieldConfig::loadByName('node', 'page', 'body');
  $body_field
    ->set('description', 'Text with Summary field description.');
  $body_field
    ->save();
  $this
    ->assertSummaryToggle();

  // Test summary is shown when non-empty.
  $node = $this
    ->createNode([
    'body' => [
      [
        'value' => $this
          ->randomMachineName(32),
        'summary' => $this
          ->randomMachineName(32),
        'format' => filter_default_format(),
      ],
    ],
  ]);
  $this
    ->drupalGet('node/' . $node
    ->id() . '/edit');
  $page = $this
    ->getSession()
    ->getPage();
  $summary_field = $page
    ->findField('edit-body-0-summary');
  $this
    ->assertEquals(TRUE, $summary_field
    ->isVisible(), 'Non-empty summary field is shown by default.');
}