Skip to content

Commit

Permalink
New job invocation page: new widgets added
Browse files Browse the repository at this point in the history
Added new widgets for the expandable sections 'Target Hosts' and 'User Inputs'
on the new job invocation page as part of the RFE SAT-26605 phase#2.
  • Loading branch information
pnovotny committed Feb 17, 2025
1 parent e595b4a commit d410461
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
19 changes: 18 additions & 1 deletion airgun/views/job_invocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
SearchableViewMixin,
WizardStepView,
)
from airgun.widgets import ActionsDropdown
from airgun.widgets import ActionsDropdown, ExpandableSection, PF4DataList


class JobInvocationsView(BaseLoggedInView, SearchableViewMixin):
Expand Down Expand Up @@ -276,3 +276,20 @@ class overview(DescriptionList):
def read(self):
"""Return `dict` without trailing ':' in the key names."""
return {key.replace(':', ''): val for key, val in super().read().items()}

@View.nested
class target_hosts(ExpandableSection):
label = 'Target Hosts'
search_query = Text('./div[contains(@class, "pf-c-expandable-section__content")]/pre')
data = PF4DataList()

def read(self):
return {'search_query': self.search_query.read(), 'data': self.data.read()}

@View.nested
class user_inputs(ExpandableSection):
label = 'User Inputs'
data = PF4DataList()

def read(self):
return {'data': self.data.read()}
40 changes: 40 additions & 0 deletions airgun/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2901,3 +2901,43 @@ def __init__(

class SatExpandableTable(BaseExpandableTable, SatPatternflyTable):
pass


class ExpandableSection(Widget):
ROOT = ParametrizedLocator(
'//div[contains(@class, "pf-c-expandable-section")]/button[normalize-space(.)={@label|quote}]/..'
)
TOGGLE_BUTTON = ParametrizedLocator('./button[normalize-space(.)={@label|quote}]')
EXPANDED_CLASS_NAME = 'pf-m-expanded'

@property
def is_expanded(self):
return self.EXPANDED_CLASS_NAME in self.browser.classes(self.ROOT)

def expand(self):
if not self.is_expanded:
self.browser.click(self.TOGGLE_BUTTON)

def collapse(self):
if self.is_expanded:
self.browser.click(self.TOGGLE_BUTTON)

def read(self):
self.expand()


class PF4DataList(Widget):
"""Widget for PatternFly 4 Data list: https://pf4.patternfly.org/components/data-list"""

ROOT = './/ul[contains(@class, "pf-c-data-list")]'
ITEMS = './li//div[contains(@class, "pf-c-data-list__item-content")]/div[1]'
VALUES = './li//div[contains(@class, "pf-c-data-list__item-content")]/div[2]'

def read(self):
items = [self.browser.text(item) for item in self.browser.elements(self.ITEMS)]
values = [self.browser.text(value) for value in self.browser.elements(self.VALUES)]
if len(items) != len(values):
raise ValueError(
f'The count of data list labels and values does not match. Labels: {items}. Values: {values}'
)
return dict(zip(items, values))

0 comments on commit d410461

Please sign in to comment.