You are here

public function ContextualLinksTest::testRevisionContextualLinks in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/node/tests/src/FunctionalJavascript/ContextualLinksTest.php \Drupal\Tests\node\FunctionalJavascript\ContextualLinksTest::testRevisionContextualLinks()
  2. 10 core/modules/node/tests/src/FunctionalJavascript/ContextualLinksTest.php \Drupal\Tests\node\FunctionalJavascript\ContextualLinksTest::testRevisionContextualLinks()

Tests the contextual links on revisions.

File

core/modules/node/tests/src/FunctionalJavascript/ContextualLinksTest.php, line 93

Class

ContextualLinksTest
Create a node with revisions and test contextual links.

Namespace

Drupal\Tests\node\FunctionalJavascript

Code

public function testRevisionContextualLinks() {

  // Confirm that the "Edit" and "Delete" contextual links appear for the
  // default revision.
  $this
    ->drupalGet('node/' . $this->nodes[0]
    ->id());
  $page = $this
    ->getSession()
    ->getPage();
  $page
    ->waitFor(10, function () use ($page) {
    return $page
      ->find('css', "main .contextual");
  });
  $this
    ->toggleContextualTriggerVisibility('main');
  $page
    ->find('css', 'main .contextual button')
    ->press();
  $links = $page
    ->findAll('css', "main .contextual-links li a");
  $this
    ->assertEquals('Edit', $links[0]
    ->getText());
  $this
    ->assertEquals('Delete', $links[1]
    ->getText());

  // Confirm that "Edit" and "Delete" contextual links don't appear for
  // non-default revision.
  $this
    ->drupalGet("node/" . $this->nodes[0]
    ->id() . "/revisions/" . $this->nodes[1]
    ->getRevisionId() . "/view");
  $this
    ->assertSession()
    ->pageTextContains($this->nodes[1]
    ->getTitle());
  $page
    ->waitFor(10, function () use ($page) {
    return $page
      ->find('css', "main .contextual");
  });
  $this
    ->toggleContextualTriggerVisibility('main');
  $contextual_button = $page
    ->find('css', 'main .contextual button');
  $this
    ->assertEmpty(0, $contextual_button ?: '');
}