$assert_session->elementTextContains('css', '.layout__region--second', 'Powered by Drupal');
// Ensure the dragged block is still in the correct position after save.
$page->pressButton('Save layout'); $assert_session->elementExists('css', '.layout__region--second .block-system-powered-by-block'); $assert_session->elementTextContains('css', '.layout__region--second', 'Powered by Drupal');
// Reconfigure a block and ensure that the layout content is updated.
$this->drupalGet($layout_url); $this->markCurrentPage();
$this->clickContextualLink('.block-field-blocknodebundle-with-section-fieldbody [data-contextual-id^="layout_builder_block"]', 'Configure'); $this->assertNotEmpty($assert_session->waitForElementVisible('css', '.ui-dialog-titlebar [title="Close"]')); // We explicitly wait for the off-canvas area to be fully resized before
// trying to press the Close button, instead of waiting for the Close button
// itself to become visible. This is to prevent a regularly occurring random
// test failure.
$this->waitForOffCanvasArea(); $page->pressButton('Close'); $assert_session->assertNoElementAfterWait('css', '#drupal-off-canvas');
// Run the steps a second time after closing dialog, which reverses the
// order that behaviors.layoutBuilderDisableInteractiveElements and
/**
* Replaces the file in the block with another one.
*
* @param \Drupal\file\FileInterface $file
* The file entity.
*/ protectedfunctionreplaceFileInBlock(FileInterface $file){ $assert_session = $this->assertSession(); $page = $this->getSession()->getPage(); $this->clickContextualLink(static::INLINE_BLOCK_LOCATOR, 'Configure'); $assert_session->waitForElement('css', "#drupal-off-canvas input[value='Remove']"); $assert_session->assertWaitOnAjaxRequest(); $page->find('css', '#drupal-off-canvas')->pressButton('Remove'); $this->attachFileToBlockForm($file); $page->pressButton('Update'); $this->assertDialogClosedAndTextVisible($file->label(), static::INLINE_BLOCK_LOCATOR); }
/**
* Adds an entity block with a file.
*
* @param string $title
* The title field value.
* @param \Drupal\file\Entity\File $file
* The file entity.
*/
/**
* Removes an entity block from the layout but does not save the layout.
*/ protectedfunctionremoveInlineBlockFromLayout(){ $assert_session = $this->assertSession(); $page = $this->getSession()->getPage(); $block_text = $page->find('css', static::INLINE_BLOCK_LOCATOR)->getText(); $this->assertNotEmpty($block_text); $assert_session->pageTextContains($block_text); $this->clickContextualLink(static::INLINE_BLOCK_LOCATOR, 'Remove block'); $assert_session->waitForElement('css', "#drupal-off-canvas input[value='Remove']"); $assert_session->assertWaitOnAjaxRequest(); $page->find('css', '#drupal-off-canvas')->pressButton('Remove'); $assert_session->assertNoElementAfterWait('css', '#drupal-off-canvas'); $assert_session->assertNoElementAfterWait('css', static::INLINE_BLOCK_LOCATOR); $assert_session->assertWaitOnAjaxRequest(); $assert_session->pageTextNotContains($block_text); }
/**
* Adds an entity block to the layout.
*
* @param string $title
* The title field value.
* @param string $body
* The body field value.
*/
// A block is highlighted when its "Configure" contextual link is clicked.
$this->clickContextualLink('.block-field-blocknodebundle-with-section-fieldbody', 'Configure'); $this->assertNotEmpty($assert_session->waitForElementVisible('css', '#drupal-off-canvas')); $assert_session->assertWaitOnAjaxRequest(); $this->assertHighlightedElement('.block-field-blocknodebundle-with-section-fieldbody');
// Make sure the highlight remains when contextual links are revealed with
// the mouse.
$this->toggleContextualTriggerVisibility('.block-field-blocknodebundle-with-section-fieldbody'); $active_section = $page->find('css', '.block-field-blocknodebundle-with-section-fieldbody'); $active_section->pressButton('Open configuration options'); $this->assertNotEmpty($assert_session->waitForElementVisible('css', '.block-field-blocknodebundle-with-section-fieldbody .contextual.open'));
/**
* Tests clicking contextual links.
*/ publicfunctiontestContextualLinksClick(){ $this->container->get('module_installer')->install(['contextual_test']); // Test clicking contextual link without toolbar.
$this->drupalGet('user'); $this->assertSession()->assertWaitOnAjaxRequest(); $this->clickContextualLink('#block-branding', 'Test Link'); $this->assertSession()->pageTextContains('Everything is contextual!');
// Test click a contextual link that uses ajax.
$this->drupalGet('user'); $this->assertSession()->assertWaitOnAjaxRequest(); $current_page_string = 'NOT_RELOADED_IF_ON_PAGE'; $this->getSession()->executeScript('document.body.appendChild(document.createTextNode("' . $current_page_string . '"));');
// Move the pointer over the branding block so the contextual link appears
// as it would with a real user interaction. Otherwise clickContextualLink()
// does not open the dialog in a manner that is opener-aware, and it isn't
/**
* Asserts that blocks in a given order in the page.
*
* @param string[] $items
* An ordered list of strings that should appear in the blocks.
*
* @internal
*/