Skip to content

Commit

Permalink
Rework several locators, and change logic for delete entities
Browse files Browse the repository at this point in the history
  • Loading branch information
sambible committed Nov 20, 2023
1 parent acf18ee commit fb7e6af
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
11 changes: 10 additions & 1 deletion airgun/entities/all_hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,17 @@ def delete(self, host_name):
"""Delete host through table dropdown"""
view = self.navigate_to(self, 'All')
self.browser.plugin.ensure_page_safe(timeout='5s')
view.table.wait_displayed()
view.wait_displayed()
view.search(host_name)
view.table[0][2].widget.item_select('Delete')
delete_modal = HostDeleteDialog(self.browser)
if delete_modal.is_displayed:
delete_modal.confirm_delete.click()
view = self.navigate_to(self, 'All')
self.browser.plugin.ensure_page_safe(timeout='5s')
view.wait_displayed()
view.search(host_name)
return view.no_results

def bulk_delete_all(self):
"""Delete multiple hosts through bulk action dropdown"""
Expand All @@ -40,6 +45,10 @@ def bulk_delete_all(self):
if delete_modal.is_displayed:
delete_modal.confirm_checkbox.fill(True)
delete_modal.confirm_delete.click()
view = self.navigate_to(self, 'All')
self.browser.plugin.ensure_page_safe(timeout='5s')
view.wait_displayed()
return view.no_results


@navigator.register(AllHostsEntity, 'All')
Expand Down
23 changes: 14 additions & 9 deletions airgun/views/all_hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class AllHostsTableView(BaseLoggedInView, SearchableViewMixinPF4):
locator='.//input[@data-ouia-component-id="select-all-checkbox-dropdown-toggle-checkbox"]'
)
bulk_actions = Dropdown(locator='.//div[@data-ouia-component-id="action-buttons-dropdown"]')
table_loading = Text("//h5[normalize-space(.)='Loading']")
no_results = Text("//h5[normalize-space(.)='No Results']")
table = PatternflyTable(
component_id='table',
column_widgets={
Expand All @@ -27,18 +29,21 @@ class AllHostsTableView(BaseLoggedInView, SearchableViewMixinPF4):

@property
def is_displayed(self):
return self.browser.wait_for_element(self.table, exception=False) is not None
return (
self.browser.wait_for_element(self.table_loading, exception=False) is None
and self.browser.wait_for_element(self.table, exception=False) is not None
)


class HostDeleteDialog(View):
"""Confirmation dialog for deleting host"""

ROOT = './/div[@data-ouia-component-id="delete-modal"]'
ROOT = './/div[@data-ouia-component-id="app-confirm-modal"]'

title = Text("//span[normalize-space(.)='Confirm Deletion']")
title = Text("//span[normalize-space(.)='Delete host?']")

confirm_delete = Button(locator='.//button[@data-ouia-component-id="confirm-delete"]')
cancel_delete = Button('cancel-delete')
confirm_delete = Button(locator='//button[normalize-space(.)="Delete"]')
cancel_delete = Button(locator='//button[normalize-space(.)="Cancel"]')

@property
def is_displayed(self):
Expand All @@ -48,13 +53,13 @@ def is_displayed(self):
class BulkHostDeleteDialog(View):
"""Confirmation dialog for bulk deleting hosts or hosts with compute resources"""

ROOT = './/div[@data-ouia-component-id="bulk-delete-hosts-modal"]'
ROOT = './/div[@id="bulk-delete-hosts-modal"]'

title = Text("//span[normalize-space(.)='Delete hosts?']")
confirm_checkbox = Checkbox('dire-warning-checkbox')
confirm_checkbox = Checkbox(locator='.//input[@id="dire-warning-checkbox"]')

confirm_delete = Button('btn-modal-confirm')
cancel_delete = Button('btn-modal-cancel')
confirm_delete = Button(locator='//button[normalize-space(.)="Delete"]')
cancel_delete = Button(locator='//button[normalize-space(.)="Cancel"]')

@property
def is_displayed(self):
Expand Down

0 comments on commit fb7e6af

Please sign in to comment.