public function ParagraphsHeaderActionsTest::testHeaderActionsWithMultiFields in Paragraphs 8
Tests header actions with multi fields.
File
- tests/
src/ Functional/ WidgetStable/ ParagraphsHeaderActionsTest.php, line 237
Class
- ParagraphsHeaderActionsTest
- Tests collapse all button.
Namespace
Drupal\Tests\paragraphs\Functional\WidgetStableCode
public function testHeaderActionsWithMultiFields() {
$this
->addParagraphedContentType('paragraphed_test');
$this
->loginAsAdmin([
'create paragraphed_test content',
'edit any paragraphed_test content',
]);
$this
->drupalGet('/admin/structure/types/manage/paragraphed_test/fields/add-field');
// Add a Paragraph type.
$paragraph_type = 'text_paragraph';
$this
->addParagraphsType($paragraph_type);
$edit = [
'new_storage_type' => 'field_ui:entity_reference_revisions:paragraph',
'label' => 'Second paragraph',
'field_name' => 'second',
];
$this
->submitForm($edit, 'Save and continue');
$this
->submitForm([], 'Save field settings');
$this
->submitForm([], 'Save settings');
$this
->drupalGet('/admin/structure/types/manage/paragraphed_test/form-display');
$edit = [
'fields[field_second][type]' => 'paragraphs',
];
$this
->submitForm($edit, 'Save');
// Add a text field to the text_paragraph type.
static::fieldUIAddNewField('admin/structure/paragraphs_type/' . $paragraph_type, 'text', 'Text', 'text_long', [], []);
$this
->drupalGet('node/add/paragraphed_test');
$this
->submitForm([], 'field_paragraphs_text_paragraph_add_more');
$this
->submitForm([], 'field_second_text_paragraph_add_more');
// Checks that we have Collapse\Edit all for each field.
$this
->assertSession()
->responseContains('field_paragraphs_collapse_all');
$this
->assertSession()
->responseContains('field_paragraphs_edit_all');
$this
->assertSession()
->responseContains('field_second_collapse_all');
$this
->assertSession()
->responseContains('field_second_edit_all');
$edit = [
'field_second[0][subform][field_text][0][value]' => 'Second field',
];
$this
->submitForm($edit, 'field_second_collapse_all');
// Checks that we collapsed only children from second field.
$this
->assertSession()
->responseNotContains('field_paragraphs_0_edit');
$this
->assertSession()
->responseContains('field_second_0_edit');
$this
->submitForm([], 'field_paragraphs_collapse_all');
$this
->assertSession()
->responseContains('field_paragraphs_0_edit');
$this
->assertSession()
->responseContains('field_second_0_edit');
$this
->submitForm([], 'field_second_edit_all');
$this
->assertSession()
->responseContains('field_second_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.');
}