public function LayoutBuilderSectionTest::testLayoutBuilderSectionForm in Block Style Plugins 8.2
Tests that styles can be applied via Layout Builder sections.
File
- tests/
src/ FunctionalJavascript/ LayoutBuilderSectionTest.php, line 69
Class
- LayoutBuilderSectionTest
- Layout Builder section tests.
Namespace
Drupal\Tests\block_style_plugins\FunctionalJavascriptCode
public function testLayoutBuilderSectionForm() {
/** @var \Drupal\FunctionalJavascriptTests\WebDriverWebAssert $assert */
$assert = $this
->assertSession();
$page = $this
->getSession()
->getPage();
$section_css_locator = '.layout--onecol';
$this
->drupalGet('node/1/layout');
$assert
->pageTextContains('The node body');
// Edit the Section config form.
$this
->clickLink('Configure Section 1');
$assert
->assertWaitOnAjaxRequest();
// Choose a style to apply.
$assert
->pageTextContains('Section Styles');
$page
->fillField('third_party_settings[block_style_plugins][section_class][test_section_field]', 'section-class');
$page
->pressButton('Update');
$assert
->assertNoElementAfterWait('css', '#drupal-off-canvas');
$assert
->assertWaitOnAjaxRequest();
// Check to see if classes were applied.
$section_element = $assert
->waitForElementVisible('css', $section_css_locator);
$section_element
->hasClass('section-class');
// Edit the style.
$this
->clickLink('Configure Section 1');
$assert
->assertWaitOnAjaxRequest();
$page
->fillField('third_party_settings[block_style_plugins][section_class][test_section_field]', 'edited-section-class');
$page
->pressButton('Update');
$assert
->assertNoElementAfterWait('css', '#drupal-off-canvas');
$assert
->assertWaitOnAjaxRequest();
// Check to see if classes were applied.
$section_element = $assert
->waitForElementVisible('css', $section_css_locator);
$section_element
->hasClass('section-class2');
// Save the Layout.
$page
->pressButton('Save layout');
// Check to see if classes are still applied.
$section_element = $assert
->waitForElementVisible('css', $section_css_locator);
$section_element
->hasClass('edited-section-class');
// Delete the style.
$this
->drupalGet('node/1/layout');
$this
->clickLink('Configure Section 1');
$assert
->assertWaitOnAjaxRequest();
$assert
->pageTextContains('Section Styles');
$page
->fillField('third_party_settings[block_style_plugins][section_class][test_section_field]', '');
$page
->pressButton('Update');
$assert
->assertNoElementAfterWait('css', '#drupal-off-canvas');
$assert
->assertWaitOnAjaxRequest();
// Check to see if classes have been removed.
$assert
->responseNotContains('edited-section-class');
// Save the Layout.
$page
->pressButton('Save layout');
// Check to see if classes have been removed.
$assert
->responseContains('The layout override has been saved');
$assert
->responseNotContains('edited-section-class');
}