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