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

No blank cv/french view #991

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
79 changes: 73 additions & 6 deletions airgun/entities/contentview_new.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from navmazing import NavigateToSibling
from wait_for import wait_for

from airgun.entities.base import BaseEntity
from airgun.navigation import NavigateStep, navigator
from airgun.utils import retry_navigation
from airgun.views.contentview_new import (
NewContentViewCreateView,
NewContentViewTableView,
)
from airgun.views.contentview_new import ContentViewCreateView
from airgun.views.contentview_new import ContentViewTableView
from airgun.views.contentview_new import ContentViewEditView
from airgun.views.contentview_new import ContentViewVersionPublishView


class NewContentViewEntity(BaseEntity):
Expand All @@ -23,25 +24,91 @@ def search(self, value):
view = self.navigate_to(self, 'All')
return view.search(value)

def publish(self, entity_name, values=None):
"""Publishes to create new version of CV and promotes the contents to
'Library' environment.
:return: dict with new content view version table row; contains keys
like 'Version', 'Status', 'Environments' etc.
"""
view = self.navigate_to(self, 'Publish', entity_name=entity_name)
if values:
view.fill(values)
view.next.click()
view.finish.click()
view.progressbar.wait_for_result()
view = self.navigate_to(self, 'Edit', entity_name=entity_name)
return view.versions.table.read()

def check_if_blank_in_french(self):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather name this differently read_french_lang(), here you are not checking this could be part of the test.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. This is just a read in french without any assertion.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yeah, that does make more sense. good suggestion!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sambible Good to add doc string which would describe functionality

view = self.navigate_to(self, 'French')
return view.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):
self.view.menu.select('Content', 'Lifecycle', 'Content Views')


@navigator.register(NewContentViewEntity, 'French')
sambible marked this conversation as resolved.
Show resolved Hide resolved
class ShowAllContentViewsScreenFrench(NavigateStep):
"""Navigate to All Content Views screen ( in French )"""

VIEW = ContentViewTableView

@retry_navigation
def step(self, *args, **kwargs):
self.view.menu.select('Contenu', 'Lifecycle', 'Content Views')
sambible marked this conversation as resolved.
Show resolved Hide resolved


@navigator.register(NewContentViewEntity, 'New')
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.
Args:
entity_name: name of content view
"""

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.
Args:
entity_name: name of content view
"""

VIEW = ContentViewVersionPublishView

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

def step(self, *args, **kwargs):
"""Click 'Publish new version' button"""
self.parent.publish.click()

68 changes: 68 additions & 0 deletions airgun/views/common.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import time
from widgetastic.widget import (
Checkbox,
ConditionalSwitchableView,
Expand All @@ -12,6 +13,8 @@
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 PatternflyTable
from widgetastic_patternfly4.ouia import Button as PF4Button

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


class NewAddRemoveResourcesView(View):
Copy link
Contributor

@vijaysawant vijaysawant Oct 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add doc string for a class which would help to understand added functionality.

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')
sambible marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These "generated" locators may not be very stable, is there any alternative, like label?

# Need to add kebab menu
table = PatternflyTable(
component_id='OUIA-Generated-Table-4',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same, can you use some better locator?

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)
sambible marked this conversation as resolved.
Show resolved Hide resolved
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 = list((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