Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redesign of bucket page, init changes #11040

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,24 @@
from selenium.webdriver.common.by import By
from ocs_ci.ocs.ocp import get_ocp_url
from ocs_ci.ocs import exceptions
from ocs_ci.ocs.ui.page_objects.confirm_dialog import ConfirmDialog
from ocs_ci.ocs.ui.page_objects.object_storage import ObjectStorage, logger
from ocs_ci.utility import version


class ObjectBucketsTab(ObjectStorage):
class BucketsTab(ObjectStorage, ConfirmDialog):
def __init__(self):
super().__init__()

def delete_object_bucket_ui(self, delete_via, expect_fail, resource_name):
def delete_bucket_ui(self, delete_via, expect_fail, resource_name):
"""
Delete an Object Bucket via the UI

delete_via (str): delete via 'OB/Actions' or via 'three dots'
expect_fail (str): verify if OB removal fails with proper PopUp message
resource_name (str): Object Bucket Claim's name. The resource with its suffix will be deleted
"""
self.navigate_object_buckets_page()
self.navigate_buckets_page()
self.delete_resource(delete_via, resource_name)

if expect_fail:
Expand All @@ -28,9 +30,9 @@ def _check_three_dots_disabled(text):
logger.info(text)
# locator of three_dots btn aligned with the specific resource name
locator = (
f"//td[@id='name']//a[contains(text(), '{resource_name}')]"
"/../../..//button[@aria-label='Actions'] | "
f"//tr[contains(., '{resource_name}')]//button[@data-test='kebab-button']",
f"//tr[contains(., '{resource_name}')]//button[@data-test='kebab-button'] | "
f"//td[@data-label='Name' and normalize-space()='{resource_name}']"
"/following-sibling::td//button[@aria-label='Kebab toggle']",
By.XPATH,
)
# when three_dots element is active attribute 'disabled' does not exist
Expand All @@ -52,23 +54,27 @@ def _check_three_dots_disabled(text):
sleep=1,
)

# PopUp is not reachable via Selenium driver. It does not appear in DOM
URL = f"{get_ocp_url()}/locales/resource.json?lng=en&ns=plugin__odf-console"
# this popup is not available on ODF 4.18 and above
if self.ocp_version_semantic < version.VERSION_4_18:
# PopUp is not reachable via Selenium driver. It does not appear in DOM
URL = f"{get_ocp_url()}/locales/resource.json?lng=en&ns=plugin__odf-console"

cookies = self.driver.get_cookies()
session = requests.Session()
for cookie in cookies:
session.cookies.set(cookie["name"], cookie["value"])
cookies = self.driver.get_cookies()
session = requests.Session()
for cookie in cookies:
session.cookies.set(cookie["name"], cookie["value"])

popup_str = "The corresponding ObjectBucketClaim must be deleted first."
logger.info(f"Send req to {URL}. Get PopUp with {popup_str}")
popup_str = (
"The corresponding ObjectBucketClaim must be deleted first."
)
logger.info(f"Send req to {URL}. Get PopUp with {popup_str}")

resp = session.get(url=URL, verify=False)
json_resp = resp.json()
resp = session.get(url=URL, verify=False)
json_resp = resp.json()

assert (
popup_str == json_resp[popup_str]
), f"No expected Popup. See full response: \n {json.dumps(json_resp)}"
assert (
popup_str == json_resp[popup_str]
), f"No expected Popup. See full response: \n {json.dumps(json_resp)}"

_check_three_dots_disabled("check three dots inactive automatically")
self.driver.refresh()
Expand Down
48 changes: 48 additions & 0 deletions ocs_ci/ocs/ui/page_objects/confirm_dialog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
from ocs_ci.ocs.ui.base_ui import BaseUI


class ConfirmDialog(BaseUI):
"""
Page object for Confirm Dialog
"""

def dialog_confirm_delete(self, resource_name):
"""
Action to confirm delete resource
"""
# placeholder for the confirm dialog remains even when text input contains any text
# remove the text if exists, for more complex scenarios
self.dialog_type_resource_name(resource_name)
self.dialog_confirm()

def dialog_confirm(self):
"""
Clicks on Delete button
"""
self.do_click(self.generic_locators["confirm_delete_resource"])

