function DisplayTest::testPageContextualLinks
Same name in other branches
- 9 core/modules/views_ui/tests/src/FunctionalJavascript/DisplayTest.php \Drupal\Tests\views_ui\FunctionalJavascript\DisplayTest::testPageContextualLinks()
- 8.9.x core/modules/views_ui/tests/src/FunctionalJavascript/DisplayTest.php \Drupal\Tests\views_ui\FunctionalJavascript\DisplayTest::testPageContextualLinks()
- 10 core/modules/views_ui/tests/src/FunctionalJavascript/DisplayTest.php \Drupal\Tests\views_ui\FunctionalJavascript\DisplayTest::testPageContextualLinks()
Tests contextual links on Views page displays.
File
-
core/
modules/ views_ui/ tests/ src/ FunctionalJavascript/ DisplayTest.php, line 111
Class
- DisplayTest
- Tests the display UI.
Namespace
Drupal\Tests\views_ui\FunctionalJavascriptCode
public function testPageContextualLinks() : void {
$view = View::load('test_display');
$view->enable()
->save();
$this->container
->get('router.builder')
->rebuildIfNeeded();
// Create node so the view has content and the contextual area is higher
// than 0 pixels.
$this->drupalCreateContentType([
'type' => 'page',
]);
$this->createNode();
// When no "main content" block is placed, we find a contextual link
// placeholder for editing just the view.
$this->drupalGet('test-display');
$page = $this->getSession()
->getPage();
$this->assertSession()
->assertWaitOnAjaxRequest();
$selector = '.views-element-container';
$this->toggleContextualTriggerVisibility($selector);
$element = $this->getSession()
->getPage()
->find('css', $selector);
$element->find('css', '.contextual button')
->press();
$contextual_container_id = 'entity.view.edit_form:view=test_display:location=page&name=test_display&display_id=page_1&langcode=en';
$contextual_container = $page->find('css', '[data-contextual-id="' . $contextual_container_id . '"]');
$this->assertNotEmpty($contextual_container);
$edit_link = $contextual_container->findLink('Edit view');
$this->assertNotEmpty($edit_link);
// When a "main content" is placed, we still find a contextual link
// placeholder for editing just the view (not the main content block).
// @see system_block_view_system_main_block_alter()
$this->drupalPlaceBlock('system_main_block', [
'id' => 'main_content',
]);
$contextual_container = $page->find('css', '[data-contextual-id="' . $contextual_container_id . '"]');
$this->assertNotEmpty($contextual_container);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.