X-Git-Url: https://yaffs.net/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Flayout_builder%2Ftests%2Fsrc%2FFunctionalJavascript%2FInlineBlockTest.php;h=4f463192d150bde3a9b787b4ffcbddeba55e3509;hb=1c1cb0980bfa6caf0c24cce671b6bb541dc87583;hp=9fdc8fdd3cca27a32e26fa6b7ac3dde17ed1fc4f;hpb=9424afc6c1f518c301bf87a23c047d1873435d05;p=yaffs-website diff --git a/web/core/modules/layout_builder/tests/src/FunctionalJavascript/InlineBlockTest.php b/web/core/modules/layout_builder/tests/src/FunctionalJavascript/InlineBlockTest.php index 9fdc8fdd3..4f463192d 100644 --- a/web/core/modules/layout_builder/tests/src/FunctionalJavascript/InlineBlockTest.php +++ b/web/core/modules/layout_builder/tests/src/FunctionalJavascript/InlineBlockTest.php @@ -428,4 +428,74 @@ class InlineBlockTest extends InlineBlockTestBase { $assert_session->pageTextNotContains('You are not authorized to access this page'); } + /** + * Tests the workflow for adding an inline block depending on number of types. + * + * @throws \Behat\Mink\Exception\ElementNotFoundException + * @throws \Behat\Mink\Exception\ExpectationException + */ + public function testAddWorkFlow() { + $assert_session = $this->assertSession(); + $page = $this->getSession()->getPage(); + $type_storage = $this->container->get('entity_type.manager')->getStorage('block_content_type'); + foreach ($type_storage->loadByProperties() as $type) { + $type->delete(); + } + + $this->drupalLogin($this->drupalCreateUser([ + 'access contextual links', + 'configure any layout', + 'administer node display', + 'administer node fields', + ])); + + // Enable layout builder and overrides. + $this->drupalPostForm( + static::FIELD_UI_PREFIX . '/display/default', + ['layout[enabled]' => TRUE, 'layout[allow_custom]' => TRUE], + 'Save' + ); + + $layout_default_path = 'admin/structure/types/manage/bundle_with_section_field/display-layout/default'; + $this->drupalGet($layout_default_path); + // Add a basic block with the body field set. + $page->clickLink('Add Block'); + $assert_session->assertWaitOnAjaxRequest(); + // Confirm that with no block content types the link does not appear. + $assert_session->linkNotExists('Create custom block'); + + $this->createBlockContentType('basic', 'Basic block'); + + $this->drupalGet($layout_default_path); + // Add a basic block with the body field set. + $page->clickLink('Add Block'); + $assert_session->assertWaitOnAjaxRequest(); + // Confirm with only 1 type the "Create custom block" link goes directly t + // block add form. + $assert_session->linkNotExists('Basic block'); + $this->clickLink('Create custom block'); + $assert_session->assertWaitOnAjaxRequest(); + $assert_session->fieldExists('Title'); + + $this->createBlockContentType('advanced', 'Advanced block'); + + $this->drupalGet($layout_default_path); + // Add a basic block with the body field set. + $page->clickLink('Add Block'); + // Confirm that, when more than 1 type exists, "Create custom block" shows a + // list of block types. + $assert_session->assertWaitOnAjaxRequest(); + $assert_session->linkNotExists('Basic block'); + $assert_session->linkNotExists('Advanced block'); + $this->clickLink('Create custom block'); + $assert_session->assertWaitOnAjaxRequest(); + $assert_session->fieldNotExists('Title'); + $assert_session->linkExists('Basic block'); + $assert_session->linkExists('Advanced block'); + + $this->clickLink('Advanced block'); + $assert_session->assertWaitOnAjaxRequest(); + $assert_session->fieldExists('Title'); + } + }