From a251a3d9db0ce781be2e449c7e21e569d58686db Mon Sep 17 00:00:00 2001
From: rahul_ <rahul_gupta@3278723.no-reply.drupal.org>
Date: Fri, 15 Jul 2022 14:31:55 +0000
Subject: [PATCH] Issue #3295758 by rahul_: The project select should be a
 require field on the automatic_updates_extensions UpdaterForm

---
 automatic_updates_extensions/src/Form/UpdaterForm.php      | 2 ++
 .../tests/src/Functional/UpdaterFormTest.php               | 7 ++++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/automatic_updates_extensions/src/Form/UpdaterForm.php b/automatic_updates_extensions/src/Form/UpdaterForm.php
index 7b73ad19b8..24ec72e571 100644
--- a/automatic_updates_extensions/src/Form/UpdaterForm.php
+++ b/automatic_updates_extensions/src/Form/UpdaterForm.php
@@ -136,6 +136,8 @@ final class UpdaterForm extends FormBase {
       '#options' => $options,
       '#empty' => $this->t('There are no available updates.'),
       '#attributes' => ['class' => ['update-recommended']],
+      '#required' => TRUE,
+      '#required_error' => t('Please select one or more projects.'),
     ];
 
     if ($form_state->getUserInput()) {
diff --git a/automatic_updates_extensions/tests/src/Functional/UpdaterFormTest.php b/automatic_updates_extensions/tests/src/Functional/UpdaterFormTest.php
index 0457f014a4..70d5ce61b2 100644
--- a/automatic_updates_extensions/tests/src/Functional/UpdaterFormTest.php
+++ b/automatic_updates_extensions/tests/src/Functional/UpdaterFormTest.php
@@ -163,13 +163,18 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase {
       $installed_version,
       $target_version
     );
+    // Submit without selecting a project.
+    $page->pressButton('Update');
+    $assert_session = $this->assertSession();
+    $assert_session->pageTextContains('Please select one or more projects.');
+
+    // Submit with a project selected.
     $page->checkField('projects[' . $this->updateProject . ']');
     $page->pressButton('Update');
     $this->checkForMetaRefresh();
     $this->assertUpdateStagedTimes(1);
     // Confirm that the site was put into maintenance mode if needed.
     $this->assertSame($state->get('system.maintenance_mode'), $maintenance_mode_on);
-    $assert_session = $this->assertSession();
     $possible_update_message = 'Possible database updates were detected in the following extensions; you may be redirected to the database update page in order to complete the update process.';
     $assert_session->pageTextContains($possible_update_message);
     $assert_session->pageTextContainsOnce('System');
-- 
GitLab