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