function LayoutBuilderNestedFormUiTest::addFormBlock
Same name in other branches
- 9 core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderNestedFormUiTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderNestedFormUiTest::addFormBlock()
- 8.9.x core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderNestedFormUiTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderNestedFormUiTest::addFormBlock()
- 10 core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderNestedFormUiTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderNestedFormUiTest::addFormBlock()
Adds a form block specified by label layout and checks it can be saved.
Need to test saving and resaving, because nested forms can cause issues on the second save.
Parameters
string $label: The form block label that will be used to identify link to add block.
string $path: Root path of the entity (i.e. node/{NID) or the entity view display path.
string $expected_save_message: The message that should be displayed after successful layout save.
2 calls to LayoutBuilderNestedFormUiTest::addFormBlock()
- LayoutBuilderNestedFormUiTest::testAddingFormBlocksToDefaults in core/
modules/ layout_builder/ tests/ src/ FunctionalJavascript/ LayoutBuilderNestedFormUiTest.php - Tests blocks containing forms can be successfully saved editing defaults.
- LayoutBuilderNestedFormUiTest::testAddingFormBlocksToOverrides in core/
modules/ layout_builder/ tests/ src/ FunctionalJavascript/ LayoutBuilderNestedFormUiTest.php - Tests blocks containing forms can be successfully saved editing overrides.
File
-
core/
modules/ layout_builder/ tests/ src/ FunctionalJavascript/ LayoutBuilderNestedFormUiTest.php, line 137
Class
- LayoutBuilderNestedFormUiTest
- Tests placing blocks containing forms in theLayout Builder UI.
Namespace
Drupal\Tests\layout_builder\FunctionalJavascriptCode
protected function addFormBlock($label, $path, $expected_save_message) {
$assert_session = $this->assertSession();
$page = $this->getSession()
->getPage();
// Go to edit the layout.
$this->drupalGet($path . '/layout');
// Add the form block.
$assert_session->linkExists('Add block');
$this->clickLink('Add block');
$assert_session->waitForElementVisible('named', [
'link',
$label,
]);
$assert_session->linkExists($label);
$this->clickLink($label);
$assert_session->waitForElementVisible('named', [
'button',
'Add block',
]);
$page->pressButton('Add block');
$assert_session->assertWaitOnAjaxRequest();
$assert_session->pageTextContains($label);
$assert_session->addressEquals($path . '/layout');
// Save the defaults.
$page->pressButton('Save layout');
$assert_session->pageTextContains($expected_save_message);
$assert_session->addressEquals($path);
// Go back to edit layout and try to re-save.
$this->drupalGet($path . '/layout');
$page->pressButton('Save layout');
$assert_session->pageTextContains($expected_save_message);
$assert_session->addressEquals($path);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.