diff --git a/airgun/entities/contentview_new.py b/airgun/entities/contentview_new.py index a27987aca..0194e9c6f 100644 --- a/airgun/entities/contentview_new.py +++ b/airgun/entities/contentview_new.py @@ -39,6 +39,9 @@ def search(self, value): view = self.navigate_to(self, 'All') self.browser.plugin.ensure_page_safe(timeout='5s') view.wait_displayed() + if not view.table.is_displayed: + # no table present, no CVs in this Org + return None return view.search(value) def publish(self, entity_name, values=None, promote=False, lce=None): @@ -60,6 +63,45 @@ def publish(self, entity_name, values=None, promote=False, lce=None): view.wait_displayed() return view.versions.table.read() + def delete(self, entity_name): + """Deletes the content view by name""" + view = self.navigate_to(self, 'Edit', entity_name=entity_name) + self.browser.plugin.ensure_page_safe(timeout='5s') + view.wait_displayed() + # click the 'cv-details-action' dropdown, then click 'Delete' + view.cv_actions.click() + view.cv_delete.click() + view.wait_displayed() + # Remove from environment(s) wizard, if it appears + if view.next_button.is_displayed: + view.next_button.click() + view.delete_finish.click() + + def delete_version(self, entity_name, version): + """Deletes the specified version of the content view + :return: bool + True if specified version was found and clicked 'Delete' + False (default) if not found in table by version name + """ + result = False + view = self.navigate_to( + self, + 'Version', + entity_name=entity_name, + version=version, + timeout=60, + ) + time.sleep(5) # 'Loading' widget on page + self.browser.plugin.ensure_page_safe(timeout='10s') + wait_for(lambda: view.table.is_displayed, timeout=20) + result = view.version_dropdown.item_select('Delete') + view.wait_displayed() + # Remove from environment(s) wizard, if it appears + if view.next_button.is_displayed: + view.next_button.click() + view.delete_finish.click() + return result + def add_content(self, entity_name, content_name): """Add specified content to the given Content View""" view = self.navigate_to(self, 'Edit', entity_name=entity_name) @@ -102,9 +144,15 @@ def read_repositories(self, entity_name): def read_version_table(self, entity_name, version, tab_name, search_param=None): """Reads a specific table for a CV Version""" - view = self.navigate_to(self, 'Version', entity_name=entity_name, version=version) + view = self.navigate_to( + self, + 'Version', + entity_name=entity_name, + version=version, + timeout=60, + ) + time.sleep(5) self.browser.plugin.ensure_page_safe(timeout='5s') - view.wait_displayed() # This allows dynamic access to the proper table wait_for(lambda: getattr(view, tab_name).table.wait_displayed(), timeout=10) if search_param: @@ -265,7 +313,9 @@ def prerequisite(self, *args, **kwargs): def step(self, *args, **kwargs): version = kwargs.get('version') + self.parent.versions.wait_displayed() self.parent.versions.search(version) + self.parent.versions.table.wait_displayed() self.parent.versions.table.row(version=version)['Version'].widget.click() @@ -280,10 +330,11 @@ class PublishContentViewVersion(NavigateStep): def prerequisite(self, *args, **kwargs): """Open Content View first.""" - return self.navigate_to(self.obj, 'Edit', entity_name=kwargs.get('entity_name')) + return self.navigate_to(self.obj, 'Edit', entity_name=kwargs.get('entity_name'), timeout=20) def step(self, *args, **kwargs): """Click 'Publish new version' button""" + self.parent.publish.wait_displayed() self.parent.publish.click() @@ -302,5 +353,7 @@ def prerequisite(self, *args, **kwargs): def step(self, *args, **kwargs): version_name = kwargs.get('version_name') + self.parent.versions.wait_displayed() self.parent.versions.search(version_name) + self.parent.version.table.wait_displayed() self.parent.versions.table[0][7].widget.item_select('Promote') diff --git a/airgun/views/contentview_new.py b/airgun/views/contentview_new.py index 2d36608ed..19dddc80f 100644 --- a/airgun/views/contentview_new.py +++ b/airgun/views/contentview_new.py @@ -111,9 +111,19 @@ def after_fill(self, value): class ContentViewEditView(BaseLoggedInView): breadcrumb = BreadCrumb('breadcrumbs-list') search = PF4Search() - actions = ActionsDropdown(".//button[contains(@id, 'toggle-dropdown')]") - publish = PF4Button('cv-details-publish-button') dialog = ConfirmationDialog() + publish = PF4Button('cv-details-publish-button') + # click the cv_actions dropdown, then click copy or delete + cv_actions = ActionsDropdown('//div[@data-ouia-component-id="cv-details-actions"]') + cv_copy = Text('//a[@data-ouia-component-id="cv-copy"]') + cv_delete = Text('//a[@data-ouia-component-id="cv-delete"]') + + # buttons for wizard: deleting a CV with Version promoted to environment(s) + next_button = Button('Next') + delete_finish = Button('Delete') + back_button = Button('Back') + cancel_button = Button('Cancel') + close_button = Button('Close') @property def is_displayed(self): @@ -252,12 +262,22 @@ class ContentViewVersionPromoteView(Modal): class ContentViewVersionDetailsView(BaseLoggedInView): breadcrumb = BreadCrumb() version = Text(locator='.//h2[@data-ouia-component-id="cv-version"]') + version_dropdown = Dropdown( + locator='.//div[@data-ouia-component-id="cv-version-header-actions-dropdown"]' + ) promoteButton = PF4Button( locator='.//button[@data-ouia-component-id="cv-details-publish-button"]' ) editDescription = PF4Button( locator='.//button[@data-ouia-component-id="edit-button-description"]' ) + # buttons for wizard: deleting a version promoted to environment(s) + next_button = Button('Next') + delete_finish = Button('Delete') + back_button = Button('Back') + cancel_button = Button('Cancel') + close_button = Button('Close') + progressbar = PF4ProgressBar('.//div[contains(@class, "pf-c-wizard__main-body")]') @View.nested class repositories(Tab):