From cc12bef61285f1503e051b318facde1d11be6b71 Mon Sep 17 00:00:00 2001 From: Sam Bible Date: Wed, 19 Feb 2025 07:42:20 -0600 Subject: [PATCH 1/2] Add view/entity for booted container images page --- airgun/entities/bootc.py | 35 +++++++++++++++++++++++++++++++++++ airgun/session.py | 6 ++++++ airgun/views/bootc.py | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 airgun/entities/bootc.py create mode 100644 airgun/views/bootc.py diff --git a/airgun/entities/bootc.py b/airgun/entities/bootc.py new file mode 100644 index 000000000..8c2e1e74d --- /dev/null +++ b/airgun/entities/bootc.py @@ -0,0 +1,35 @@ +from airgun.entities.base import BaseEntity +from airgun.navigation import NavigateStep, navigator +from airgun.utils import retry_navigation +from airgun.views.bootc import BootedContainerImagesView + + +class BootcEntity(BaseEntity): + endpoint_path = '/booted_container_images' + + def read(self, booted_image_name): + """ + Read the expanded row of a specific booted_image, returns a tuple + with the unexpanded content, and the expanded content + """ + view = self.navigate_to(self, 'All') + self.browser.plugin.ensure_page_safe(timeout='5s') + # Workaround for a current bug with the page + script = "document.querySelector('tbody').remove();" + self.browser.execute_script(script) + view.search(f"bootc_booted_image = {booted_image_name}") + view.table.row(image_name=booted_image_name).expand() + row = view.table.row(image_name=booted_image_name).read() + row_content = view.table.row(image_name=booted_image_name).content.read() + return (row, row_content['table'][0]) + + +@navigator.register(BootcEntity, 'All') +class BootedImagesScreen(NavigateStep): + """Navigate to Booted Container Images screen.""" + + VIEW = BootedContainerImagesView + + @retry_navigation + def step(self, *args, **kwargs): + self.view.menu.select('Content', 'Booted Container Images') diff --git a/airgun/session.py b/airgun/session.py index 9777120a7..fec531ca1 100644 --- a/airgun/session.py +++ b/airgun/session.py @@ -19,6 +19,7 @@ from airgun.entities.architecture import ArchitectureEntity from airgun.entities.audit import AuditEntity from airgun.entities.bookmark import BookmarkEntity +from airgun.entities.bootc import BootcEntity from airgun.entities.capsule import CapsuleEntity from airgun.entities.cloud_insights import CloudInsightsEntity from airgun.entities.cloud_inventory import CloudInventoryEntity @@ -371,6 +372,11 @@ def bookmark(self): """Instance of Bookmark entity.""" return self._open(BookmarkEntity) + @cached_property + def bootc(self): + """Instance of Bootc entity.""" + return self._open(BootcEntity) + @cached_property def capsule(self): """Instance of Capsule entity.""" diff --git a/airgun/views/bootc.py b/airgun/views/bootc.py new file mode 100644 index 000000000..1e8131be6 --- /dev/null +++ b/airgun/views/bootc.py @@ -0,0 +1,33 @@ +from widgetastic.widget import Table, Text, View +from widgetastic_patternfly4.ouia import ExpandableTable + +from airgun.views.common import ( + BaseLoggedInView, + SearchableViewMixinPF4, +) + + +class BootedContainerImagesView(BaseLoggedInView, SearchableViewMixinPF4): + title = Text('.//h1[@data-ouia-component-id="header-text"]') + + # This represents the contents of the expanded table rows + class NestedBootCTable(View): + table = Table( + locator='.//div[@class="pf-c-table__expandable-row-content"]/table', + column_widgets={'Image Digest': Text('./a'), 'Hosts': Text('./a')}, + ) + + # Passing in the nested table as content_view, refer to ExpandableTable docs for info + table = ExpandableTable( + component_id='booted-containers-table', + column_widgets={ + 'Image Name': Text('./a'), + 'Image Digests': Text('./a'), + 'Hosts': Text('./a'), + }, + content_view=NestedBootCTable(), + ) + + @property + def is_displayed(self): + return self.table.is_displayed From bcc81b081ecd857d222688121ff1134420745511 Mon Sep 17 00:00:00 2001 From: Sam Bible Date: Thu, 27 Feb 2025 09:15:47 -0600 Subject: [PATCH 2/2] Clarify which issue the workaround is for --- airgun/entities/bootc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airgun/entities/bootc.py b/airgun/entities/bootc.py index 8c2e1e74d..db1d4e758 100644 --- a/airgun/entities/bootc.py +++ b/airgun/entities/bootc.py @@ -14,7 +14,7 @@ def read(self, booted_image_name): """ view = self.navigate_to(self, 'All') self.browser.plugin.ensure_page_safe(timeout='5s') - # Workaround for a current bug with the page + # Workaround for SAT-31160 script = "document.querySelector('tbody').remove();" self.browser.execute_script(script) view.search(f"bootc_booted_image = {booted_image_name}")