diff --git a/core/modules/tracker/tests/src/Functional/TrackerTest.php b/core/modules/tracker/tests/src/Functional/TrackerTest.php
index 1a77d95ac8..f7fcdc3ee6 100644
--- a/core/modules/tracker/tests/src/Functional/TrackerTest.php
+++ b/core/modules/tracker/tests/src/Functional/TrackerTest.php
@@ -418,6 +418,33 @@ public function testTrackerAdminUnpublish() {
     $this->assertText(t('No content available.'), 'A node is displayed on the tracker listing pages.');
   }
 
+  /**
+   * Tests that tracker module can be installed with unpublished nodes existing.
+   */
+  public function testTrackerEnableModuleWithUnpublishedNodes() {
+    \Drupal::service('module_installer')->uninstall(['tracker']);
+    \Drupal::service('router.builder')->rebuild();
+
+    $this->drupalLogin($this->user);
+
+    $unpublished = $this->drupalCreateNode([
+      'title' => $this->randomMachineName(8),
+      'status' => 0,
+    ]);
+    $published = $this->drupalCreateNode([
+      'title' => $this->randomMachineName(8),
+      'status' => 1,
+    ]);
+
+    \Drupal::service('module_installer')->install(['tracker']);
+    \Drupal::service('router.builder')->rebuild();
+
+    $this->drupalLogin($this->user);
+    $this->drupalGet('activity');
+    $this->assertNoText($unpublished->label(), 'Unpublished node does not show up in the tracker listing.');
+    $this->assertText($published->label(), 'Published node shows up in the tracker listing.');
+  }
+
   /**
    * Passes if the appropriate history metadata exists.
    *
