Skip to content

Commit

Permalink
New Host UI Ansible Work (#717)
Browse files Browse the repository at this point in the history
* Add view for all but variables tab

* Update to some ROOT variables, and attempts to make test work

* Rework lots of stuff, get first test passing
  • Loading branch information
sambible authored Feb 27, 2023
1 parent da4f3d7 commit 00f7d54
Show file tree
Hide file tree
Showing 2 changed files with 164 additions and 3 deletions.
31 changes: 31 additions & 0 deletions airgun/entities/host_new.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from navmazing import NavigateToSibling

from airgun.entities.host import HostEntity
from airgun.navigation import NavigateStep
from airgun.navigation import navigator
from airgun.views.host_new import AllAssignedRolesView
from airgun.views.host_new import InstallPackagesView
from airgun.views.host_new import ModuleStreamDialog
from airgun.views.host_new import NewHostDetailsView
Expand Down Expand Up @@ -140,6 +143,22 @@ def override_repo_sets(self, entity_name, repo_set, action):
view.flash.assert_no_error()
view.flash.dismiss()

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()
return view.ansible.roles.table.read()

def get_ansible_roles_modal(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.assignedRoles.click()
view = AllAssignedRolesView(self.browser)
view.wait_displayed()
self.browser.plugin.ensure_page_safe()
return view.table.read()


@navigator.register(NewHostEntity, 'NewDetails')
class ShowNewHostDetails(NavigateStep):
Expand All @@ -158,3 +177,15 @@ 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(NewHostEntity, 'AnsibleTab')
class ShowNewHostAnsible(NavigateStep):
"""Navigate to the Ansible Tab of Host Details by clicking on the subtab"""

VIEW = NewHostDetailsView

prerequisite = NavigateToSibling('NewDetails')

def step(self, *args, **kwargs):
print(self.parent.rolesListTable)
136 changes: 133 additions & 3 deletions airgun/views/host_new.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,12 +254,117 @@ class traces(Tab):
enable_traces = OUIAButton('OUIA-Generated-Button-primary-1')

@View.nested
class ansible(Tab):
class insights(Tab):
pass

@View.nested
class insights(Tab):
pass
class ansible(Tab):
"""View comprising the subtabs under the Ansible Tab"""

ROOT = './/div'

@View.nested
class roles(Tab):
TAB_NAME = 'Roles'
ROOT = './/div[@class="ansible-host-detail"]'

assignedRoles = Text('.//a[contains(@href, "roles/all")]')
edit = Button(locator='.//button[@aria-label="edit ansible roles"]')
table = Table(
locator='.//table[contains(@class, "pf-c-table")]',
column_widgets={'Name': Text('.//a')},
)
pagination = Pagination()

@View.nested
class variables(Tab):
TAB_NAME = 'Variables'
ROOT = './/div[@class="ansible-host-detail"]'
table = Table(
locator='.//table[contains(@class, "pf-c-table")]',
column_widgets={
'Name': Text('.//a'),
'Ansible role': Text('./span'),
'Type': Text('./span'),
# the next field can also be a form group
'Value': Text('./span'),
'Source attribute': Text('./span'),
# The next 2 buttons are hidden by default, but appear in this order
5: Button(locator='.//button[@aria-label="Cancel editing override button"]'),
6: Button(locator='.//button[@aria-label="Submit override button"]'),
# Clicking this button hides it, and displays the previous 2
7: Button(locator='.//button[@aria-label="Edit override button"]'),
},
)
pagination = Pagination()

@View.nested
class inventory(Tab):
TAB_NAME = 'Inventory'
ROOT = './/div[@class="ansible-host-detail"]'

@View.nested
class jobs(Tab):
TAB_NAME = 'Jobs'
ROOT = './/div[@class="ansible-host-detail"]'

@property
def is_displayed(self):
return (
self.schedule.is_displayed
or self.jobs.is_displayed
or self.previous.is_displayed
)

@View.nested
class schedule(Tab):
# Only displays when there isn't a Job scheduled for this host
scheduleRecurringJob = Button(
locator='.//button[@aria-label="schedule recurring job"]'
)

@property
def is_displayed(self):
return self.scheduleRecurringJob.is_displayed

@View.nested
class jobs(Tab):
# Mutually Exclusive with the above button
scheduledText = './/h3[text()="Scheduled recurring jobs"]'
scheduledJobsTable = Table(
locator='.//div[contains(@class, "pf-c-table)"]',
column_widgets={
'Description': Text('.//a'),
'Schedule': Text('./span'),
'Next Run': Text('./span'),
4: Dropdown(locator='.//div[contains(@class, "pf-c-dropdown")]'),
},
)
pagination = Pagination()

@property
def is_displayed(self):
return self.scheduledText.is_displayed

@View.nested
class previous(Tab):
# Only displayed on Refresh when there are previously executed jobs
previousText = './/h3[text()="Previously executed jobs"]'
previousJobsTable = Table(
locator='',
column_widgets={
'Description': Text('.//a'),
'Result': Text('./span'),
'State': Text('./span'),
'Executed at': Text('./span'),
'Schedule': Text('./span'),
},
)
pagination = Pagination()

@property
def is_displayed(self):
return self.previousText.is_displayed


class InstallPackagesView(View):
Expand All @@ -284,7 +389,32 @@ class InstallPackagesView(View):
cancel = Button('Cancel')


class AllAssignedRolesView(View):
"""All Assigned Roles Modal"""

ROOT = './/div[@data-ouia-component-id="modal-ansible-roles"]'

table = Table(
locator='.//table[contains(@class, "pf-c-table")]',
column_widgets={'Name': Text('.//a'), 'Source': Text('.//a')},
)
pagination = Pagination()


class EditAnsibleRolesView(View):
"""Edit Ansible Roles Modal"""

ROOT = ''
# No current representation for this Widget in Widgetastic


class ModuleStreamDialog(Pf4ConfirmationDialog):

confirm_dialog = Button(locator='.//button[@aria-label="confirm-module-action"]')
cancel_dialog = Button(locator='.//button[@aria-label="cancel-module-action"]')


class RecurringJobDialog(Pf4ConfirmationDialog):

confirm_dialog = Button(locator='.//button[@data-ouia-component-id="btn-modal-confirm"]')
cancel_dialog = Button(locator='.//button[@data-ouia-component-id="btn-modal-cancel"]')

0 comments on commit 00f7d54

Please sign in to comment.