From 6c4ad188707a0b4ecf0358d793151dbe42347f01 Mon Sep 17 00:00:00 2001 From: David Moore Date: Fri, 12 Jan 2024 12:18:55 -0500 Subject: [PATCH] host_new>content>errata tab pagination Click button to clear searchbar docstring fix --- airgun/entities/host_new.py | 29 ++++++++++++++++++++++++++--- airgun/views/host_new.py | 2 +- airgun/widgets.py | 20 ++++++++++++++++++++ 3 files changed, 47 insertions(+), 4 deletions(-) diff --git a/airgun/entities/host_new.py b/airgun/entities/host_new.py index 109c0c5c8..879552d5a 100644 --- a/airgun/entities/host_new.py +++ b/airgun/entities/host_new.py @@ -299,17 +299,40 @@ def get_errata_by_type(self, entity_name, type): view.content.errata.table.wait_displayed() return view.read(widget_names="content.errata.table") - def apply_erratas(self, entity_name, search): - """Apply errata on selected host based on errata_id""" + def apply_erratas(self, entity_name, search=None): + """Apply available errata on selected host based on searchbar result. + param: search (string): search value to filter results. + example: search="errata_id == {ERRATA_ID}" + default: None; all available errata are returned and installed. + """ view = self.navigate_to(self, 'NewDetails', entity_name=entity_name) view.wait_displayed() - view.content.errata.searchbar.fill(search) + if search is None: + # Return all errata, clear the searchbar + view.content.errata.searchbar.clear() + else: + # Return only errata by search + view.content.errata.searchbar.fill(search) # wait for filter to apply + view.content.errata.wait_displayed() self.browser.plugin.ensure_page_safe() view.content.errata.select_all.click() view.content.errata.apply.fill('Apply') view.flash.assert_no_error() view.flash.dismiss() + # clear the searchbar so any input will not persist + view.content.errata.searchbar.clear() + view.content.errata.wait_displayed() + self.browser.plugin.ensure_page_safe() + + def get_errata_pagination(self, entity_name): + """Get pagination info from Errata tab on selected host.""" + view = self.navigate_to(self, 'NewDetails', entity_name=entity_name) + view.wait_displayed() + view.content.errata.select() + view.content.errata.wait_displayed() + self.browser.plugin.ensure_page_safe() + return view.content.errata.pagination def get_module_streams(self, entity_name, search): """Filter module streams""" diff --git a/airgun/views/host_new.py b/airgun/views/host_new.py index 813cb5a40..4ce54cda7 100644 --- a/airgun/views/host_new.py +++ b/airgun/views/host_new.py @@ -359,7 +359,7 @@ class errata(Tab): 8: Dropdown(locator='./div'), }, ) - pagination = PF4Pagination() + pagination = PF4Pagination("//div[@class = 'pf-c-pagination pf-m-bottom tfm-pagination']") @View.nested class module_streams(Tab): diff --git a/airgun/widgets.py b/airgun/widgets.py index 03867ddc0..10e335c47 100644 --- a/airgun/widgets.py +++ b/airgun/widgets.py @@ -2645,7 +2645,27 @@ def read(self): class SearchInput(TextInput): + """Searchbar's contained input text, and buttons""" + + search_field = TextInput(locator=('//input[@aria-label="Search input"]')) + clear_button = Text(locator=('//button[@aria-label="Reset search"]')) + + def clear(self): + """Clear search input by clicking the clear_button. + Check the clear_button is not present after clicking it. + Return: True if button was present, and clicking it + caused it to disappear. False otherwise. + """ + changed = False + if self.clear_button.is_displayed: + self.clear_button.click() + # after clicking clear button, it should disappear + if not self.clear_button.is_displayed: + changed = True + return changed + def fill(self, value, enter_timeout=1, after_enter_timeout=3): + """Fill the search input with supplied value""" changed = super().fill(value) if changed: # workaround for BZ #2140636