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.
  if (version_compare(\Drupal::VERSION, '10.1', '>=')) {
    $this
      ->clickLink('Create a new field');
  }
  else {
    $this
      ->clickLink('Add field');
  }
  $this
    ->submitForm([
    'new_storage_type' => 'field_ui:entity_reference_revisions:paragraph',
    'label' => 'Paragraph',
    'field_name' => 'paragraph',
  ], $this
    ->coreVersion('10.2') ? 'Continue' : 'Save and continue');
  if (!$this
    ->coreVersion('10.2')) {
    $this
      ->submitForm([], 'Save field settings');
  }
  $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');
}