def dialog_cancel(self):
"""
Clicks on Cancel button
"""
self.do_click(self.generic_locators["cancel_delete_resource"])

def dialog_type_resource_name(self, resource_name):
"""
Type the resource name in the dialog
"""
from ocs_ci.ocs.ui.helpers_ui import format_locator

self.clear_input_gradually(
format_locator(self.generic_locators["confirm_dilog_input"], resource_name)
)
self.do_send_keys(
format_locator(self.generic_locators["confirm_dilog_input"], resource_name),
resource_name,
)

def dialog_close(self):
"""
Close the dialog
"""
self.do_click(self.generic_locators["close_dialog"])
10 changes: 4 additions & 6 deletions ocs_ci/ocs/ui/page_objects/object_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,18 @@ def nav_namespace_store_tab(self):

return NameSpaceStoreTab()

def nav_object_buckets_tab(self):
def nav_buckets_tab(self):
"""
Navigate to Object Buckets tab. Accessible from Object Storage page

Returns:
ObjectBucketTab: ObjectBucketTab page object
"""
self.do_click(
locator=self.page_nav["object_buckets_tab"], enable_screenshot=False
)
self.do_click(locator=self.page_nav["buckets_tab"], enable_screenshot=False)

from ocs_ci.ocs.ui.page_objects.object_buckets_tab import ObjectBucketsTab
from ocs_ci.ocs.ui.page_objects.buckets_tab import BucketsTab

return ObjectBucketsTab()
return BucketsTab()

def nav_object_buckets_claims_tab(self):
"""
Expand Down
4 changes: 2 additions & 2 deletions ocs_ci/ocs/ui/page_objects/page_navigator.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,13 +292,13 @@ def navigate_volumesnapshotcontents_page(self):
enable_screenshot=False,
)

def navigate_object_buckets_page(self):
def navigate_buckets_page(self):
"""
Navigate to Object Buckets Page
"""

return self.nav_object_storage().nav_object_buckets_tab()
return self.nav_object_storage().nav_buckets_tab()

def navigate_object_bucket_claims_page(self):
"""
Expand Down
18 changes: 16 additions & 2 deletions ocs_ci/ocs/ui/page_objects/resource_list.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from ocs_ci.ocs.ui.helpers_ui import format_locator
from ocs_ci.ocs.ui.page_objects.searchbar import SearchBar
from ocs_ci.ocs.ui.base_ui import logger
from ocs_ci.utility import version


class ResourceList(SearchBar):
Expand All @@ -23,7 +24,9 @@ def nav_to_resource_via_name(self, resource_name: str = None):
self.do_clear(self.generic_locators["searchbar_input"])
self.search(resource_name)
self.do_click(
format_locator(self.generic_locators["resource_link"], resource_name),
format_locator(
self.generic_locators["resource_link"], resource_name, resource_name
),
enable_screenshot=True,
)

Expand Down Expand Up @@ -78,4 +81,15 @@ def delete_resource(self, delete_via, resource):

logger.info(f"Confirm {resource} Deletion")
# same PopUp both for OBC and OB
self.do_click(self.generic_locators["confirm_action"], enable_screenshot=True)
# check if we are on the Bucket page, it has different UI starting from 4.18
from ocs_ci.ocs.ui.page_objects.buckets_tab import BucketsTab

if (
isinstance(self, BucketsTab)
and self.ocp_version_semantic >= version.VERSION_4_18
):
self.dialog_confirm_delete(resource)
else:
self.do_click(
self.generic_locators["confirm_action"], enable_screenshot=True
)
4 changes: 2 additions & 2 deletions ocs_ci/ocs/ui/page_objects/resource_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def nav_resource_list_via_breadcrumbs(self):
from ocs_ci.ocs.ui.page_objects.object_bucket_claims_tab import (
ObjectBucketClaimsTab,
)
from ocs_ci.ocs.ui.page_objects.object_buckets_tab import ObjectBucketsTab
from ocs_ci.ocs.ui.page_objects.buckets_tab import BucketsTab

