function ContextualLinksTest::testContextualLinksVisibility

Same name in other branches
  1. 9 core/modules/contextual/tests/src/FunctionalJavascript/ContextualLinksTest.php \Drupal\Tests\contextual\FunctionalJavascript\ContextualLinksTest::testContextualLinksVisibility()
  2. 8.9.x core/modules/contextual/tests/src/FunctionalJavascript/ContextualLinksTest.php \Drupal\Tests\contextual\FunctionalJavascript\ContextualLinksTest::testContextualLinksVisibility()
  3. 11.x core/modules/contextual/tests/src/FunctionalJavascript/ContextualLinksTest.php \Drupal\Tests\contextual\FunctionalJavascript\ContextualLinksTest::testContextualLinksVisibility()

Tests the visibility of contextual links.

File

core/modules/contextual/tests/src/FunctionalJavascript/ContextualLinksTest.php, line 45

Class

ContextualLinksTest
Tests the UI for correct contextual links.

Namespace

Drupal\Tests\contextual\FunctionalJavascript

Code

public function testContextualLinksVisibility() : void {
    $this->drupalGet('user');
    $contextualLinks = $this->assertSession()
        ->waitForElement('css', '.contextual button');
    $this->assertEmpty($contextualLinks);
    // Ensure visibility remains correct after cached paged load.
    $this->drupalGet('user');
    $contextualLinks = $this->assertSession()
        ->waitForElement('css', '.contextual button');
    $this->assertEmpty($contextualLinks);
    // Grant permissions to use contextual links on blocks.
    $this->grantPermissions(Role::load(Role::AUTHENTICATED_ID), [
        'access contextual links',
        'administer blocks',
    ]);
    $this->drupalGet('user');
    $contextualLinks = $this->assertSession()
        ->waitForElement('css', '.contextual button');
    $this->assertNotEmpty($contextualLinks);
    // Confirm touchevents detection is loaded with Contextual Links
    $this->assertSession()
        ->elementExists('css', 'html.no-touchevents');
    // Ensure visibility remains correct after cached paged load.
    $this->drupalGet('user');
    $contextualLinks = $this->assertSession()
        ->waitForElement('css', '.contextual button');
    $this->assertNotEmpty($contextualLinks);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.