You are here

public function ContextualLinksTest::testContextualLinksVisibility in Drupal 9

Same name and namespace in other branches
  1. 8 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 40

Class

ContextualLinksTest
Tests the UI for correct contextual links.

Namespace

Drupal\Tests\contextual\FunctionalJavascript

Code

public function testContextualLinksVisibility() {
  $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);

  // Ensure visibility remains correct after cached paged load.
  $this
    ->drupalGet('user');
  $contextualLinks = $this
    ->assertSession()
    ->waitForElement('css', '.contextual button');
  $this
    ->assertNotEmpty($contextualLinks);
}