From d06ef2bfe797cb13b917fce42819e0b58858666e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maty=C3=A1=C5=A1=20Strelec?= Date: Thu, 9 Nov 2023 19:01:47 +0100 Subject: [PATCH] Pagination refactor (#947) * update views to use Widgetastic's PF4 Pagination * rename to PF4Pagination * fix SatTable locator * add Pagination to location for testing * pre-commit --- airgun/views/ansible_role.py | 18 +++++++------- airgun/views/ansible_variable.py | 3 +-- airgun/views/cloud_insights.py | 4 ++-- airgun/views/filter.py | 4 ++-- airgun/views/host_new.py | 40 ++++++++++++++++++-------------- airgun/views/location.py | 2 ++ airgun/views/task.py | 2 -- airgun/widgets.py | 11 ++++----- 8 files changed, 43 insertions(+), 41 deletions(-) diff --git a/airgun/views/ansible_role.py b/airgun/views/ansible_role.py index fcb524db9..8f6729196 100644 --- a/airgun/views/ansible_role.py +++ b/airgun/views/ansible_role.py @@ -1,14 +1,14 @@ from widgetastic.widget import Checkbox, Table, Text from widgetastic_patternfly import BreadCrumb -from widgetastic_patternfly4 import Button, PatternflyTable +from widgetastic_patternfly4 import ( + Button, + CompactPagination, + Pagination as PF4Pagination, + PatternflyTable, +) from airgun.views.common import BaseLoggedInView, SearchableViewMixin -from airgun.widgets import ActionsDropdown, Pagination - - -class ImportPagination(Pagination): - PER_PAGE_BUTTON_DROPDOWN = ".//div[button[@id='pagination-options-menu-toggle-2']]" - total_items = Text("//span[@class='pf-c-optionsmenu__toggle-text']/b[2]") +from airgun.widgets import ActionsDropdown class AnsibleRolesView(BaseLoggedInView, SearchableViewMixin): @@ -26,7 +26,7 @@ class AnsibleRolesView(BaseLoggedInView, SearchableViewMixin): 'Actions': ActionsDropdown("./div[contains(@class, 'btn-group')]"), }, ) - pagination = Pagination() + pagination = PF4Pagination() @property def is_displayed(self): @@ -45,7 +45,7 @@ class AnsibleRolesImportView(BaseLoggedInView): 0: Checkbox(locator='.//input[@type="checkbox"]'), }, ) - pagination = ImportPagination() + pagination = CompactPagination() submit = Button('Submit') cancel = Button('Cancel') diff --git a/airgun/views/ansible_variable.py b/airgun/views/ansible_variable.py index 2b23f0afe..7a24d8f3e 100644 --- a/airgun/views/ansible_variable.py +++ b/airgun/views/ansible_variable.py @@ -2,7 +2,7 @@ from widgetastic_patternfly import BreadCrumb from airgun.views.common import BaseLoggedInView, SatTable, SearchableViewMixinPF4 -from airgun.widgets import CustomParameter, FilteredDropdown, Pagination, SatSelect +from airgun.widgets import CustomParameter, FilteredDropdown, SatSelect class AnsibleVariablesView(BaseLoggedInView, SearchableViewMixinPF4): @@ -17,7 +17,6 @@ class AnsibleVariablesView(BaseLoggedInView, SearchableViewMixinPF4): 'Actions': Text(".//a[@data-method='delete']"), }, ) - pagination = Pagination() @property def is_displayed(self): diff --git a/airgun/views/cloud_insights.py b/airgun/views/cloud_insights.py index 88d66c8eb..71fb3db51 100644 --- a/airgun/views/cloud_insights.py +++ b/airgun/views/cloud_insights.py @@ -1,5 +1,5 @@ from widgetastic.widget import Checkbox, Text, TextInput, View -from widgetastic_patternfly4 import Button, Pagination +from widgetastic_patternfly4 import Button, Pagination as PF4Pagination from widgetastic_patternfly4.dropdown import Dropdown from widgetastic_patternfly4.ouia import Modal, PatternflyTable, Switch @@ -58,7 +58,7 @@ class CloudInsightsView(BaseLoggedInView, SearchableViewMixinPF4): ) select_all_hits = Button('Select recommendations from all pages') clear_hits_selection = Button('Clear Selection') - pagination = Pagination() + pagination = PF4Pagination() remediation_window = View.nested(RemediationView) @property diff --git a/airgun/views/filter.py b/airgun/views/filter.py index b955ae348..20985c018 100644 --- a/airgun/views/filter.py +++ b/airgun/views/filter.py @@ -7,13 +7,13 @@ View, ) from widgetastic_patternfly import BreadCrumb +from widgetastic_patternfly4 import Pagination as PF4Pagination from airgun.views.common import BaseLoggedInView, SatTab from airgun.widgets import ( ActionsDropdown, FilteredDropdown, MultiSelect, - Pagination, Search, ) @@ -28,7 +28,7 @@ class FiltersView(BaseLoggedInView): 'Actions': ActionsDropdown("./div[contains(@class, 'btn-group')]"), }, ) - pagination = Pagination() + pagination = PF4Pagination() @property def is_displayed(self): diff --git a/airgun/views/host_new.py b/airgun/views/host_new.py index fb96d4e63..e5dfbb553 100644 --- a/airgun/views/host_new.py +++ b/airgun/views/host_new.py @@ -3,7 +3,13 @@ from selenium.webdriver.common.keys import Keys from widgetastic.widget import Checkbox, Text, TextInput, View, Widget from widgetastic.widget.table import Table -from widgetastic_patternfly4 import Button, Dropdown, Pagination, Select, Tab +from widgetastic_patternfly4 import ( + Button, + Dropdown, + Pagination as PF4Pagination, + Select, + Tab, +) from widgetastic_patternfly4.ouia import ( BreadCrumb, Button as OUIAButton, @@ -364,7 +370,7 @@ class packages(Tab): 5: Dropdown(locator='.//div[contains(@class, "pf-c-dropdown")]'), }, ) - pagination = Pagination() + pagination = PF4Pagination() @View.nested class errata(Tab): @@ -391,7 +397,7 @@ class errata(Tab): 8: Dropdown(locator='./div'), }, ) - pagination = Pagination() + pagination = PF4Pagination() @View.nested class module_streams(Tab): @@ -417,7 +423,7 @@ class module_streams(Tab): 5: DropdownWithDescripton(locator='.//div[contains(@class, "pf-c-dropdown")]'), }, ) - pagination = Pagination() + pagination = PF4Pagination() @View.nested class repository_sets(Tab): @@ -447,7 +453,7 @@ class repository_sets(Tab): 5: Dropdown(locator='.//div[contains(@class, "pf-c-dropdown")]'), }, ) - pagination = Pagination() + pagination = PF4Pagination() @View.nested class parameters(Tab): @@ -482,7 +488,7 @@ class parameters(Tab): 5: Dropdown(locator='.//div[contains(@class, "pf-c-dropdown")]'), }, ) - pagination = Pagination() + pagination = PF4Pagination() @View.nested class traces(Tab): @@ -505,7 +511,7 @@ class traces(Tab): 4: Button(locator='.//button[contains(@aria-label, "Actions")]'), }, ) - pagination = Pagination() + pagination = PF4Pagination() @View.nested class ansible(Tab): @@ -524,7 +530,7 @@ class roles(Tab): locator='.//table[contains(@class, "pf-c-table")]', column_widgets={'Name': Text('.//a')}, ) - pagination = Pagination() + pagination = PF4Pagination() @View.nested class variables(Tab): @@ -546,7 +552,7 @@ class variables(Tab): 7: Button(locator='.//button[@aria-label="Edit override button"]'), }, ) - pagination = Pagination() + pagination = PF4Pagination() @View.nested class inventory(Tab): @@ -590,7 +596,7 @@ class jobs(Tab): 4: Dropdown(locator='.//div[contains(@class, "pf-c-dropdown")]'), }, ) - pagination = Pagination() + pagination = PF4Pagination() @property def is_displayed(self): @@ -610,7 +616,7 @@ class previous(Tab): 'Schedule': Text('./span'), }, ) - pagination = Pagination() + pagination = PF4Pagination() @property def is_displayed(self): @@ -634,7 +640,7 @@ class puppet(Tab): 7: Button(locator='.//button[contains(@aria-label, "Actions")]'), }, ) - pagination = Pagination() + pagination = PF4Pagination() @View.nested class enc_preview(Tab): @@ -675,7 +681,7 @@ class reports(Tab): }, ) - pagination = Pagination() + pagination = PF4Pagination() @View.nested class insights(Tab): @@ -700,7 +706,7 @@ class insights(Tab): 4: Button(locator='.//button[contains(@aria-label, "Actions")]'), }, ) - pagination = Pagination() + pagination = PF4Pagination() class InstallPackagesView(View): @@ -719,7 +725,7 @@ class InstallPackagesView(View): 'Version': Text('./parent::td'), }, ) - pagination = Pagination() + pagination = PF4Pagination() install = Button(locator='.//button[(normalize-space(.)="Install")]') cancel = Button('Cancel') @@ -734,7 +740,7 @@ class AllAssignedRolesView(View): locator='.//table[contains(@class, "pf-c-table")]', column_widgets={'Name': Text('.//a'), 'Source': Text('.//a')}, ) - pagination = Pagination() + pagination = PF4Pagination() class EnableTracerView(View): @@ -773,7 +779,7 @@ class ManageHostCollectionModal(View): }, ) - pagination = Pagination() + pagination = PF4Pagination() add = OUIAButton('add-button') remove = OUIAButton('add-button') diff --git a/airgun/views/location.py b/airgun/views/location.py index 0dc241bbd..b862e2440 100644 --- a/airgun/views/location.py +++ b/airgun/views/location.py @@ -1,5 +1,6 @@ from widgetastic.widget import Checkbox, Table, Text, TextInput, View from widgetastic_patternfly import BreadCrumb +from widgetastic_patternfly4 import Pagination as PF4Pagination from airgun.views.common import BaseLoggedInView, SatVerticalTab, SearchableViewMixinPF4 from airgun.widgets import ( @@ -20,6 +21,7 @@ class LocationsView(BaseLoggedInView, SearchableViewMixinPF4): 'Actions': ActionsDropdown("./div[contains(@class, 'btn-group')]"), }, ) + pagination = PF4Pagination() @property def is_displayed(self): diff --git a/airgun/views/task.py b/airgun/views/task.py index 25bd7be15..f7931b0cb 100644 --- a/airgun/views/task.py +++ b/airgun/views/task.py @@ -1,7 +1,6 @@ from wait_for import wait_for from widgetastic.widget import Table, Text, View from widgetastic_patternfly import BreadCrumb -from widgetastic_patternfly4 import Pagination from airgun.views.common import BaseLoggedInView, SatTab, SearchableViewMixinPF4 from airgun.widgets import ( @@ -33,7 +32,6 @@ class TasksView(BaseLoggedInView, SearchableViewMixinPF4): 'Action': Text('./a'), }, ) - pagination = Pagination() @property def is_displayed(self): diff --git a/airgun/widgets.py b/airgun/widgets.py index 7378ef7ec..106c45a01 100644 --- a/airgun/widgets.py +++ b/airgun/widgets.py @@ -23,6 +23,7 @@ Kebab, VerticalNavigation, ) +from widgetastic_patternfly4 import Pagination as PF4Pagination from widgetastic_patternfly4.ouia import ( BaseSelect, Button as PF4Button, @@ -1670,12 +1671,6 @@ def fill(self, values): widget.fill(value) -class SatTablePagination(Pagination): - """Paginator widget for use within SatTable.""" - - ROOT = "//form[contains(@class, 'content-view-pf-pagination')]" - - class SatTable(Table): """Satellite version of table. @@ -1716,7 +1711,9 @@ class SatTable(Table): "contains(@data-block, 'no-search-results-message')]" ) tbody_row = Text('./tbody/tr') - pagination = SatTablePagination() + pagination = PF4Pagination( + locator="//div[contains(@class, 'pf-c-pagination') and not(contains(@class, 'pf-m-compact'))]" + ) @property def has_rows(self):