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

CV Publish #948

Merged
merged 14 commits into from
Oct 18, 2023
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
61 changes: 57 additions & 4 deletions airgun/entities/contentview_new.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
from airgun.navigation import NavigateStep, navigator
from airgun.utils import retry_navigation
from airgun.views.contentview_new import (
NewContentViewCreateView,
NewContentViewTableView,
ContentViewCreateView,
ContentViewEditView,
ContentViewTableView,
ContentViewVersionPublishView,
)


Expand All @@ -15,20 +17,40 @@ class NewContentViewEntity(BaseEntity):
def create(self, values):
"""Create a new content view"""
view = self.navigate_to(self, 'New')
self.browser.plugin.ensure_page_safe(timeout='5s')
view.wait_displayed()
view.fill(values)
view.submit.click()

def search(self, value):
"""Search for content view"""
view = self.navigate_to(self, 'All')
self.browser.plugin.ensure_page_safe(timeout='5s')
view.wait_displayed()
return view.search(value)

def publish(self, entity_name, values=None):
"""Publishes new version of CV"""
view = self.navigate_to(self, 'Publish', entity_name=entity_name)
self.browser.plugin.ensure_page_safe(timeout='5s')
view.wait_displayed()
if values:
view.fill(values)
view.next.click()
view.finish.click()
view.progressbar.wait_for_result(delay=0.01)
view = self.navigate_to(self, 'Edit', entity_name=entity_name)
self.browser.plugin.ensure_page_safe(timeout='5s')
view.wait_displayed()
view.versions.table.wait_displayed()
return view.versions.table.read()


@navigator.register(NewContentViewEntity, 'All')
class ShowAllContentViewsScreen(NavigateStep):
"""Navigate to All Content Views screen."""

VIEW = NewContentViewTableView
VIEW = ContentViewTableView

@retry_navigation
def step(self, *args, **kwargs):
Expand All @@ -39,9 +61,40 @@ def step(self, *args, **kwargs):
class CreateContentView(NavigateStep):
"""Navigate to Create content view."""

VIEW = NewContentViewCreateView
VIEW = ContentViewCreateView

prerequisite = NavigateToSibling('All')

def step(self, *args, **kwargs):
self.parent.create_content_view.click()


@navigator.register(NewContentViewEntity, 'Edit')
class EditContentView(NavigateStep):
"""Navigate to Edit Content View screen."""

VIEW = ContentViewEditView

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(entity_name)
self.parent.table.row(name=entity_name)['Name'].widget.click()


@navigator.register(NewContentViewEntity, 'Publish')
class PublishContentViewVersion(NavigateStep):
"""Navigate to Content View Publish screen."""

VIEW = ContentViewVersionPublishView

def prerequisite(self, *args, **kwargs):
"""Open Content View first."""
return self.navigate_to(self.obj, 'Edit', entity_name=kwargs.get('entity_name'))

@retry_navigation
def step(self, *args, **kwargs):
"""Click 'Publish new version' button"""
self.parent.publish.click()
72 changes: 71 additions & 1 deletion airgun/views/common.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import time

import wait_for
from widgetastic.widget import (
Checkbox,
ConditionalSwitchableView,
Expand All @@ -11,7 +14,7 @@
)
from widgetastic_patternfly import BreadCrumb, Button, Tab, TabWithDropdown
from widgetastic_patternfly4.navigation import Navigation
from widgetastic_patternfly4.ouia import Dropdown
from widgetastic_patternfly4.ouia import Button as PF4Button, Dropdown, PatternflyTable

from airgun.utils import get_widget_by_name, normalize_dict_values
from airgun.widgets import (
Expand Down Expand Up @@ -383,6 +386,73 @@ class add_tab(AddTab):
)


class NewAddRemoveResourcesView(View):
searchbox = PF4Search()
type = Dropdown(
locator='.//div[contains(@class, "All repositories") or'
' contains(@aria-haspopup="listbox")]'
)
Status = Dropdown(
locator='.//div[contains(@class, "All") or contains(@aria-haspopup="listbox")]'
)
add_repo = PF4Button('OUIA-Generated-Button-secondary-2')
# Need to add kebab menu
table = PatternflyTable(
component_id='OUIA-Generated-Table-4',
column_widgets={
0: Checkbox(locator='.//input[@type="checkbox"]'),
'Type': Text('.//a'),
'Name': Text('.//a'),
'Product': Text('.//a'),
'Sync State': Text('.//a'),
'Content': Text('.//a'),
'Status': Text('.//a'),
},
)

def search(self, value):
"""Search for specific available resource and return the results"""
self.searchbox.search(value)
# Tried following ways to wait for table to be displayed, only sleep worked
# Might need a before/after fill
wait_for(
lambda: self.table.is_displayed is True,
timeout=60,
delay=1,
)
time.sleep(3)
self.table.wait_displayed()
return self.table.read()

def add(self, value):
"""Associate specific resource"""
self.search(value)
next(self.table.rows())[0].widget.fill(True)
self.add_repo.click()

def fill(self, values):
"""Associate resource(s)"""
if not isinstance(values, list):
values = [
values,
]
for value in values:
self.add(value)

def remove(self, value):
"""Unassign some resource(s).
:param str or list values: string containing resource name or a list of
such strings.
"""
self.search(value)
next(self.table.rows())[0].widget.fill(True)
self.remove_button.click()

def read(self):
"""Read all table values from both resource tables"""
return self.table.read()


class TemplateEditor(View):
"""Default view for template entity editor that can be present for example
on provisioning template of partition table pages. It contains from
Expand Down
Loading
Loading