From fbe7f40fb23667fdf05d5b3be2149a0ef182ab95 Mon Sep 17 00:00:00 2001 From: Samuel Bible Date: Mon, 3 Jun 2024 01:39:02 -0500 Subject: [PATCH] CV UI - Add versions screen, and capability to search/read all tables (#1083) * Add versions screen, and capability to search/read all tables * Change field name and remove commented field * Better locator for versions tab * Apply suggestions from code review Use single quotation instead of double Co-authored-by: vijay sawant --------- Co-authored-by: vijay sawant --- airgun/entities/contentview_new.py | 28 +++++++++- airgun/views/contentview_new.py | 82 ++++++++++++++++++++++++++++-- 2 files changed, 105 insertions(+), 5 deletions(-) diff --git a/airgun/entities/contentview_new.py b/airgun/entities/contentview_new.py index 469017207..6007da6c0 100644 --- a/airgun/entities/contentview_new.py +++ b/airgun/entities/contentview_new.py @@ -9,6 +9,7 @@ ContentViewCreateView, ContentViewEditView, ContentViewTableView, + ContentViewVersionDetailsView, ContentViewVersionPublishView, CreateFilterView, EditFilterView, @@ -42,12 +43,22 @@ def publish(self, entity_name, values=None): view.fill(values) view.next.click() view.finish.click() - view.progressbar.wait_for_result(delay=0.01) view = self.navigate_to(self, 'Edit', entity_name=entity_name) self.browser.plugin.ensure_page_safe(timeout='5s') view.wait_displayed() return view.versions.table.read() + def read_version_table(self, entity_name, version, tab_name, search_param=None): + """Reads a specific table for a CV Version""" + view = self.navigate_to(self, 'Version', entity_name=entity_name, version=version) + self.browser.plugin.ensure_page_safe(timeout='5s') + view.wait_displayed() + # This allows dynamic access to the proper table + getattr(view, tab_name).table.wait_displayed() + if search_param: + getattr(view, tab_name).searchbox.search(search_param) + return getattr(view, tab_name).table.read() + def create_filter(self, entity_name, filter_name, filter_type, filter_inclusion): """Create a new filter on a CV - filter_type should be one of the available dropdown options in the Content Type dropdown, and filter_inclusion should be either 'include' or 'exclude' @@ -182,3 +193,18 @@ def step(self, *args, **kwargs): entity_name = kwargs.get('entity_name') self.parent.search(entity_name) self.parent.table.row(name=entity_name)['Name'].widget.click() + + +@navigator.register(NewContentViewEntity, 'Version') +class ShowContentViewVersionDetails(NavigateStep): + """Navigate to Content View Version screen for a specific Version.""" + + VIEW = ContentViewVersionDetailsView + + def prerequisite(self, *args, **kwargs): + return self.navigate_to(self.obj, 'Edit', **kwargs) + + def step(self, *args, **kwargs): + version = kwargs.get('version') + self.parent.versions.search(version) + self.parent.versions.table.row(version=version)['Version'].widget.click() diff --git a/airgun/views/contentview_new.py b/airgun/views/contentview_new.py index 9415f54ce..c6db5fbdb 100644 --- a/airgun/views/contentview_new.py +++ b/airgun/views/contentview_new.py @@ -103,7 +103,7 @@ class ContentViewTableView(BaseLoggedInView, SearchableViewMixinPF4): @property def is_displayed(self): - return self.create_content_view.is_displayed() + return self.create_content_view.is_displayed class ContentViewCreateView(BaseLoggedInView): @@ -165,7 +165,9 @@ class details(Tab): @View.nested class versions(Tab): - TAB_LOCATOR = ParametrizedLocator('//a[contains(@href, "#/versions")]') + TAB_LOCATOR = ParametrizedLocator( + '//a[contains(@href, "#/versions") and @data-ouia-component-id="routed-tabs-tab-versions"]' + ) searchbox = PF4Search() table = PatternflyTable( component_id="content-view-versions-table", @@ -271,8 +273,80 @@ def before_fill(self, values=None): ) -class NewContentViewVersionDetailsView(BaseLoggedInView): +class ContentViewVersionDetailsView(BaseLoggedInView): breadcrumb = BreadCrumb() + version = Text(locator='.//h2[@data-ouia-component-id="cv-version"]') + promoteButton = PF4Button( + locator='.//button[@data-ouia-component-id="cv-details-publish-button"]' + ) + editDescription = PF4Button( + locator='.//button[@data-ouia-component-id="edit-button-description"]' + ) + + @View.nested + class repositories(Tab): + TAB_LOCATOR = ParametrizedLocator( + './/button[@data-ouia-component-id="cv-version-details-tabs-tab-repositories"]' + ) + searchbox = PF4Search() + table = PatternflyTable( + component_id="content-view-version-details-repositories-table", + column_widgets={ + 'Name': Text('.//a'), + 'Version': Text('.//a'), + 'Release': Text('.//a'), + 'Arch': Text('.//a'), + 'Epoch': Text('.//a'), + }, + ) + + @View.nested + class rpmPackages(Tab): + TAB_LOCATOR = ParametrizedLocator( + './/button[@data-ouia-component-id="cv-version-details-tabs-tab-rpmPackages"]' + ) + searchbox = PF4Search() + table = PatternflyTable( + component_id='content-view-version-details-rpm-packages-table', + column_widgets={ + 'Name': Text('.//a'), + 'Type': Text('.//a'), + 'Product': Text('.//a'), + 'Content': Text('.//a'), + }, + ) + + @View.nested + class rpmPackageGroups(Tab): + TAB_LOCATOR = ParametrizedLocator( + './/button[@data-ouia-component-id="cv-version-details-tabs-tab-rpmPackageGroups"]' + ) + searchbox = PF4Search() + table = PatternflyTable( + component_id='content-view-version-details-rpm-package-groups-table', + column_widgets={ + 'Name': Text('.//a'), + 'Repository': Text('.//a'), + }, + ) + + @View.nested + class errata(Tab): + TAB_LOCATOR = ParametrizedLocator( + './/button[@data-ouia-component-id="cv-version-details-tabs-tab-errata"]' + ) + searchbox = PF4Search() + table = PatternflyTable( + component_id='content-view-version-details-errata-table', + column_widgets={ + 'Errata ID': Text('.//a'), + 'Title': Text('.//a'), + 'Type': Text('.//a'), + 'Modular': Text('.//a'), + 'Applicable Content Hosts': Text('.//a'), + 'Updated': Text('.//a'), + }, + ) @property def is_displayed(self): @@ -280,7 +354,7 @@ def is_displayed(self): return ( breadcrumb_loaded and len(self.breadcrumb.locations) > LOCATION_NUM - and self.breadcrumb.locations[0] == 'Content Views' + and self.breadcrumb.locations[0] == 'Content views' and self.breadcrumb.locations[2] == 'Versions' )