Skip to content

Commit

Permalink
Add view/entity for booted container images page (#1745)
Browse files Browse the repository at this point in the history
* Add view/entity for booted container images page

* Clarify which issue the workaround is for
  • Loading branch information
sambible authored Feb 27, 2025
1 parent 27637fc commit 16621d5
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 0 deletions.
35 changes: 35 additions & 0 deletions airgun/entities/bootc.py
Original file line number Diff line number Diff line change
@@ -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 SAT-31160
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')
6 changes: 6 additions & 0 deletions airgun/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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."""
Expand Down
33 changes: 33 additions & 0 deletions airgun/views/bootc.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 16621d5

Please sign in to comment.