Test the paragraph type description settings.
public function testParagraphTypeDescription() {
$admin_user = $this
->drupalCreateUser([
'administer paragraphs types',
]);
$this
->drupalLogin($admin_user);
// Add the paragraph type with description.
$this
->drupalGet('admin/structure/paragraphs_type/add');
$this
->assertSession()
->pageTextContains('Description');
$label = 'Test paragraph type';
$description_markup = 'Use <em>Test paragraph type</em> to test the functionality of descriptions.';
$description_text = 'Use Test paragraph type to test the functionality of descriptions.';
$edit = [
'label' => $label,
'id' => 'test_paragraph_type_description',
'description' => $description_markup,
];
$this
->submitForm($edit, 'Save and manage fields');
$this
->assertSession()
->pageTextContains("Saved the {$label} Paragraphs type.");
// Check if the description has been saved.
$this
->drupalGet('admin/structure/paragraphs_type');
$this
->assertSession()
->pageTextContains('Description');
$this
->assertSession()
->pageTextContains($description_text);
$this
->assertSession()
->responseContains($description_markup);
// Check if description is at Description column.
$header_position = count($this
->xpath('//table/thead/tr/th[.="Description"]/preceding-sibling::th'));
$row_position = count($this
->xpath('//table/tbody/tr/td[.="' . $description_text . '"]/preceding-sibling::td'));
$this
->assertEquals($header_position, $row_position);
$this
->clickLink('Edit');
$this
->assertSession()
->responseContains('Use <em>Test paragraph type</em> to test the functionality of descriptions.');
}