Skip to content

Commit eae5bf5

Browse files
Add view/entity for booted container images page (#1745) (#1752)
* Add view/entity for booted container images page * Clarify which issue the workaround is for (cherry picked from commit 16621d5) Co-authored-by: Samuel Bible <sbible@redhat.com>
1 parent fdb185f commit eae5bf5

File tree

3 files changed

+74
-0
lines changed

3 files changed

+74
-0
lines changed

airgun/entities/bootc.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
from airgun.entities.base import BaseEntity
2+
from airgun.navigation import NavigateStep, navigator
3+
from airgun.utils import retry_navigation
4+
from airgun.views.bootc import BootedContainerImagesView
5+
6+
7+
class BootcEntity(BaseEntity):
8+
endpoint_path = '/booted_container_images'
9+
10+
def read(self, booted_image_name):
11+
"""
12+
Read the expanded row of a specific booted_image, returns a tuple
13+
with the unexpanded content, and the expanded content
14+
"""
15+
view = self.navigate_to(self, 'All')
16+
self.browser.plugin.ensure_page_safe(timeout='5s')
17+
# Workaround for SAT-31160
18+
script = "document.querySelector('tbody').remove();"
19+
self.browser.execute_script(script)
20+
view.search(f"bootc_booted_image = {booted_image_name}")
21+
view.table.row(image_name=booted_image_name).expand()
22+
row = view.table.row(image_name=booted_image_name).read()
23+
row_content = view.table.row(image_name=booted_image_name).content.read()
24+
return (row, row_content['table'][0])
25+
26+
27+
@navigator.register(BootcEntity, 'All')
28+
class BootedImagesScreen(NavigateStep):
29+
"""Navigate to Booted Container Images screen."""
30+
31+
VIEW = BootedContainerImagesView
32+
33+
@retry_navigation
34+
def step(self, *args, **kwargs):
35+
self.view.menu.select('Content', 'Booted Container Images')

airgun/session.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from airgun.entities.architecture import ArchitectureEntity
2020
from airgun.entities.audit import AuditEntity
2121
from airgun.entities.bookmark import BookmarkEntity
22+
from airgun.entities.bootc import BootcEntity
2223
from airgun.entities.capsule import CapsuleEntity
2324
from airgun.entities.cloud_insights import CloudInsightsEntity
2425
from airgun.entities.cloud_inventory import CloudInventoryEntity
@@ -371,6 +372,11 @@ def bookmark(self):
371372
"""Instance of Bookmark entity."""
372373
return self._open(BookmarkEntity)
373374

375+
@cached_property
376+
def bootc(self):
377+
"""Instance of Bootc entity."""
378+
return self._open(BootcEntity)
379+
374380
@cached_property
375381
def capsule(self):
376382
"""Instance of Capsule entity."""

airgun/views/bootc.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from widgetastic.widget import Table, Text, View
2+
from widgetastic_patternfly4.ouia import ExpandableTable
3+
4+
from airgun.views.common import (
5+
BaseLoggedInView,
6+
SearchableViewMixinPF4,
7+
)
8+
9+
10+
class BootedContainerImagesView(BaseLoggedInView, SearchableViewMixinPF4):
11+
title = Text('.//h1[@data-ouia-component-id="header-text"]')
12+
13+
# This represents the contents of the expanded table rows
14+
class NestedBootCTable(View):
15+
table = Table(
16+
locator='.//div[@class="pf-c-table__expandable-row-content"]/table',
17+
column_widgets={'Image Digest': Text('./a'), 'Hosts': Text('./a')},
18+
)
19+
20+
# Passing in the nested table as content_view, refer to ExpandableTable docs for info
21+
table = ExpandableTable(
22+
component_id='booted-containers-table',
23+
column_widgets={
24+
'Image Name': Text('./a'),
25+
'Image Digests': Text('./a'),
26+
'Hosts': Text('./a'),
27+
},
28+
content_view=NestedBootCTable(),
29+
)
30+
31+
@property
32+
def is_displayed(self):
33+
return self.table.is_displayed

0 commit comments

Comments
 (0)