Repository: splunk/addonfactory-ucc-generator (language: python)

Issue:
chore: ui tests improvements
Add few missing UI test cases.
Minor refactor of existing test cases



Discussion / hints:

Fix patch:
diff --git a/.gitignore b/.gitignore
index 55b19e817..674dc5174 100644
--- a/.gitignore
+++ b/.gitignore
@@ -36,3 +36,8 @@ output
 site/
 **/events.pickle
 assets/
+Splunk_TA_Dynatrace/*
+Splunk_TA_Dynatrace_ucc/*
+demo_addon_for_splunk/
+demo_addon_for_splunk_already_exists/
+init_addon_for_ucc_package/


Test patch:
diff --git a/tests/testdata/expected_addons/expected_output_global_config_everything/Splunk_TA_UCCExample/bin/splunk_ta_uccexample_rh_settings.py b/tests/testdata/expected_addons/expected_output_global_config_everything/Splunk_TA_UCCExample/bin/splunk_ta_uccexample_rh_settings.py
index 5bb1466fd..dc6d0f094 100644
--- a/tests/testdata/expected_addons/expected_output_global_config_everything/Splunk_TA_UCCExample/bin/splunk_ta_uccexample_rh_settings.py
+++ b/tests/testdata/expected_addons/expected_output_global_config_everything/Splunk_TA_UCCExample/bin/splunk_ta_uccexample_rh_settings.py
@@ -34,9 +34,14 @@
         required=False,
         encrypted=False,
         default=None,
-        validator=validator.String(
-            max_len=4096, 
-            min_len=0, 
+        validator=validator.AllOf(
+            validator.String(
+                max_len=4096, 
+                min_len=0, 
+            ), 
+            validator.Pattern(
+                regex=r"""^[a-zA-Z]\w*$""", 
+            )
         )
     ), 
     field.RestField(
diff --git a/tests/testdata/test_addons/package_global_config_everything/globalConfig.json b/tests/testdata/test_addons/package_global_config_everything/globalConfig.json
index c53e31645..25cc73f76 100644
--- a/tests/testdata/test_addons/package_global_config_everything/globalConfig.json
+++ b/tests/testdata/test_addons/package_global_config_everything/globalConfig.json
@@ -233,6 +233,11 @@
                                     "errorMsg": "Max host length is 4096",
                                     "minLength": 0,
                                     "maxLength": 4096
+                                },
+                                {
+                                    "type": "regex",
+                                    "errorMsg": "Proxy Host should not have special characters",
+                                    "pattern": "^[a-zA-Z]\\w*$"
                                 }
                             ],
                             "field": "proxy_url"
@@ -1286,7 +1291,7 @@
     "meta": {
         "name": "Splunk_TA_UCCExample",
         "restRoot": "splunk_ta_uccexample",
-        "version": "5.29.0R411a911a",
+        "version": "5.30.0R2e44f258",
         "displayName": "Splunk UCC test Add-on",
         "schemaVersion": "0.0.3"
     }
diff --git a/tests/ui/test_account_page.py b/tests/ui/test_account_page.py
index df2445c3f..739293426 100644
--- a/tests/ui/test_account_page.py
+++ b/tests/ui/test_account_page.py
@@ -99,7 +99,7 @@ def test_account_count(
     @pytest.mark.execute_enterprise_cloud_true
     @pytest.mark.forwarder
     @pytest.mark.account
-    def test_accounts_filter_functionality_negative(
+    def test_account_filter_functionality_negative(
         self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper, add_account
     ):
         """Verifies the filter functionality (Negative)"""
@@ -115,7 +115,7 @@ def test_accounts_filter_functionality_negative(
     @pytest.mark.execute_enterprise_cloud_true
     @pytest.mark.forwarder
     @pytest.mark.account
-    def test_accounts_filter_functionality_positive(
+    def test_account_filter_functionality_positive(
         self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper, add_account
     ):
         """Verifies the filter functionality (Positive)"""
@@ -896,9 +896,16 @@ def test_account_clone_default_values(
         account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
         account.table.clone_row(ACCOUNT_CONFIG["name"])
         self.assert_util(account.entity.name.get_value, "")
-        self.assert_util(account.entity.username.get_value, "TestUser")
+        self.assert_util(account.entity.environment.get_value, "Value1")
+        self.assert_util(
+            account.entity.example_checkbox.is_checked(),
+            ACCOUNT_CONFIG["account_checkbox"],
+        )
         self.assert_util(account.entity.multiple_select.get_values, ["Option One"])
-        self.assert_util(account.entity.auth_key.get_value, "basic")
+        self.assert_util(account.entity.auth_key.get_value, ACCOUNT_CONFIG["auth_type"])
+        self.assert_util(account.entity.username.get_value, ACCOUNT_CONFIG["username"])
+        self.assert_util(account.entity.password.get_value, "")
+        self.assert_util(account.entity.security_token.get_value, "")
 
     @pytest.mark.execute_enterprise_cloud_true
     @pytest.mark.forwarder
@@ -1035,3 +1042,50 @@ def test_account_delete_account_in_use(
             r"data collection for that input.",
             left_args={"name": ACCOUNT_CONFIG["name"], "prompt_msg": True},
         )
+
+    @pytest.mark.execute_enterprise_cloud_true
+    @pytest.mark.account
+    @pytest.mark.forwarder
+    def test_account_displayed_columns(
+        self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper
+    ):
+        """Verifies headers of account table"""
+        account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
+        expected_headers = ["Name", "Auth Type", "Actions"]
+        self.assert_util(list(account.table.get_headers()), expected_headers)
+
+    @pytest.mark.execute_enterprise_cloud_true
+    @pytest.mark.account
+    @pytest.mark.forwarder
+    def test_account_action_values(
+        self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper, add_account
+    ):
+        """Verifies action items for accout page"""
+        account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
+        expected_actions = ["Edit", "Clone", "Delete"]
+        self.assert_util(
+            list(account.table.get_list_of_actions(ACCOUNT_CONFIG["name"])),
+            expected_actions,
+        )
+
+    @pytest.mark.execute_enterprise_cloud_true
+    @pytest.mark.account
+    @pytest.mark.forwarder
+    def test_account_edit_default_values(
+        self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper, add_account
+    ):
+        """Verification of default values in fields at time of edit"""
+        account = AccountPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
+        account.table.edit_row(ACCOUNT_CONFIG["name"])
+        self.assert_util(account.entity.name.get_value, ACCOUNT_CONFIG["name"])
+        self.assert_util(account.entity.environment.get_value, "Value1")
+        self.assert_util(
+            account.entity.example_checkbox.is_checked(),
+            ACCOUNT_CONFIG["account_checkbox"],
+        )
+        # self.assert_util(account.entity.account_radio.get_value, "Yes")
+        self.assert_util(account.entity.multiple_select.get_values, ["Option One"])
+        self.assert_util(account.entity.auth_key.get_value, ACCOUNT_CONFIG["auth_type"])
+        self.assert_util(account.entity.username.get_value, ACCOUNT_CONFIG["username"])
+        self.assert_util(account.entity.password.get_value, "")
+        self.assert_util(account.entity.security_token.get_value, "")
diff --git a/tests/ui/test_custom_page.py b/tests/ui/test_custom_page.py
index b42966d41..539161565 100644
--- a/tests/ui/test_custom_page.py
+++ b/tests/ui/test_custom_page.py
@@ -47,7 +47,7 @@ def test_custom_frontend_backend_validation(
         """This test case checks the validates frontend save in custom tab"""
         custom = CustomPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
         custom.test_string.set_value("test_str")
-        custom.test_number.set_value("7")
+        custom.test_number.set_value("1")
         custom.test_regex.set_value("test_rex")
         custom.test_email.set_value("test@a.b")
         custom.test_ipv4.set_value("1.10.1.100")
@@ -58,7 +58,7 @@ def test_custom_frontend_backend_validation(
             custom.backend_conf.get_stanza,
             {
                 "disabled": False,
-                "testNumber": "7",
+                "testNumber": "1",
                 "testRegex": "test_rex",
                 "testString": "test_str",
                 "testEmail": "test@a.b",
@@ -123,12 +123,20 @@ def test_custom_valid_range_test_number(
         """This test case checks range of test number field should be between 1 to 10"""
         custom = CustomPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
         custom.test_string.set_value("test_str")
-        custom.test_number.set_value("50")
+        custom.test_number.set_value("0")
         self.assert_util(
             custom.save,
             r"Field Test Number should be within the range of [1 and 10]",
             left_args={"expect_error": True},
         )
+        custom.test_number.set_value("11")
+        self.assert_util(
+            custom.save,
+            r"Field Test Number should be within the range of [1 and 10]",
+            left_args={"expect_error": True},
+        )
+        custom.test_number.set_value("10")
+        self.assert_util(custom.save, True)
 
     @pytest.mark.execute_enterprise_cloud_true
     @pytest.mark.forwarder
diff --git a/tests/ui/test_logging_page.py b/tests/ui/test_logging_page.py
index 780d7b05a..f221ee9c5 100644
--- a/tests/ui/test_logging_page.py
+++ b/tests/ui/test_logging_page.py
@@ -69,3 +69,19 @@ def test_logging_selected_log_level_frontend_backend(
         self.assert_util(logging.log_level.get_value().lower(), selection_log.lower())
         log_level = logging.backend_conf.get_parameter("loglevel")
         self.assert_util(log_level, selection_log)
+
+    @pytest.mark.logging
+    def test_logging_label_log_level(
+        self,
+        ucc_smartx_selenium_helper,
+        ucc_smartx_rest_helper,
+    ):
+        """
+        Verifies the label of log level
+        """
+        logging = Logging(  # noqa: F811
+            C.ADDON_NAME,
+            ucc_smartx_selenium_helper=ucc_smartx_selenium_helper,
+            ucc_smartx_rest_helper=ucc_smartx_rest_helper,
+        )
+        self.assert_util(logging.log_level.get_input_label, "Log level")
diff --git a/tests/ui/test_proxy_page.py b/tests/ui/test_proxy_page.py
index 35cf2c314..361b85c6f 100644
--- a/tests/ui/test_proxy_page.py
+++ b/tests/ui/test_proxy_page.py
@@ -97,7 +97,7 @@ def test_proxy_required_field_port(
         )
         proxy.proxy_enable.check()
         proxy.type.select("http")
-        proxy.host.set_value("1.1.1.1")
+        proxy.host.set_value("foobar")
         proxy.username.set_value("test")
         proxy.password.set_value("test")
         self.assert_util(
@@ -116,7 +116,7 @@ def test_proxy_port_field_numeric_values(
             ucc_smartx_selenium_helper=ucc_smartx_selenium_helper,
             ucc_smartx_rest_helper=ucc_smartx_rest_helper,
         )
-        proxy.host.set_value("1.1.1.1")
+        proxy.host.set_value("foobar")
         proxy.port.set_value("test")
         self.assert_util(
             proxy.save,
@@ -136,7 +136,7 @@ def test_proxy_port_field_valid_range(
             ucc_smartx_selenium_helper=ucc_smartx_selenium_helper,
             ucc_smartx_rest_helper=ucc_smartx_rest_helper,
         )
-        proxy.host.set_value("1.1.1.1")
+        proxy.host.set_value("foobar")
         proxy.port.set_value("0")
         self.assert_util(
             proxy.save,
@@ -164,7 +164,7 @@ def test_proxy_encrypted_field_password(
         self.assert_util(msg, "Password is masked")
         proxy.proxy_enable.check()
         proxy.type.select("http")
-        proxy.host.set_value("abc")
+        proxy.host.set_value("foobar")
         proxy.port.set_value("655")
         proxy.username.set_value("test")
         proxy.password.set_value("test")
@@ -185,7 +185,7 @@ def test_proxy_username_field_length_validation(
             ucc_smartx_selenium_helper=ucc_smartx_selenium_helper,
             ucc_smartx_rest_helper=ucc_smartx_rest_helper,
         )
-        proxy.host.set_value("1.1.1.1")
+        proxy.host.set_value("foobar")
         proxy.port.set_value("65535")
         proxy.username.set_value("a" * 51)
         self.assert_util(
@@ -206,7 +206,7 @@ def test_proxy_password_field_length_validation(
             ucc_smartx_selenium_helper=ucc_smartx_selenium_helper,
             ucc_smartx_rest_helper=ucc_smartx_rest_helper,
         )
-        proxy.host.set_value("1.1.1.1")
+        proxy.host.set_value("foobar")
         proxy.port.set_value("65535")
         proxy.username.set_value("aaa")
         proxy.password.set_value("a" * 8193)
@@ -231,7 +231,7 @@ def test_proxy_frontend_backend_validation(
         )
         proxy.proxy_enable.check()
         proxy.type.select("socks4")
-        proxy.host.set_value("1.1.1.1")
+        proxy.host.set_value("foobar")
         proxy.port.set_value("655")
         proxy.username.set_value("test")
         proxy.password.set_value("test")
@@ -245,8 +245,30 @@ def test_proxy_frontend_backend_validation(
                 "proxy_port": "655",
                 "proxy_rdns": "1",
                 "proxy_type": "socks4",
-                "proxy_url": "1.1.1.1",
+                "proxy_url": "foobar",
                 "proxy_password": "test",
                 "proxy_username": "test",
             },
         )
+
+    @pytest.mark.execute_enterprise_cloud_false
+    @pytest.mark.proxy
+    @pytest.mark.forwarder
+    def test_proxy_host_valid_input(
+        self, ucc_smartx_selenium_helper, ucc_smartx_rest_helper
+    ):
+        """
+        Verification of host throwing error msg when containing special characters
+        """
+        proxy = Proxy(
+            C.ADDON_NAME,
+            PROXY_URL,
+            ucc_smartx_selenium_helper=ucc_smartx_selenium_helper,
+            ucc_smartx_rest_helper=ucc_smartx_rest_helper,
+        )
+        proxy.host.set_value("abc$$")
+        self.assert_util(
+            proxy.save,
+            "Proxy Host should not have special characters",
+            left_args={"expect_error": True},
+        )