X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Flayout_builder%2Ftests%2Fsrc%2FFunctionalJavascript%2FItemLayoutFieldBlockTest.php;fp=web%2Fcore%2Fmodules%2Flayout_builder%2Ftests%2Fsrc%2FFunctionalJavascript%2FItemLayoutFieldBlockTest.php;h=92b48a7762ae5d9de2c68133e86b6902c0e04442;hp=0000000000000000000000000000000000000000;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hpb=74df008bdbb3a11eeea356744f39b802369bda3c diff --git a/web/core/modules/layout_builder/tests/src/FunctionalJavascript/ItemLayoutFieldBlockTest.php b/web/core/modules/layout_builder/tests/src/FunctionalJavascript/ItemLayoutFieldBlockTest.php new file mode 100644 index 000000000..92b48a776 --- /dev/null +++ b/web/core/modules/layout_builder/tests/src/FunctionalJavascript/ItemLayoutFieldBlockTest.php @@ -0,0 +1,77 @@ +drupalLogin($this->drupalCreateUser([ + 'configure any layout', + 'administer node display', + 'administer node fields', + ])); + + // We need more then one content type for this test. + $this->createContentType(['type' => 'bundle_with_layout_overrides']); + $this->createContentType(['type' => 'filler_bundle']); + } + + /** + * Tests configuring a field block for a user field. + */ + public function testAddAjaxBlock() { + $assert_session = $this->assertSession(); + $page = $this->getSession()->getPage(); + + // Allow overrides for the layout. + $this->drupalGet('admin/structure/types/manage/bundle_with_layout_overrides/display/default'); + $page->checkField('layout[enabled]'); + $page->checkField('layout[allow_custom]'); + $page->pressButton('Save'); + + // Start by creating a node of type with layout overrides. + $node = $this->createNode([ + 'type' => 'bundle_with_layout_overrides', + 'body' => [ + [ + 'value' => 'The node body', + ], + ], + ]); + $node->save(); + + // Open single item layout page. + $this->drupalGet('node/1/layout'); + + // Add a new block. + $this->clickLink('Add Block'); + $assert_session->assertWaitOnAjaxRequest(); + + // Validate that only field blocks for layouted bundle are present. + $valid_links = $page->findAll('css', 'a[href$="field_block%3Anode%3Abundle_with_layout_overrides%3Abody"]'); + $this->assertCount(1, $valid_links); + $invalid_links = $page->findAll('css', 'a[href$="field_block%3Anode%3Afiller_bundle%3Abody"]'); + $this->assertCount(0, $invalid_links); + } + +}