From e4efc8b807d9b9254e0eb6bf267b050ec2901321 Mon Sep 17 00:00:00 2001
From: "yash.rode" <yash.rode@3685174.no-reply.drupal.org>
Date: Wed, 7 Sep 2022 12:27:57 +0000
Subject: [PATCH] Issue #3304617 by yash.rode, tedbow: Display readiness checks
 failure at admin/reports/updates/automatic-update

---
 src/Form/UpdaterForm.php                 | 18 +++++++++---------
 tests/src/Functional/UpdaterFormTest.php | 15 +++++++++++++++
 2 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/src/Form/UpdaterForm.php b/src/Form/UpdaterForm.php
index 2b36689a08..1a14a641b7 100644
--- a/src/Form/UpdaterForm.php
+++ b/src/Form/UpdaterForm.php
@@ -164,6 +164,15 @@ final class UpdaterForm extends FormBase {
       return $form;
     }
 
+    if ($form_state->getUserInput()) {
+      $results = [];
+    }
+    else {
+      $event = new ReadinessCheckEvent($this->updater);
+      $this->eventDispatcher->dispatch($event);
+      $results = $event->getResults();
+    }
+    $this->displayResults($results, $this->messenger(), $this->renderer);
     $project = $project_info->getProjectInfo();
     if ($installed_minor_release === NULL && $next_minor_release === NULL) {
       if ($project['status'] === UpdateManagerInterface::CURRENT) {
@@ -216,15 +225,6 @@ final class UpdaterForm extends FormBase {
         $release_status = $this->t('Available update');
         $type = 'update-recommended';
     }
-    if ($form_state->getUserInput()) {
-      $results = [];
-    }
-    else {
-      $event = new ReadinessCheckEvent($this->updater);
-      $this->eventDispatcher->dispatch($event);
-      $results = $event->getResults();
-    }
-    $this->displayResults($results, $this->messenger(), $this->renderer);
     $create_update_buttons = !$stage_exists && $this->getOverallSeverity($results) !== SystemManager::REQUIREMENT_ERROR;
     if ($installed_minor_release) {
       $installed_version = ExtensionVersion::createFromVersionString($project_info->getInstalledVersion());
diff --git a/tests/src/Functional/UpdaterFormTest.php b/tests/src/Functional/UpdaterFormTest.php
index 32aaa8eee5..f941578553 100644
--- a/tests/src/Functional/UpdaterFormTest.php
+++ b/tests/src/Functional/UpdaterFormTest.php
@@ -187,6 +187,21 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase {
     $this->assertUpdateStagedTimes(0);
   }
 
+  /**
+   * Tests readiness checks are displayed when there is no update available.
+   */
+  public function testReadinessCheckFailureWhenNoUpdate() {
+    $assert_session = $this->assertSession();
+    $this->setCoreVersion('9.8.1');
+    $message = "You've not experienced Shakespeare until you have read him in the original Klingon.";
+    $result = ValidationResult::createError([$message]);
+    TestSubscriber1::setTestResult([$result], ReadinessCheckEvent::class);
+    $this->checkForUpdates();
+    $this->drupalGet('/admin/reports/updates/automatic-update');
+    $assert_session->pageTextContains('No update available');
+    $assert_session->pageTextContains($message);
+  }
+
   /**
    * Checks the table for a release on the form.
    *
-- 
GitLab