From 89763fbcf53a2e57e5d5f44a69e6b9933c58359c Mon Sep 17 00:00:00 2001
From: Ramil Gonzaga <rgonzaga@cs.ubc.ca>
Date: Tue, 7 Jan 2025 10:45:54 -0800
Subject: [PATCH 1/2] test UI of field aggregation settings

---
 .../tests/src/Functional/FieldUITest.php      | 31 ++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/core/modules/views_ui/tests/src/Functional/FieldUITest.php b/core/modules/views_ui/tests/src/Functional/FieldUITest.php
index cd8a199d18af..2789dfe1556c 100644
--- a/core/modules/views_ui/tests/src/Functional/FieldUITest.php
+++ b/core/modules/views_ui/tests/src/Functional/FieldUITest.php
@@ -25,7 +25,17 @@ class FieldUITest extends UITestBase {
    *
    * @var array
    */
-  public static $testViews = ['test_view'];
+  public static $testViews = [
+    'test_view',
+    'test_aggregate_count',
+  ];
+
+  /**
+   * {@inheritdoc}
+   */
+  protected static $modules = [
+    'entity_test',
+  ];
 
   /**
    * Tests the UI of field handlers.
@@ -104,4 +114,23 @@ public function testFieldLabel(): void {
     $this->assertEquals('', $view->field['title']->options['label'], 'The field label for normal styles are empty.');
   }
 
+  /**
+   * Tests the UI of field aggregation settings.
+   */
+  public function testFieldAggregationSettings(): void {
+    $edit_handler_url = 'admin/structure/views/nojs/handler-group/test_aggregate_count/default/field/id';
+    $this->drupalGet($edit_handler_url);
+    $this->submitForm(['options[group_type]' => 'count'], 'Apply');
+    $this->assertSession()
+      ->pageTextNotContains('The website encountered an unexpected error. Try again later.');
+    $this->drupalGet($edit_handler_url);
+    $dropdown = $this->getSession()->getPage()->find('named', ['select', 'options[group_column]']);
+    // Ensure the dropdown for group column exists.
+    $this->assertNotNull($dropdown, 'The dropdown for options[group_column] does not exist.');
+    $this->submitForm(['options[group_type]' => 'count'], 'Apply');
+    // Ensure that there is no error after submitting the form.
+    $this->assertSession()
+      ->pageTextNotContains('The website encountered an unexpected error. Try again later.');
+  }
+
 }
-- 
GitLab


From 23bc31dd861646948cb44a48359efe31d71f6722 Mon Sep 17 00:00:00 2001
From: Ramil Gonzaga <rgonzaga@cs.ubc.ca>
Date: Tue, 7 Jan 2025 11:45:15 -0800
Subject: [PATCH 2/2] #2735997 views ui aggregation settings patch

---
 core/modules/views/src/Plugin/views/query/Sql.php | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/core/modules/views/src/Plugin/views/query/Sql.php b/core/modules/views/src/Plugin/views/query/Sql.php
index c178044417aa..e218ddfe4a39 100644
--- a/core/modules/views/src/Plugin/views/query/Sql.php
+++ b/core/modules/views/src/Plugin/views/query/Sql.php
@@ -1786,7 +1786,6 @@ public function getAggregationInfo() {
         'method' => 'aggregationMethodSimple',
         'handler' => [
           'argument' => 'groupby_numeric',
-          'field' => 'numeric',
           'filter' => 'groupby_numeric',
           'sort' => 'groupby_numeric',
         ],
@@ -1796,7 +1795,6 @@ public function getAggregationInfo() {
         'method' => 'aggregationMethodDistinct',
         'handler' => [
           'argument' => 'groupby_numeric',
-          'field' => 'numeric',
           'filter' => 'groupby_numeric',
           'sort' => 'groupby_numeric',
         ],
@@ -1806,7 +1804,6 @@ public function getAggregationInfo() {
         'method' => 'aggregationMethodSimple',
         'handler' => [
           'argument' => 'groupby_numeric',
-          'field' => 'numeric',
           'filter' => 'groupby_numeric',
           'sort' => 'groupby_numeric',
         ],
@@ -1816,7 +1813,6 @@ public function getAggregationInfo() {
         'method' => 'aggregationMethodSimple',
         'handler' => [
           'argument' => 'groupby_numeric',
-          'field' => 'numeric',
           'filter' => 'groupby_numeric',
           'sort' => 'groupby_numeric',
         ],
@@ -1826,7 +1822,6 @@ public function getAggregationInfo() {
         'method' => 'aggregationMethodSimple',
         'handler' => [
           'argument' => 'groupby_numeric',
-          'field' => 'numeric',
           'filter' => 'groupby_numeric',
           'sort' => 'groupby_numeric',
         ],
@@ -1836,7 +1831,6 @@ public function getAggregationInfo() {
         'method' => 'aggregationMethodSimple',
         'handler' => [
           'argument' => 'groupby_numeric',
-          'field' => 'numeric',
           'filter' => 'groupby_numeric',
           'sort' => 'groupby_numeric',
         ],
@@ -1846,7 +1840,6 @@ public function getAggregationInfo() {
         'method' => 'aggregationMethodSimple',
         'handler' => [
           'argument' => 'groupby_numeric',
-          'field' => 'numeric',
           'filter' => 'groupby_numeric',
           'sort' => 'groupby_numeric',
         ],
-- 
GitLab