Tests that header actions works fine with nesting.
public function testHeaderActionsWithNesting() {
$this
->addParagraphedContentType('paragraphed_test');
$this
->loginAsAdmin([
'create paragraphed_test content',
'edit any paragraphed_test content',
]);
// Add Paragraph types.
$nested_paragraph_type = 'nested_paragraph';
$this
->addParagraphsType($nested_paragraph_type);
$paragraph_type = 'text';
$this
->addParagraphsType($paragraph_type);
// Add a text field to the text_paragraph type.
static::fieldUIAddNewField('admin/structure/paragraphs_type/' . $paragraph_type, 'text', 'Text', 'text_long', [], []);
// Add a ERR paragraph field to the nested_paragraph type.
static::fieldUIAddNewField('admin/structure/paragraphs_type/' . $nested_paragraph_type, 'nested', 'Nested', 'field_ui:entity_reference_revisions:paragraph', [
'settings[target_type]' => 'paragraph',
'cardinality' => '-1',
], []);
$this
->drupalGet('admin/structure/paragraphs_type/nested_paragraph/form-display');
$this
->submitForm([
'fields[field_nested][type]' => 'paragraphs',
], 'Save');
$this
->setParagraphsWidgetSettings($nested_paragraph_type, 'nested', [
'edit_mode' => 'closed',
], 'paragraphs', 'paragraph');
// Checks that Collapse/Edit all button is presented.
$this
->drupalGet('node/add/paragraphed_test');
$this
->submitForm([], 'field_paragraphs_nested_paragraph_add_more');
$this
->submitForm([], 'field_paragraphs_text_add_more');
$this
->assertSession()
->responseContains('field_paragraphs_collapse_all');
$this
->assertSession()
->responseContains('field_paragraphs_edit_all');
$this
->submitForm([], 'field_paragraphs_text_add_more');
$this
->submitForm([], 'field_paragraphs_0_subform_field_nested_text_add_more');
$this
->assertSession()
->responseNotContains('field_paragraphs_0_collapse_all');
$this
->assertSession()
->responseNotContains('field_paragraphs_0_edit_all');
$edit = [
'field_paragraphs[0][subform][field_nested][0][subform][field_text][0][value]' => 'Nested text',
'field_paragraphs[1][subform][field_text][0][value]' => 'Second text paragraph',
];
$this
->submitForm($edit, 'Collapse all');
$this
->assertSession()
->responseContains('field-paragraphs-0-edit');
$this
->assertSession()
->elementExists('css', '[name="field_paragraphs_1_edit"] + .paragraphs-dropdown');
$this
->submitForm([], 'field_paragraphs_edit_all');
$this
->assertSession()
->responseContains('field-paragraphs-0-collapse');
$edit = [
'title[0][value]' => 'Test',
];
$this
->submitForm($edit, 'Save');
$this
->assertSession()
->pageTextContains('paragraphed_test Test has been created.');
$node = $this
->getNodeByTitle('Test');
$this
->drupalGet('node/' . $node
->id());
$this
->clickLink('Edit');
$this
->assertSession()
->pageTextNotContains('No Paragraph added yet.');
$this
->submitForm([], 'field_paragraphs_0_subform_field_nested_text_add_more');
$edit = [
'field_paragraphs[0][subform][field_nested][1][subform][field_text][0][value]' => 'Second nested text',
];
$this
->submitForm($edit, 'field_paragraphs_0_collapse');
$this
->submitForm([], 'field_paragraphs_0_edit');
$this
->assertSession()
->responseContains('field_paragraphs_0_subform_field_nested_collapse_all');
$this
->assertSession()
->responseContains('field_paragraphs_0_subform_field_nested_edit_all');
}