function LayoutBuilderDisableInteractionsTest::assertContextualLinkRetainsMouseup
Same name in other branches
- 8.9.x core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderDisableInteractionsTest::assertContextualLinkRetainsMouseup()
- 10 core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderDisableInteractionsTest::assertContextualLinkRetainsMouseup()
- 11.x core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderDisableInteractionsTest::assertContextualLinkRetainsMouseup()
Makes sure contextual links respond to mouseup event.
Disabling interactive elements includes preventing defaults on the mouseup event for links. However, this should not happen with contextual links. This is confirmed by clicking a contextual link then moving the mouse pointer. If mouseup is working properly, the draggable element will not be moved by the pointer moving.
@internal
1 call to LayoutBuilderDisableInteractionsTest::assertContextualLinkRetainsMouseup()
- LayoutBuilderDisableInteractionsTest::assertContextualLinksClickable in core/
modules/ layout_builder/ tests/ src/ FunctionalJavascript/ LayoutBuilderDisableInteractionsTest.php - Confirms that Layout Builder contextual links remain active.
File
-
core/
modules/ layout_builder/ tests/ src/ FunctionalJavascript/ LayoutBuilderDisableInteractionsTest.php, line 254
Class
- LayoutBuilderDisableInteractionsTest
- Tests the Layout Builder disables interactions of rendered blocks.
Namespace
Drupal\Tests\layout_builder\FunctionalJavascriptCode
protected function assertContextualLinkRetainsMouseup() : void {
$assert_session = $this->assertSession();
$page = $this->getSession()
->getPage();
$body_field_selector = '.block-field-blocknodebundle-with-section-fieldbody';
$body_block = $page->find('css', $body_field_selector);
$this->assertNotEmpty($body_block);
// Get the current Y position of the body block.
$body_block_top_position = $this->getElementVerticalPosition($body_field_selector, 'top');
$body_block_contextual_link_button = $body_block->find('css', '.trigger');
$this->assertNotEmpty($body_block_contextual_link_button);
// If the body block contextual link is hidden, make it visible.
if ($body_block_contextual_link_button->hasClass('visually-hidden')) {
$this->toggleContextualTriggerVisibility($body_field_selector);
}
// For the purposes of this test, the contextual link must be accessed with
// discrete steps instead of using ContextualLinkClickTrait.
$body_block->pressButton('Open configuration options');
$body_block->clickLink('Configure');
$this->assertNotEmpty($assert_session->waitForElementVisible('css', '#drupal-off-canvas'));
$assert_session->assertWaitOnAjaxRequest();
// After the contextual link opens the dialog, move the mouse pointer
// elsewhere on the page. If mouse up were not working correctly this would
// actually drag the body field too.
$this->movePointerTo('#iframe-that-should-be-disabled');
$new_body_block_bottom_position = $this->getElementVerticalPosition($body_field_selector, 'bottom');
$iframe_top_position = $this->getElementVerticalPosition('#iframe-that-should-be-disabled', 'top');
$minimum_distance_mouse_moved = $iframe_top_position - $new_body_block_bottom_position;
$this->assertGreaterThan(200, $minimum_distance_mouse_moved, 'The mouse moved at least 200 pixels');
// If mouseup is working properly, the body block should be nearly in same
// position as it was when $body_block_y_position was declared. It will have
// moved slightly because the current block being configured will have a
// border that was not present when the dialog was not open.
$new_body_block_top_position = $this->getElementVerticalPosition($body_field_selector, 'top');
$distance_body_block_moved = abs($body_block_top_position - $new_body_block_top_position);
// Confirm that body moved only slightly compared to the distance the mouse
// moved and therefore was not dragged when the mouse moved.
$this->assertGreaterThan($distance_body_block_moved * 20, $minimum_distance_mouse_moved);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.