function NavigationTopBarContentModerationTest::testContentModerationPageActions

Tests the interaction of page actions and content moderation.

File

core/modules/navigation/tests/src/Functional/NavigationTopBarContentModerationTest.php, line 60

Class

NavigationTopBarContentModerationTest
Tests the top bar behavior along with content moderation.

Namespace

Drupal\Tests\navigation\Functional

Code

public function testContentModerationPageActions() : void {
    $this->drupalGet($this->node
        ->toUrl());
    $this->assertSession()
        ->elementNotContains('xpath', '//*[@id="top-bar-page-actions"]/ul', 'Latest version');
    // Publish a new draft.
    $this->node
        ->setNewRevision(TRUE);
    $this->node
        ->setTitle($this->node
        ->getTitle() . ' - draft');
    $this->node->moderation_state->value = 'draft';
    $this->node
        ->save();
    $this->drupalGet($this->node
        ->toUrl());
    $this->assertSession()
        ->elementContains('xpath', '//*[@id="top-bar-page-actions"]/ul', 'Latest version');
    // Confirm that Edit option is featured  in Latest version page.
    $this->clickLink('Latest version');
    $this->assertSession()
        ->elementNotContains('xpath', '//*[@id="top-bar-page-actions"]/ul', 'Edit');
    $this->assertSession()
        ->elementTextEquals('xpath', "//div[contains(@class, 'top-bar__content')]/div[contains(@class, 'top-bar__actions')]/a[contains(@class, 'toolbar-button--icon--thin-pencil')]", "Edit");
}

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