Skip to content

Commit dd91b71

Browse files
fix: ADDON-68980 single_select is_editable fix for combobox (#418)
Fix for reported issue with is_editable() of SingleSelect: https://splunk.atlassian.net/browse/ADDON-68980 Issue was present when SingleSelect element was configured to allow new values - updated tests scenarios.
1 parent d405e51 commit dd91b71

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

pytest_splunk_addon_ui_smartx/components/controls/single_select.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -367,11 +367,15 @@ def is_editable(self) -> bool:
367367
"""
368368
Returns True if the SingleSelect is editable, False otherwise
369369
"""
370-
if (
371-
self.root.get_attribute("readonly")
372-
or self.root.get_attribute("readOnly")
373-
or self.root.get_attribute("disabled")
374-
):
375-
return False
370+
if self.allow_new_values:
371+
return (
372+
not self.selected.get_attribute("readonly")
373+
and not self.selected.get_attribute("readOnly")
374+
and not self.selected.get_attribute("disabled")
375+
)
376376
else:
377-
return True
377+
return (
378+
not self.root.get_attribute("readonly")
379+
and not self.root.get_attribute("readOnly")
380+
and not self.root.get_attribute("disabled")
381+
)

pytest_splunk_addon_ui_smartx/components/dropdown.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def select_nested(self, values: list):
130130
break
131131
if not found:
132132
raise ValueError(
133-
f"{value} not found in select list. Values found {[_ for _.text.strip().lower in self.get_elements('values')]}"
133+
f"{value} not found in select list. Values found {[_.text.strip().lower() for _ in self.get_elements('dropdown_options')]}"
134134
)
135135
return True
136136

tests/testdata/Splunk_TA_UCCExample/globalConfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,7 @@
539539
"type": "singleSelect",
540540
"options": {
541541
"createSearchChoice": true,
542+
"disableonEdit": true,
542543
"autoCompleteFields": [
543544
{
544545
"label": "Group1",

tests/ui/test_splunk_ta_example_addon_input_1.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -869,6 +869,7 @@ def test_example_input_one_edit_uneditable_field_name(
869869
input_page = InputPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
870870
input_page.table.edit_row("dummy_input_one")
871871
self.assert_util(input_page.entity1.name.is_editable, False)
872+
self.assert_util(input_page.entity1.single_select_group_test.is_editable, False)
872873

873874
@pytest.mark.execute_enterprise_cloud_true
874875
@pytest.mark.forwarder
@@ -882,7 +883,6 @@ def test_example_input_one_edit_frontend_validation(
882883
input_page.table.edit_row("dummy_input_one")
883884
input_page.entity1.example_checkbox.uncheck()
884885
input_page.entity1.example_radio.select("No")
885-
input_page.entity1.single_select_group_test.select("four")
886886
input_page.entity1.multiple_select_test.deselect("b")
887887
input_page.entity1.interval.set_value("3600")
888888
input_page.entity1.index.select("main")
@@ -918,7 +918,6 @@ def test_example_input_one_edit_backend_validation(
918918
input_page.table.edit_row("dummy_input_one")
919919
input_page.entity1.example_checkbox.uncheck()
920920
input_page.entity1.example_radio.select("No")
921-
input_page.entity1.single_select_group_test.select("Four")
922921
input_page.entity1.multiple_select_test.deselect("b")
923922
input_page.entity1.interval.set_value("3600")
924923
input_page.entity1.index.select("main")
@@ -941,7 +940,7 @@ def test_example_input_one_edit_backend_validation(
941940
"object": "edit_object",
942941
"object_fields": "edit_field",
943942
"order_by": "LastDate",
944-
"singleSelectTest": "four",
943+
"singleSelectTest": "two",
945944
"start_date": "2020-20-20T20:20:20.000z",
946945
"disabled": 0,
947946
"example_textarea_field": "line3\nline4",

0 commit comments

Comments
 (0)