Commit 20afd752 authored by Nguyen Tan's avatar Nguyen Tan Committed by Joël Pittet
Browse files

Issue #3264639 by joelpittet, tannguyenhn, justcaldwell, Berdir, Qusai Taha:...

Issue #3264639 by joelpittet, tannguyenhn, justcaldwell, Berdir, Qusai Taha: Can't preview a new node
parent b1f1e798
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -46,6 +46,10 @@ function moderation_sidebar_toolbar() {
    return $items;
  }

  if ($entity->isNew()) {
    return $items;
  }

  $cacheability->addCacheableDependency($entity);

  /** @var \Drupal\content_moderation\ModerationInformation $moderation_information */
+24 −1
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ class ModerationSidebarTest extends BrowserTestBase {
    'moderation_sidebar',
    'toolbar',
    'content_moderation',
    'node',
    'workflows',
    'entity_test',
  ];
@@ -40,10 +41,12 @@ class ModerationSidebarTest extends BrowserTestBase {
    $workflow = $this->createEditorialWorkflow();
    $this->addEntityTypeAndBundleToWorkflow($workflow, 'entity_test_mulrevpub', 'entity_test_mulrevpub');

    $this->drupalCreateContentType(['type' => 'article']);

    $this->drupalLogin($this->createUser([
      'view test entity',
      'access toolbar',
      'access toolbar',
      'create article content',
      'use ' . $workflow->id() . ' transition create_new_draft',
      'use ' . $workflow->id() . ' transition archive',
      'use ' . $workflow->id() . ' transition publish',
@@ -72,4 +75,24 @@ class ModerationSidebarTest extends BrowserTestBase {
    $this->assertEquals('Tasks', $toolbarItem->getText());
  }

  /**
   * Test preview with moderation sidebar.
   */
  public function testPreview() {
    $title_key = 'title[0][value]';

    // Create an english node with an english menu.
    $this->drupalGet('/node/add/article');
    $edit = [
      $title_key => $this->randomMachineName(),
    ];
    $this->drupalGet('node/add/article');
    $this->submitForm($edit, 'Preview');

    // Check that the preview is displaying the title, body and term.
    $expected_title = $edit[$title_key] . ' | Drupal';
    $this->assertSession()->titleEquals($expected_title);
    $this->assertSession()->linkExists('Back to content editing');
  }

}