public function ParagraphsWidgetButtonsTest::testAddModeSelect in Paragraphs 8
Tests 'Select list' add mode logic.
File
- tests/
src/ Functional/ ParagraphsWidgetButtonsTest.php, line 475
Class
- ParagraphsWidgetButtonsTest
- Tests paragraphs stable widget buttons.
Namespace
Drupal\Tests\paragraphs\FunctionalCode
public function testAddModeSelect() {
$this
->loginAsAdmin();
$this
->addParagraphedContentType('paragraphed_test', 'paragraphs');
$this
->addParagraphsType('test_paragraph');
$this
->addParagraphsType('text');
$this
->addFieldtoParagraphType('text', 'field_text_demo', 'text');
$settings = [
'add_mode' => 'select',
'edit_mode' => 'closed',
'closed_mode' => 'summary',
];
$this
->setParagraphsWidgetSettings('paragraphed_test', 'paragraphs', $settings, 'paragraphs');
$this
->drupalGet('node/add/paragraphed_test');
$this
->assertSession()
->selectExists('paragraphs[add_more][add_more_select]');
$edit = [
'settings[handler_settings][negate]' => 0,
'settings[handler_settings][target_bundles_drag_drop][text][enabled]' => 1,
];
$this
->drupalGet('admin/structure/types/manage/paragraphed_test/fields/node.paragraphed_test.paragraphs');
$this
->submitForm($edit, 'Save settings');
$this
->drupalGet('node/add/paragraphed_test');
$this
->assertSession()
->fieldNotExists('paragraphs[add_more][add_more_select]');
$this
->getSession()
->getPage()
->findButton('paragraphs_add_more')
->press();
$edit = [
'title[0][value]' => 'Demo text title',
'paragraphs[0][subform][field_text_demo][0][value]' => 'Demo text for the detail page',
];
$this
->submitForm($edit, 'Save');
$this
->assertSession()
->pageTextContains('Demo text for the detail page');
}