if self.is_namespace_store_open():
resource_list_page = NameSpaceStoreTab
Expand All @@ -135,7 +135,7 @@ def nav_resource_list_via_breadcrumbs(self):
elif self.is_obc_open():
resource_list_page = ObjectBucketClaimsTab
elif self.is_ob_open():
resource_list_page = ObjectBucketsTab
resource_list_page = BucketsTab
else:
raise IncorrectUiOptionRequested(
"Wrong page is open after resource created", func=take_screenshot
Expand Down
18 changes: 14 additions & 4 deletions ocs_ci/ocs/ui/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@
By.XPATH,
),
"actions": (
'//button[@aria-label="Actions"] | //div[@data-test-id="details-actions"]//button | '
'//button[@aria-label="Actions"]| //div[@data-test-id="details-actions"]//button[normalize-space()="Actions"]| '
'//span[@class="pf-c-dropdown__toggle-text" and text()="Actions"]/..',
By.XPATH,
),
Expand All @@ -308,11 +308,19 @@
"//tr[contains(., '{}')]//button[@data-test='kebab-button']",
By.XPATH,
),
"resource_link": ("//td[@id='name']//a[contains(text(),'{}')]", By.XPATH),
"resource_link": (
"//td[@id='name']//a[contains(text(),'{}')] | "
"//td[@data-label='Name']//a[contains(text(),'{}')]",
By.XPATH,
),
"confirm_action": (
'button[id="confirm-action"],button[data-test="delete-action"]',
By.CSS_SELECTOR,
),
"confirm_dilog_input": ("//input[@placeholder='{}']", By.XPATH),
"confirm_delete_resource": ("//button[contains(text(), 'Delete')]", By.XPATH),
"cancel_delete_resource": ("//button[contains(text(), 'Cancel')]", By.XPATH),
"close_dialog": ("button[aria-label='Close']", By.XPATH),
"submit_form": ('button[type="submit"]', By.CSS_SELECTOR),
"ocs_operator": ('//h1[text()="OpenShift Container Storage"]', By.XPATH),
"kebab_button": ('button[data-test-id="kebab-button"', By.CSS_SELECTOR),
Expand Down Expand Up @@ -689,8 +697,10 @@
"volumesnapshots_page": ("VolumeSnapshots", By.LINK_TEXT),
"volumesnapshotclasses_page": ("VolumeSnapshotClasses", By.LINK_TEXT),
"volumesnapshotcontents_page": ("VolumeSnapshotContents", By.LINK_TEXT),
"object_buckets_tab": (
"//a[normalize-space()='Object Buckets'] | //span[normalize-space()='Object Buckets']/..",
"buckets_tab": (
"//a[normalize-space()='Object Buckets'] "
"| //span[normalize-space()='Object Buckets']/.. "
"| //span[normalize-space()='Buckets']/..",
By.XPATH,
),
"object_storage": ("//a[normalize-space()='Object Storage']", By.XPATH),
Expand Down
6 changes: 4 additions & 2 deletions tests/functional/object/mcg/ui/test_mcg_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
mcg,
skipif_ibm_cloud_managed,
provider_mode,
jira,
)
from ocs_ci.ocs import constants
from ocs_ci.helpers.helpers import create_unique_resource_name
Expand All @@ -29,7 +30,7 @@
from ocs_ci.ocs.ui.page_objects.object_bucket_claims_tab import (
ObjectBucketClaimsTab,
)
from ocs_ci.ocs.ui.page_objects.object_buckets_tab import ObjectBucketsTab
from ocs_ci.ocs.ui.page_objects.buckets_tab import BucketsTab
from ocs_ci.ocs.ui.page_objects.page_navigator import PageNavigator
from ocs_ci.ocs.scale_noobaa_lib import fetch_noobaa_storage_class_name

Expand Down Expand Up @@ -338,6 +339,7 @@ def teardown(self):
resource_name=obc_name
)

@jira("DFBUGS-1147")
@pytest.mark.parametrize(
argnames=["storageclass", "bucketclass", "delete_via", "verify_ob_removal"],
argvalues=generate_test_params(),
Expand Down Expand Up @@ -404,7 +406,7 @@ def test_obc_creation_and_deletion(

# covers BZ 2097772
if verify_ob_removal:
ObjectBucketsTab().delete_object_bucket_ui(
BucketsTab().delete_bucket_ui(
delete_via="three_dots", expect_fail=True, resource_name=obc_name
)

Expand Down
Loading