-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for File page in Content section of UI (#1426)
* Add support for File page in Content section of UI * Change Title from H2 to h1 Co-authored-by: Ladislav Vašina <[email protected]> --------- Co-authored-by: Ladislav Vašina <[email protected]>
- Loading branch information
1 parent
676f9d6
commit e488c25
Showing
3 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
from airgun.entities.base import BaseEntity | ||
from airgun.navigation import NavigateStep, navigator | ||
from airgun.utils import retry_navigation | ||
from airgun.views.file import FileDetailsView, FilesView | ||
|
||
|
||
class FilesEntity(BaseEntity): | ||
endpoint_path = '/files' | ||
|
||
def search(self, query): | ||
view = self.navigate_to(self, 'All') | ||
return view.search(query) | ||
|
||
def read(self, entity_name, widget_names=None): | ||
view = self.navigate_to(self, 'Details', entity_name=entity_name) | ||
return view.read(widget_names=widget_names) | ||
|
||
def read_cv_table(self, entity_name): | ||
view = self.navigate_to(self, 'Details', entity_name=entity_name) | ||
return view.content_views.cvtable.read() | ||
|
||
|
||
@navigator.register(FilesEntity, 'All') | ||
class ShowAllFiles(NavigateStep): | ||
"""navigate to Files Page""" | ||
|
||
VIEW = FilesView | ||
|
||
@retry_navigation | ||
def step(self, *args, **kwargs): | ||
self.view.menu.select('Content', 'Content Types', 'Files') | ||
|
||
|
||
@navigator.register(FilesEntity, 'Details') | ||
class ShowPackageDetails(NavigateStep): | ||
"""Navigate to File Details page by clicking on file name""" | ||
|
||
VIEW = FileDetailsView | ||
|
||
def prerequisite(self, *args, **kwargs): | ||
return self.navigate_to(self.obj, 'All') | ||
|
||
def step(self, *args, **kwargs): | ||
entity_name = kwargs.get('entity_name') | ||
self.parent.search(f'name = {entity_name}') | ||
self.parent.table.row(name=entity_name)['Name'].widget.click() | ||
|
||
def am_i_here(self, *args, **kwargs): | ||
entity_name = kwargs.get('entity_name') | ||
self.view.file_name = entity_name | ||
return self.view.is_displayed and self.view.breadcrumb.locations[1] == entity_name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from widgetastic.widget import Text, View | ||
from widgetastic_patternfly import BreadCrumb | ||
|
||
from airgun.views.common import ( | ||
BaseLoggedInView, | ||
ReadOnlyEntry, | ||
SatTab, | ||
SatTable, | ||
) | ||
from airgun.widgets import Search | ||
|
||
|
||
class FilesView(BaseLoggedInView): | ||
"""Main Files view""" | ||
|
||
title = Text("//h1[contains(., 'Files')]") | ||
table = SatTable('.//table', column_widgets={'Name': Text("./a"), 'Path': Text("./a")}) | ||
|
||
search_box = Search() | ||
|
||
def search(self, query): | ||
self.search_box.search(query) | ||
return self.table.read() | ||
|
||
@property | ||
def is_displayed(self): | ||
return self.browser.wait_for_element(self.title, exception=False) is not None | ||
|
||
|
||
class FileDetailsView(BaseLoggedInView): | ||
breadcrumb = BreadCrumb() | ||
|
||
@property | ||
def is_displayed(self): | ||
breadcrumb_loaded = self.browser.wait_for_element(self.breadcrumb, exception=False) | ||
|
||
return breadcrumb_loaded and self.breadcrumb.locations[0] == 'Files' | ||
|
||
@View.nested | ||
class details(SatTab): | ||
path = ReadOnlyEntry(name='Checksum') | ||
checksum = ReadOnlyEntry(name='Path') | ||
|
||
@View.nested | ||
class content_views(SatTab): | ||
TAB_NAME = 'Content Views' | ||
cvtable = SatTable( | ||
'.//table', | ||
column_widgets={ | ||
'Name': Text("./a"), | ||
'Environment': Text("./a"), | ||
'Version': Text("./a"), | ||
}, | ||
) |