Skip to content
Snippets Groups Projects
Commit 954ce9b8 authored by mark_fullmer's avatar mark_fullmer
Browse files

Add test coverage for required group

parent 1544bb11
No related branches found
No related tags found
No related merge requests found
......@@ -83,6 +83,14 @@ class LayoutBuilderStyleGroupTest extends BrowserTestBase {
'required' => false,
])->save();
LayoutBuilderStyleGroup::create([
'label' => 'Test Required',
'id' => 'testrequired',
'multiselect' => LayoutBuilderStyleGroupInterface::TYPE_MULTIPLE,
'form_type' => LayoutBuilderStyleGroupInterface::TYPE_MULTIPLE_SELECT,
'required' => TRUE,
])->save();
LayoutBuilderStyleGroup::create([
'label' => 'Test Single',
'id' => 'testsingle',
......@@ -124,6 +132,33 @@ class LayoutBuilderStyleGroupTest extends BrowserTestBase {
'group' => 'testsingle',
])->save();
LayoutBuilderStyle::create([
'id' => 'foobar5',
'label' => 'Foobar5',
'classes' => 'foo5-style-class',
'type' => 'section',
'group' => 'testrequired',
])->save();
LayoutBuilderStyle::create([
'id' => 'foobar6',
'label' => 'Foobar6',
'classes' => 'foo6-style-class',
'type' => 'section',
'group' => 'testrequired',
])->save();
// Confirm form validation catches if required group is not selected.
$this->drupalGet('node/' . $section_node->id());
$page->clickLink('Layout');
$page->clickLink('Add section');
$page->clickLink('Two column');
// Verify 'Required' group exists.
$assert_session->elementExists('css', 'select#edit-layout-builder-style-testrequired option');
// Do not make a selection.
$page->pressButton('Add section');
$assert_session->responseContains('Test Required field is required.');
// Add section to node with new styles.
$this->drupalGet('node/' . $section_node->id());
$assert_session->responseNotContains('foo-style-class bar-style-class');
......@@ -137,6 +172,7 @@ class LayoutBuilderStyleGroupTest extends BrowserTestBase {
$assert_session->elementExists('css', 'select#edit-layout-builder-style-testmulti option');
$page->selectFieldOption('edit-layout-builder-style-testmulti', 'foobar', TRUE);
$page->selectFieldOption('edit-layout-builder-style-testmulti', 'foobar2', TRUE);
$page->selectFieldOption('edit-layout-builder-style-testrequired', 'foobar5', TRUE);
$page->pressButton('Add section');
// Confirm section element contains the proper classes.
......@@ -156,6 +192,5 @@ class LayoutBuilderStyleGroupTest extends BrowserTestBase {
$assert_session->responseContains('foo3-style-class bar3-style-class');
$assert_session->responseNotContains('foo4-style-class bar4-style-class');
// Confirm query fails if required Group is not selected.
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment