ee765b
From 991849cf58fa990ad4540a61214b5ab4fcd4baa1 Mon Sep 17 00:00:00 2001
ee765b
From: Armando Neto <abiagion@redhat.com>
ee765b
Date: Fri, 8 Jul 2022 15:56:31 -0300
ee765b
Subject: [PATCH] webui: Do not allow empty pagination size
ee765b
ee765b
Pagination size must be required, the current validators are triggered after
ee765b
form is submitted, thus the only way for check if data is not empty is by making
ee765b
the field required.
ee765b
ee765b
Fixes: https://pagure.io/freeipa/issue/9192
ee765b
ee765b
Signed-off-by: Armando Neto <abiagion@redhat.com>
ee765b
Reviewed-By: Florence Blanc-Renaud <frenaud@redhat.com>
ee765b
---
ee765b
 .../ui/src/freeipa/Application_controller.js  |  1 +
ee765b
 ipatests/test_webui/test_misc_cases.py        | 19 +++++++++++++++++++
ee765b
 2 files changed, 20 insertions(+)
ee765b
ee765b
diff --git a/install/ui/src/freeipa/Application_controller.js b/install/ui/src/freeipa/Application_controller.js
ee765b
index 46aabc9c4..140ee8fe0 100644
ee765b
--- a/install/ui/src/freeipa/Application_controller.js
ee765b
+++ b/install/ui/src/freeipa/Application_controller.js
ee765b
@@ -318,6 +318,7 @@ define([
ee765b
                         $type: 'text',
ee765b
                         name: 'pagination_size',
ee765b
                         label: '@i18n:customization.table_pagination',
ee765b
+                        required: true,
ee765b
                         validators: ['positive_integer']
ee765b
                     }
ee765b
                 ]
ee765b
diff --git a/ipatests/test_webui/test_misc_cases.py b/ipatests/test_webui/test_misc_cases.py
ee765b
index 5f7ffb54e..aca9e1a99 100644
ee765b
--- a/ipatests/test_webui/test_misc_cases.py
ee765b
+++ b/ipatests/test_webui/test_misc_cases.py
ee765b
@@ -11,6 +11,11 @@ from ipatests.test_webui.ui_driver import screenshot
ee765b
 import pytest
ee765b
 import re
ee765b
 
ee765b
+try:
ee765b
+    from selenium.webdriver.common.by import By
ee765b
+except ImportError:
ee765b
+    pass
ee765b
+
ee765b
 
ee765b
 @pytest.mark.tier1
ee765b
 class TestMiscCases(UI_driver):
ee765b
@@ -26,3 +31,17 @@ class TestMiscCases(UI_driver):
ee765b
         ver_re = re.compile('version: .*')
ee765b
         assert re.search(ver_re, about_text), 'Version not found'
ee765b
         self.dialog_button_click('ok')
ee765b
+
ee765b
+    @screenshot
ee765b
+    def test_customization_pagination_input_required(self):
ee765b
+        """Test if 'pagination size' is required when submitting the form."""
ee765b
+        self.init_app()
ee765b
+
ee765b
+        self.profile_menu_action('configuration')
ee765b
+        self.fill_input('pagination_size', '')
ee765b
+        self.dialog_button_click('save')
ee765b
+
ee765b
+        pagination_size_elem = self.find(
ee765b
+            ".widget[name='pagination_size']", By.CSS_SELECTOR)
ee765b
+
ee765b
+        self.assert_field_validation_required(parent=pagination_size_elem)
ee765b
-- 
ee765b
2.36.1
ee765b