function AjaxBlockTest::testAddAjaxBlock
Same name in other branches
- 9 core/modules/layout_builder/tests/src/FunctionalJavascript/AjaxBlockTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\AjaxBlockTest::testAddAjaxBlock()
- 8.9.x core/modules/layout_builder/tests/src/FunctionalJavascript/AjaxBlockTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\AjaxBlockTest::testAddAjaxBlock()
- 10 core/modules/layout_builder/tests/src/FunctionalJavascript/AjaxBlockTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\AjaxBlockTest::testAddAjaxBlock()
Tests configuring a field block for a user field.
File
-
core/
modules/ layout_builder/ tests/ src/ FunctionalJavascript/ AjaxBlockTest.php, line 61
Class
- AjaxBlockTest
- Ajax blocks tests.
Namespace
Drupal\Tests\layout_builder\FunctionalJavascriptCode
public function testAddAjaxBlock() : void {
$assert_session = $this->assertSession();
$page = $this->getSession()
->getPage();
// Start by creating a node.
$this->createNode([
'type' => 'bundle_with_section_field',
'body' => [
[
'value' => 'The node body',
],
],
]);
$this->drupalGet('node/1');
$assert_session->pageTextContains('The node body');
$assert_session->pageTextNotContains('Every word is like an unnecessary stain on silence and nothingness.');
// From the manage display page, go to manage the layout.
$this->clickLink('Layout');
// The body field is present.
$assert_session->elementExists('css', '.field--name-body');
// Add a new block.
$assert_session->linkExists('Add block');
$this->clickLink('Add block');
$this->waitForOffCanvasArea();
$assert_session->assertWaitOnAjaxRequest();
$assert_session->linkExists('TestAjax');
$this->clickLink('TestAjax');
$this->waitForOffCanvasArea();
$assert_session->assertWaitOnAjaxRequest();
// Find the radio buttons.
$name = 'settings[ajax_test]';
/** @var \Behat\Mink\Element\NodeElement[] $radios */
$radios = $this->assertSession()
->fieldExists($name);
// Click them both a couple of times.
foreach ([
1,
2,
] as $rounds) {
foreach ($radios as $radio) {
$radio->click();
$assert_session->assertWaitOnAjaxRequest();
}
}
// Then add the block.
$assert_session->waitForElementVisible('named', [
'button',
'Add block',
])
->press();
$assert_session->assertWaitOnAjaxRequest();
$assert_session->waitForElementVisible('css', '.block-layout-builder-test-ajax');
$block_elements = $this->cssSelect('.block-layout-builder-test-ajax');
// Should be exactly one of these in there.
$this->assertCount(1, $block_elements);
$assert_session->pageTextContains('Every word is like an unnecessary stain on silence and nothingness.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.