You are here

function ParagraphsHeaderActionsTest::testHeaderActionsWhileTranslating in Paragraphs 8

Tests drag and drop button visibility while translating.

File

tests/src/Functional/WidgetStable/ParagraphsHeaderActionsTest.php, line 314

Class

ParagraphsHeaderActionsTest
Tests collapse all button.

Namespace

Drupal\Tests\paragraphs\Functional\WidgetStable

Code

function testHeaderActionsWhileTranslating() {

  // Display drag and drop in tests.
  $this
    ->addParagraphedContentType('paragraphed_test');
  \Drupal::state()
    ->set('paragraphs_test_dragdrop_force_show', TRUE);
  $this
    ->loginAsAdmin([
    'administer site configuration',
    'create paragraphed_test content',
    'edit any paragraphed_test content',
    'delete any paragraphed_test content',
    'administer content translation',
    'translate any entity',
    'create content translations',
    'administer languages',
  ]);
  ConfigurableLanguage::createFromLangcode('es')
    ->save();

  // Enable translation for test content.
  $this
    ->drupalGet('admin/config/regional/content-language');
  $edit = [
    'entity_types[node]' => TRUE,
    'settings[node][paragraphed_test][translatable]' => TRUE,
  ];
  $this
    ->submitForm($edit, 'Save configuration');

  // Add a Paragraph type.
  $paragraph_type = 'text_paragraph';
  $this
    ->addParagraphsType($paragraph_type);
  static::fieldUIAddNewField('admin/structure/paragraphs_type/' . $paragraph_type, 'text', 'Text', 'text_long', [], []);
  $this
    ->drupalGet('node/add/paragraphed_test');

  // Assert that the drag and drop button is present.
  $this
    ->assertSession()
    ->responseContains('name="field_paragraphs_dragdrop_mode"');
  $edit = [
    'title[0][value]' => 'Title',
    'field_paragraphs[0][subform][field_text][0][value]' => 'First',
  ];
  $this
    ->submitForm($edit, 'Save');
  $this
    ->clickLink('Translate');
  $this
    ->clickLink('Add');

  // Assert that the drag and drop button is not present while translating.
  $this
    ->assertSession()
    ->responseNotContains('name="field_paragraphs_dragdrop_mode"');
  $this
    ->assertSession()
    ->pageTextContains('First');
}