Skip to content

Commit

Permalink
add/update host_new entities & views (#1300) (#1314)
Browse files Browse the repository at this point in the history
  • Loading branch information
Satellite-QE authored Apr 8, 2024
1 parent 1fbe9cc commit 53b0b90
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
31 changes: 29 additions & 2 deletions airgun/entities/host_new.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand All @@ -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()
Expand Down
10 changes: 8 additions & 2 deletions airgun/views/host_new.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')},
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 53b0b90

Please sign in to comment.