Skip to content
This repository has been archived by the owner on Apr 7, 2022. It is now read-only.

Commit

Permalink
Merge pull request #9981 from niyazRedhat/dialog-copy
Browse files Browse the repository at this point in the history
[1LP][RFR] Fixing is_displayed for service dialog
  • Loading branch information
mshriver authored Mar 13, 2020
2 parents c63598e + f4e03d3 commit 0ab8391
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 4 deletions.
46 changes: 42 additions & 4 deletions cfme/automate/dialogs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,16 @@ class AddDialogView(DialogForm):

@property
def is_displayed(self):
expected_title = (
"Automate Customization"
if self.browser.product_version < "5.11"
else "Add a new Dialog"
)
return (
self.in_customization and self.title.text == "Automate Customization" and
self.sub_title.text == "General" and self.create_tab.is_displayed
self.in_customization
and self.title.text == expected_title
and self.sub_title.text == "General"
and self.create_tab.is_displayed
)


Expand All @@ -60,9 +67,40 @@ class EditDialogView(DialogForm):

@property
def is_displayed(self):
obj = self.context["object"]

expected_title = (
"Automate Customization"
if self.browser.product_version < "5.11"
else 'Editing {} Service Dialog'.format(obj.label)
)
return (
self.in_customization
and self.title.text == expected_title
and self.sub_title.text == "General"
and self.label.read() == obj.label
)


class CopyDialogView(DialogForm):
save_button = Button('Save')
cancel_button = Button('Cancel')

@property
def is_displayed(self):
obj = self.context["object"]
expected_label = 'Copy of {}'.format(obj.label)

expected_title = (
"Automate Customization"
if self.browser.product_version < "5.11"
else 'Editing {} Service Dialog'.format(obj.label)
)
return (
self.in_customization and self.title.text == "Automate Customization" and
self.sub_title.text == "General" and self.label.read() == self.context['object'].label
self.in_customization
and self.title.text == expected_title
and self.sub_title.text == "General"
and self.label.read() == expected_label
)


Expand Down
19 changes: 19 additions & 0 deletions cfme/automate/dialogs/service_dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from cfme.automate.dialogs import AddDialogView
from cfme.automate.dialogs import AutomateCustomizationView
from cfme.automate.dialogs import CopyDialogView
from cfme.automate.dialogs import EditDialogView
from cfme.automate.dialogs.dialog_tab import TabCollection
from cfme.exceptions import RestLookupError
Expand Down Expand Up @@ -90,6 +91,15 @@ def delete(self):
view.flash.assert_success_message(
'Dialog "{}": Delete successful'.format(self.label))

def copy(self):
view = navigate_to(self, "Copy")
view.save_button.click()
view = self.create_view(DetailsDialogView)
view.flash.assert_success_message(f'Copy of {self.label} was saved')
view.flash.wait_displayed(timeout=20)
assert view.is_displayed
view.flash.assert_no_error

@property
def rest_api_entity(self):
try:
Expand Down Expand Up @@ -153,3 +163,12 @@ class Edit(CFMENavigateStep):

def step(self, *args, **kwargs):
self.prerequisite_view.configuration.item_select("Edit this Dialog")


@navigator.register(Dialog)
class Copy(CFMENavigateStep):
VIEW = CopyDialogView
prerequisite = NavigateToSibling('Details')

def step(self, *args, **kwargs):
self.prerequisite_view.configuration.item_select('Copy this Dialog')

0 comments on commit 0ab8391

Please sign in to comment.