Skip to content

Commit 9c96213

Browse files
committed
hostgroups: PF5 update & navigation improvements
PatternFly5 updates for the host groups pages. Additional changes: - several `view.wait_displayed()` added for more reliable page loading - Host Groups page now also expects if no host groups are present - `hostgroup.read()` no longer submits the form - it can cause to submit unintentional data (not likely, but still) - it prolongs the test time as new page needs to load - the navigation can clash with actions chains like `read() && update(...)` where `read()` submits the form while `update()` expects to interact with the page immediately
1 parent 4095b8f commit 9c96213

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

airgun/entities/hostgroup.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ def read(self, entity_name, widget_names=None):
4343
"""Read values from host group edit page"""
4444
view = self.navigate_to(self, 'Edit', entity_name=entity_name)
4545
value = view.read(widget_names=widget_names)
46-
view.submit.click()
4746
return value
4847

4948
def read_all(self):
@@ -67,6 +66,7 @@ def update(self, entity_name, values):
6766
view.submit.click()
6867
view.flash.assert_no_error()
6968
view.flash.dismiss()
69+
self.browser.plugin.ensure_page_safe()
7070

7171
def total_no_of_assigned_role(self, entity_name):
7272
"""Count of assigned role to the host group"""
@@ -113,6 +113,7 @@ class ShowAllHostGroups(NavigateStep):
113113
@retry_navigation
114114
def step(self, *args, **kwargs):
115115
self.view.menu.select('Configure', 'Host Groups')
116+
self.view.wait_displayed()
116117

117118

118119
@navigator.register(HostGroupEntity, 'New')
@@ -128,6 +129,7 @@ def step(self, *args, **kwargs):
128129
self.parent.new.click()
129130
except NoSuchElementException:
130131
self.parent.new_on_blank_page.click()
132+
self.view.wait_displayed()
131133

132134

133135
@navigator.register(HostGroupEntity, 'Edit')
@@ -147,3 +149,4 @@ def step(self, *args, **kwargs):
147149
entity_name = kwargs.get('entity_name')
148150
self.parent.search(entity_name)
149151
self.parent.table.row(name=entity_name)['Name'].widget.click()
152+
self.view.wait_displayed()

airgun/views/hostgroup.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from widgetastic.widget import ConditionalSwitchableView, Table, Text, TextInput, View
22
from widgetastic_patternfly import BreadCrumb
3-
from widgetastic_patternfly4 import Button as PF4Button, Pagination as PF4Pagination
43
from widgetastic_patternfly4.ouia import Select as OUIASelect
4+
from widgetastic_patternfly5 import Button as PF5Button, Pagination as PF5Pagination
55

66
from airgun.views.common import BaseLoggedInView, SatTab, SearchableViewMixinPF4
77
from airgun.widgets import (
@@ -32,7 +32,7 @@ class HostGroupsView(BaseLoggedInView, SearchableViewMixinPF4):
3232
"//h1[contains(., 'Host Group Configuration') or normalize-space(.)='Host Groups']"
3333
)
3434
new = Text("//a[contains(@href, '/hostgroups/new')]")
35-
new_on_blank_page = PF4Button('Create Host Group')
35+
new_on_blank_page = PF5Button('Create Host Group')
3636
table = Table(
3737
'.//table',
3838
column_widgets={
@@ -43,9 +43,10 @@ class HostGroupsView(BaseLoggedInView, SearchableViewMixinPF4):
4343

4444
@property
4545
def is_displayed(self):
46-
return self.browser.wait_for_element(
46+
page_loaded = self.browser.wait_for_element(
4747
self.title, exception=False
48-
) is not None and self.browser.url.endswith('hostgroups')
48+
) or self.browser.wait_for_element(self.new_on_blank_page, exception=False)
49+
return page_loaded and self.browser.url.endswith('hostgroups')
4950

5051

5152
class HostGroupCreateView(BaseLoggedInView):
@@ -81,7 +82,7 @@ class host_group(SatTab):
8182
class ansible_roles(SatTab):
8283
TAB_NAME = 'Ansible Roles'
8384
resources = MultiSelectNoFilter(id='ansible_roles')
84-
pagination = PF4Pagination()
85+
pagination = PF5Pagination()
8586

8687
@View.nested
8788
class puppet_enc(SatTab):
@@ -158,4 +159,4 @@ class ansible_roles(SatTab):
158159
no_of_available_role = Text('//span[@class="pf-c-options-menu__toggle-text"]//b[2]')
159160
resources = MultiSelectNoFilter(id='ansible_roles')
160161
submit = Text('//input[@name="commit"]')
161-
pagination = PF4Pagination()
162+
pagination = PF5Pagination()

0 commit comments

Comments
 (0)