diff --git a/modules/paragraphs_demo/src/Tests/ParagraphsDemoTest.php b/modules/paragraphs_demo/src/Tests/ParagraphsDemoTest.php index 54fc725..1543f28 100644 --- a/modules/paragraphs_demo/src/Tests/ParagraphsDemoTest.php +++ b/modules/paragraphs_demo/src/Tests/ParagraphsDemoTest.php @@ -155,4 +155,30 @@ class ParagraphsDemoTest extends WebTestBase { $this->assertNoRaw('Welcome to the Paragraphs Demo module!'); } + /** + * Tests the nested paragraph. + */ + public function testNestedParagraph() { + $this->drupalLogin($this->drupalCreateUser([ + 'create paragraphed_content_demo content', + 'edit any paragraphed_content_demo content', + ])); + // Create an user the reference in a paragraph. + $test_user = $this->drupalCreateUser([]); + + $this->drupalGet('node/add/paragraphed_content_demo'); + $this->drupalPostForm(NULL, NULL, t('Add Nested Paragraph')); + $this->drupalPostAjaxForm(NULL, NULL, t('field_paragraphs_demo_0_subform_field_paragraphs_demo_user_add_more')); + $this->drupalPostForm(NULL, [ + 'title[0][value]' => 'Node title', + 'field_paragraphs_demo[0][subform][field_paragraphs_demo][0][subform][field_user_demo][0][target_id]' => $test_user->label() . ' (' . $test_user->id() . ')', + ], t('Save')); + + $test_user->delete(); + $nodes = \Drupal::entityTypeManager()->getStorage('node')->loadByProperties(['title' => 'Node title']); + $this->drupalGet('node/' . current($nodes)->id() . '/edit'); + $this->drupalPostAjaxForm(NULL, [], t('field_paragraphs_demo_0_collapse')); + $this->assertResponse(200); + } + }