Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add view/entity for booted container images page #1745

Merged
merged 2 commits into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading