Skip to content

Commit fa824e3

Browse files
feat: add changes for SUI-5 support in UCC (#454)
ADDON-78814: changes to support Splunk UI 5.
1 parent b9389fe commit fa824e3

File tree

7 files changed

+33
-16
lines changed

7 files changed

+33
-16
lines changed

.github/workflows/build-test-release.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
name: CI/CD
2+
13
on:
24
push:
35
branches:
@@ -24,7 +26,7 @@ jobs:
2426
steps:
2527
- uses: actions/checkout@v4
2628
- id: matrix
27-
uses: splunk/addonfactory-test-matrix-action@v1.10
29+
uses: splunk/addonfactory-test-matrix-action@v3.0.6
2830

2931
fossa-scan:
3032
continue-on-error: true
@@ -90,7 +92,8 @@ jobs:
9092
name: build
9193
runs-on: ubuntu-22.04
9294
needs:
93-
- fossa-scan
95+
# marking fossa-scan as optional due to pre-existing failures
96+
# - fossa-scan
9497
- compliance-copyrights
9598
- pre-commit
9699
- run-unit-tests

pytest_splunk_addon_ui_smartx/components/controls/checkbox.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def __init__(self, browser, container, searchable=True):
5656
),
5757
"checkbox_btn": Selector(
5858
select=container.select
59-
+ ' [data-test="button"][role="checkbox"]'
59+
+ ' div[data-test="controls"] button[role="checkbox"]'
6060
),
6161
}
6262
)

pytest_splunk_addon_ui_smartx/components/controls/single_select.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#
1616

1717
from selenium.webdriver.common.keys import Keys
18+
from selenium.webdriver.common.by import By
1819

1920
from ..base_component import Selector
2021
from .base_control import BaseControl
@@ -198,6 +199,11 @@ def get_value(self):
198199
if self.root.get_attribute(
199200
"data-test-loading"
200201
) == "false" and self.root.get_attribute("data-test-value"):
202+
nested_span_element = self.root.find_element(
203+
By.CSS_SELECTOR, "span > span"
204+
)
205+
if nested_span_element:
206+
return nested_span_element.text
201207
return self.root.get_attribute("label")
202208
else:
203209
return False

pytest_splunk_addon_ui_smartx/components/entity.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ def __init__(self, browser, container, add_btn=None, is_single_page=False):
6262
)
6363
self.cancel_btn = Button(
6464
browser,
65-
Selector(select=container.select + ' [data-test="button"][label="Cancel"]'),
65+
Selector(
66+
by=By.XPATH, select='//span[@data-test="label" and text()="Cancel"]'
67+
),
6668
)
6769
self.close_btn = Button(
6870
browser, Selector(select=container.select + ' button[data-test="close"]')

pytest_splunk_addon_ui_smartx/components/input_table.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ def __init__(self, browser, container, mapping={}):
4040
self.elements.update(
4141
{
4242
"switch_button_status": Selector(select='[data-disabled="true"]'),
43+
# It works as both selectors never exist simultaneously, if it does new_selector will get picked.
4344
"status_toggle": Selector(
44-
select='button[data-test="button"][role="switch"]'
45+
select='button[data-test="toggle"][role="switch"], button[data-test="button"][role="switch"]'
4546
),
4647
"switch_to_page": Selector(
4748
select=container.select + " [data-test-page]"

pytest_splunk_addon_ui_smartx/components/table.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,13 @@ def __init__(self, browser, container, mapping=dict(), wait_for_seconds=10):
7373
"search": Selector(select=".searchBtn"),
7474
"delete": Selector(select=".deleteBtn"),
7575
"delete_prompt": Selector(select=".deletePrompt"), # [data-test="body"]
76-
"delete_btn": Selector(select='[data-test="button"][label="Delete"]'),
76+
"delete_btn": Selector(
77+
by=By.XPATH,
78+
select='//button[@data-test="button" and .//span[text()="Delete"]]',
79+
),
7780
"delete_cancel": Selector(
78-
select='[data-test="button"][label="Cancel"]'
81+
by=By.XPATH,
82+
select='//button[@data-test="button" and .//span[text()="Cancel"]]',
7983
),
8084
"delete_close": Selector(select='[data-test="close"]'),
8185
"delete_loading": Selector(select='button[data-test="wait-spinner"]'),
@@ -126,11 +130,7 @@ def get_headers(self):
126130
:return: Generator for Str list The headers in the table
127131
"""
128132
headers = []
129-
GET_PARENT_ELEMENT = (
130-
"var parent = arguments[0].firstChild.firstChild;if(parent.hasChildNodes()){var r='';var C=parent.childNodes;"
131-
"for(var n=0;n<C.length;n++){if(C[n].nodeType==Node.TEXT_NODE){r+=' '+C[n].nodeValue}}"
132-
"return r.trim()}else{return parent.innerText}"
133-
)
133+
GET_PARENT_ELEMENT = "return arguments[0].innerText.trim();"
134134
for each in self.get_elements("header"):
135135
parent_text = self.browser.execute_script(GET_PARENT_ELEMENT, each)
136136
headers.append(parent_text)

tests/ui/test_splunk_ta_example_addon_input_1.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,17 +1269,22 @@ def test_inputs_textarea_height(
12691269
"""
12701270
input_page = InputPage(ucc_smartx_selenium_helper, ucc_smartx_rest_helper)
12711271
input_page.table.edit_row("dummy_input_one")
1272-
min_textarea_height = 71
1273-
max_textarea_height = 311
1272+
# adding two different heights for different Splunk versions
1273+
min_textarea_height = [61, 71]
1274+
max_textarea_height = [301, 311]
12741275
long_input = ""
12751276
self.assert_util(
1276-
min_textarea_height, input_page.entity1.text_area.get_textarea_height
1277+
left=input_page.entity1.text_area.get_textarea_height,
1278+
right=min_textarea_height,
1279+
operator="in",
12771280
)
12781281
for i in range(1, 50):
12791282
long_input += f"{str(i)}\n"
12801283
input_page.entity1.text_area.append_value(long_input)
12811284
self.assert_util(
1282-
max_textarea_height, input_page.entity1.text_area.get_textarea_height
1285+
left=input_page.entity1.text_area.get_textarea_height,
1286+
right=max_textarea_height,
1287+
operator="in",
12831288
)
12841289

12851290
@pytest.mark.execute_enterprise_cloud_true

0 commit comments

Comments
 (0)