From 89f35ae7361b008b84f8d8c9328fba4283fcc4c4 Mon Sep 17 00:00:00 2001 From: Sam Bible Date: Mon, 3 Jun 2024 02:02:33 -0500 Subject: [PATCH 1/4] add support for versions dropdown --- airgun/entities/contentview_new.py | 6 ++++++ airgun/views/contentview_new.py | 3 +++ 2 files changed, 9 insertions(+) diff --git a/airgun/entities/contentview_new.py b/airgun/entities/contentview_new.py index 6007da6c0..8ff2fe038 100644 --- a/airgun/entities/contentview_new.py +++ b/airgun/entities/contentview_new.py @@ -129,6 +129,12 @@ def read_french_lang_cv(self): view.wait_displayed() return view.table.read() + def click_version_dropdown(self, entity_name, version, dropdown_option): + """Clicks a specific dropdown option for a CV Version""" + view = self.navigate_to(self, 'Version', entity_name=entity_name, version=version) + self.browser.plugin.ensure_page_safe(timeout='5s') + return view.version_dropdown.item_select(dropdown_option) + @navigator.register(NewContentViewEntity, 'All') class ShowAllContentViewsScreen(NavigateStep): diff --git a/airgun/views/contentview_new.py b/airgun/views/contentview_new.py index c6db5fbdb..64054b810 100644 --- a/airgun/views/contentview_new.py +++ b/airgun/views/contentview_new.py @@ -279,6 +279,9 @@ class ContentViewVersionDetailsView(BaseLoggedInView): promoteButton = PF4Button( locator='.//button[@data-ouia-component-id="cv-details-publish-button"]' ) + version_dropdown = Dropdown( + locator='.//div[@data-ouia-component-id="cv-version-header-actions-dropdown"]' + ) editDescription = PF4Button( locator='.//button[@data-ouia-component-id="edit-button-description"]' ) From c668cae8cde86c37b2c5520dc4d5cb109e84e527 Mon Sep 17 00:00:00 2001 From: Sam Bible Date: Wed, 3 Jul 2024 08:20:19 -0500 Subject: [PATCH 2/4] Move error checking logic into airgun, and add method to contain it --- airgun/entities/contentview_new.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/airgun/entities/contentview_new.py b/airgun/entities/contentview_new.py index 8ff2fe038..9fd66795c 100644 --- a/airgun/entities/contentview_new.py +++ b/airgun/entities/contentview_new.py @@ -1,5 +1,7 @@ from navmazing import NavigateToSibling +import pytest from widgetastic.exceptions import NoSuchElementException +from widgetastic_patternfly4.dropdown import DropdownItemDisabled from airgun.entities.base import BaseEntity from airgun.navigation import NavigateStep, navigator @@ -135,6 +137,20 @@ def click_version_dropdown(self, entity_name, version, dropdown_option): self.browser.plugin.ensure_page_safe(timeout='5s') return view.version_dropdown.item_select(dropdown_option) + def republish_metadata_error(self, entity_name, version): + """Clicks a specific dropdown option for a CV Version, that will throw an error""" + view = self.navigate_to(self, 'Version', entity_name=entity_name, version=version) + self.browser.plugin.ensure_page_safe(timeout='5s') + with pytest.raises(DropdownItemDisabled) as error: + view.version_dropdown.item_select('Republish repository metadata') + if ( + 'Item "Republish repository metadata" of dropdown ".//div[@data-ouia-component-id="cv-version-header-actions-dropdown"]" is disabled' + in error.value.args[0] + ): + return True + else: + return 'No error was found, metadata unexpectedly was able to be published.' + @navigator.register(NewContentViewEntity, 'All') class ShowAllContentViewsScreen(NavigateStep): From 47dbf0d802c01ba080f3c2ea914ffcd82d1897db Mon Sep 17 00:00:00 2001 From: Sam Bible Date: Wed, 3 Jul 2024 09:24:06 -0500 Subject: [PATCH 3/4] Add better is_displayed logic and call it in function --- airgun/entities/contentview_new.py | 2 ++ airgun/views/contentview_new.py | 1 + 2 files changed, 3 insertions(+) diff --git a/airgun/entities/contentview_new.py b/airgun/entities/contentview_new.py index 9fd66795c..7958815da 100644 --- a/airgun/entities/contentview_new.py +++ b/airgun/entities/contentview_new.py @@ -135,12 +135,14 @@ def click_version_dropdown(self, entity_name, version, dropdown_option): """Clicks a specific dropdown option for a CV Version""" view = self.navigate_to(self, 'Version', entity_name=entity_name, version=version) self.browser.plugin.ensure_page_safe(timeout='5s') + view.wait_displayed() return view.version_dropdown.item_select(dropdown_option) def republish_metadata_error(self, entity_name, version): """Clicks a specific dropdown option for a CV Version, that will throw an error""" view = self.navigate_to(self, 'Version', entity_name=entity_name, version=version) self.browser.plugin.ensure_page_safe(timeout='5s') + view.wait_displayed() with pytest.raises(DropdownItemDisabled) as error: view.version_dropdown.item_select('Republish repository metadata') if ( diff --git a/airgun/views/contentview_new.py b/airgun/views/contentview_new.py index 64054b810..26c9d88fc 100644 --- a/airgun/views/contentview_new.py +++ b/airgun/views/contentview_new.py @@ -359,6 +359,7 @@ def is_displayed(self): and len(self.breadcrumb.locations) > LOCATION_NUM and self.breadcrumb.locations[0] == 'Content views' and self.breadcrumb.locations[2] == 'Versions' + and self.promoteButton.is_displayed ) From 468943d6b9ffdb0ce4d1919b969e2df460a3f5d8 Mon Sep 17 00:00:00 2001 From: Sam Bible Date: Wed, 10 Jul 2024 10:28:59 -0500 Subject: [PATCH 4/4] Remove pytest reference and change is_displayed --- airgun/entities/contentview_new.py | 14 +++++--------- airgun/views/contentview_new.py | 3 ++- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/airgun/entities/contentview_new.py b/airgun/entities/contentview_new.py index 7958815da..1f8f6b9ed 100644 --- a/airgun/entities/contentview_new.py +++ b/airgun/entities/contentview_new.py @@ -1,5 +1,4 @@ from navmazing import NavigateToSibling -import pytest from widgetastic.exceptions import NoSuchElementException from widgetastic_patternfly4.dropdown import DropdownItemDisabled @@ -143,15 +142,12 @@ def republish_metadata_error(self, entity_name, version): view = self.navigate_to(self, 'Version', entity_name=entity_name, version=version) self.browser.plugin.ensure_page_safe(timeout='5s') view.wait_displayed() - with pytest.raises(DropdownItemDisabled) as error: + try: view.version_dropdown.item_select('Republish repository metadata') - if ( - 'Item "Republish repository metadata" of dropdown ".//div[@data-ouia-component-id="cv-version-header-actions-dropdown"]" is disabled' - in error.value.args[0] - ): - return True - else: - return 'No error was found, metadata unexpectedly was able to be published.' + except DropdownItemDisabled as error: + if 'Item "Republish repository metadata"' and 'is disabled' in error.args[0]: + return True + return 'No error was found, metadata unexpectedly was able to be published.' @navigator.register(NewContentViewEntity, 'All') diff --git a/airgun/views/contentview_new.py b/airgun/views/contentview_new.py index 26c9d88fc..5790c9b61 100644 --- a/airgun/views/contentview_new.py +++ b/airgun/views/contentview_new.py @@ -354,12 +354,13 @@ class errata(Tab): @property def is_displayed(self): breadcrumb_loaded = self.browser.wait_for_element(self.breadcrumb, exception=False) + title_loaded = self.browser.wait_for_element(self.version, exception=False) return ( breadcrumb_loaded + and title_loaded and len(self.breadcrumb.locations) > LOCATION_NUM and self.breadcrumb.locations[0] == 'Content views' and self.breadcrumb.locations[2] == 'Versions' - and self.promoteButton.is_displayed )