diff --git a/airgun/entities/host_new.py b/airgun/entities/host_new.py index 9536174f7..af1442681 100644 --- a/airgun/entities/host_new.py +++ b/airgun/entities/host_new.py @@ -1,11 +1,13 @@ import time from navmazing import NavigateToSibling +from wait_for import wait_for from airgun.entities.host import HostEntity from airgun.navigation import NavigateStep, navigator from airgun.views.host_new import ( AllAssignedRolesView, + EditAnsibleRolesView, EditSystemPurposeView, EnableTracerView, InstallPackagesView, @@ -41,8 +43,7 @@ def get_details(self, entity_name, widget_names=None): view = self.navigate_to(self, 'NewDetails', entity_name=entity_name) view.wait_displayed() self.browser.plugin.ensure_page_safe() - # Run this read twice to navigate to the page and load it before reading - view.read(widget_names=widget_names) + wait_for(lambda: view.ansible.roles.noRoleAssign.is_displayed, timeout=5) return view.read(widget_names=widget_names) def get_host_statuses(self, entity_name): @@ -367,10 +368,24 @@ def bulk_override_repo_sets(self, entity_name, repo_type, action): view.flash.assert_no_error() view.flash.dismiss() + def add_single_ansible_role(self, entity_name): + view = self.navigate_to(self, 'NewDetails', entity_name=entity_name) + view.wait_displayed() + self.browser.plugin.ensure_page_safe() + wait_for(lambda: view.ansible.roles.edit.is_displayed, timeout=5) + view.ansible.roles.edit.click() + wait_for(lambda: EditAnsibleRolesView(self.browser).addAnsibleRole.is_displayed, timeout=5) + edit_view = EditAnsibleRolesView(self.browser) + actions = [edit_view.addAnsibleRole, edit_view.selectRoles, edit_view.confirm] + for action in actions: + wait_for(lambda: edit_view.is_displayed, timeout=5) + action.click() + def get_ansible_roles(self, entity_name): view = self.navigate_to(self, 'NewDetails', entity_name=entity_name) view.wait_displayed() self.browser.plugin.ensure_page_safe() + wait_for(lambda: view.ansible.roles.is_displayed, timeout=5) return view.ansible.roles.table.read() def get_ansible_roles_modal(self, entity_name): @@ -383,6 +398,18 @@ def get_ansible_roles_modal(self, entity_name): self.browser.plugin.ensure_page_safe() return view.table.read() + def remove_ansible_role(self, entity_name): + view = self.navigate_to(self, 'NewDetails', entity_name=entity_name) + view.wait_displayed() + self.browser.plugin.ensure_page_safe() + view.ansible.roles.edit.click() + wait_for(lambda: view.ansible.roles.edit.click(), timeout=5) + edit_role = EditAnsibleRolesView(self.browser) + actions = [edit_role.hostAssignedAnsibleRoles, edit_role.unselectRoles, edit_role.confirm] + for action in actions: + wait_for(lambda: edit_role.is_displayed, timeout=5) + action.click() + def enable_tracer(self, entity_name): view = self.navigate_to(self, 'NewDetails', entity_name=entity_name) view.wait_displayed() diff --git a/airgun/views/host_new.py b/airgun/views/host_new.py index 950702327..c141cb284 100644 --- a/airgun/views/host_new.py +++ b/airgun/views/host_new.py @@ -492,6 +492,7 @@ class roles(Tab): assignedRoles = Text('.//a[contains(@href, "roles/all")]') edit = Button(locator='.//button[@aria-label="edit ansible roles"]') + noRoleAssign = Text('.//h5[contains(@class, "pf-c-title pf-m-4xl")]') table = Table( locator='.//table[contains(@class, "pf-c-table")]', column_widgets={'Name': Text('.//a')}, @@ -790,8 +791,13 @@ def read(self): class EditAnsibleRolesView(View): """Edit Ansible Roles Modal""" - ROOT = '' - # No current representation for this Widget in Widgetastic + addAnsibleRole = Text('.//span[contains(text(),"RedHatInsights.insights-client")]') + confirm = Button(locator='.//button[@aria-label="submit ansible roles"]') + hostAssignedAnsibleRoles = Text( + './/button[@class="pf-c-dual-list-selector__item"]/span[1]//span[2]' + ) + selectRoles = Button(locator='.//button[@aria-label="Add selected"]') + unselectRoles = Button(locator='.//button[@aria-label="Remove selected"]') class ModuleStreamDialog(Pf4ConfirmationDialog):