public function ParagraphsUiTest::testDefaultWidget

Test the default paragraphs widget used.

File

paragraphs/tests/src/Functional/ParagraphsUiTest.php, line 99

Class

ParagraphsUiTest
Tests the Paragraphs user interface.

Namespace

Drupal\Tests\paragraphs\Functional

Code

public function testDefaultWidget() {
  $this
    ->loginAsAdmin();

  // Create a new content type.
  $this
    ->drupalGet('admin/structure/types/add');
  $this
    ->submitForm([
    'name' => 'Test',
    'type' => 'test',
  ], 'Save and manage fields');

  // Add a new paragraphs field to the content type.
  $this
    ->clickLink('Create a new field');
  $this
    ->getSession()
    ->getPage()
    ->fillField('new_storage_type', 'field_ui:entity_reference_revisions:paragraph');
  if ($this
    ->coreVersion('10.3')) {
    $this
      ->getSession()
      ->getPage()
      ->pressButton('Continue');
  }
  $edit = [
    'label' => 'Paragraph',
    'field_name' => 'paragraph',
  ];
  $this
    ->submitForm($edit, 'Continue');
  $this
    ->submitForm([], 'Save settings');

  // Visit the "Manage form display" page of the new content type.
  $this
    ->drupalGet('admin/structure/types/manage/test/form-display');

  // The selected widget should be "paragraphs".
  $this
    ->assertSession()
    ->fieldValueEquals('fields[field_paragraph][type]', 'paragraphs');
}