Add banner message UI test case (#19529)

Fix #19272

Signed-off-by: Yang Jiao <jiaoya@vmware.com>
This commit is contained in:
Yang Jiao 2023-11-06 11:41:35 +08:00 committed by GitHub
parent 3f7c605cf5
commit e1a44232f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 117 additions and 4 deletions

View File

@ -9,7 +9,7 @@ from library.configurations import Configurations
from library.system_info import System_info
class TestReferrersApi(unittest.TestCase):
class TestBannerMessage(unittest.TestCase):
@suppress_urllib3_warning
@ -20,7 +20,7 @@ class TestReferrersApi(unittest.TestCase):
self.message_type = "info"
self.closable = True
self.from_date = "10/27/2023"
self.to_date_str = "10/31/2030"
self.to_date = "10/31/2030"
def testBannerMessage(self):
@ -40,7 +40,7 @@ class TestReferrersApi(unittest.TestCase):
10. Check banner message by system info api;
"""
# 1. Setup banner message
self.configurations.set_configurations_of_banner_message(message=self.message, message_type=self.message_type, closable=self.closable, from_date=self.from_date, to_date=self.to_date_str)
self.configurations.set_configurations_of_banner_message(message=self.message, message_type=self.message_type, closable=self.closable, from_date=self.from_date, to_date=self.to_date)
# 2. Get banner message by configurations api
configurations = self.configurations.get_configurations()
@ -85,7 +85,7 @@ class TestReferrersApi(unittest.TestCase):
self.assertEqual(banner_mseeage["type"], self.message_type)
self.assertEqual(banner_mseeage["closable"], self.closable)
self.assertEqual(banner_mseeage["fromDate"], self.from_date)
self.assertEqual(banner_mseeage["toDate"], self.to_date_str)
self.assertEqual(banner_mseeage["toDate"], self.to_date)
if __name__ == '__main__':

View File

@ -384,3 +384,56 @@ Set Up Retain Image Last Pull Time
Run Keyword If '${action}'=='enable' Retry Double Keywords When Error Click Element ${retain_image_last_pull_time_label} Checkbox Should Be Selected ${retain_image_last_pull_time_checkbox}
... ELSE Retry Double Keywords When Error Click Element ${retain_image_last_pull_time_label} Checkbox Should Not Be Selected ${retain_image_last_pull_time_checkbox}
Retry Double Keywords When Error Retry Element Click ${config_save_button_xpath} Retry Wait Until Page Contains Configuration has been successfully saved.
Set Banner Message
[Arguments] ${message} ${message_type}=${null} ${closable}=${null} ${in_duration}=${null}
IF '${message}' != '${null}'
Retry Text Input ${banner_message_input_id} ${message}
Select From List By Value ${banner_message_type_select_id} ${message_type}
Run Keyword If '${closable}' == '${true}' Retry Element Click ${banner_message_closable_checkbox}
IF '${in_duration}' == '${true}'
Retry Element Click ${banner_message_from_date}
Retry Element Click //td[.//button[contains(@class,'is-today')]]
Retry Element Click ${banner_message_to_date}
Retry Element Click ${banner_message_date_next_month}
Retry Element Click (//td[.//button[text()=' 1 ']])[1]
ELSE IF '${in_duration}' == '${false}'
Retry Element Click ${banner_message_from_date}
Retry Element Click ${banner_message_date_next_month}
Retry Element Click (//td[.//button[text()=' 1 ']])[1]
Retry Element Click ${banner_message_to_date}
Retry Element Click ${banner_message_date_next_month}
Retry Element Click (//td[.//button[text()=' 1 ']])[1]
END
ELSE
Clear Field Of Characters ${banner_message_input_id} 23
END
Retry Double Keywords When Error Retry Element Click ${config_save_button_xpath} Retry Wait Until Page Contains Configuration has been successfully saved.
Check Banner Message
[Arguments] ${message} ${message_type}=${null} ${closable}=${null}
IF '${message}' == '${null}'
Retry Wait Element Not Visible ${banner_message_alert}
ELSE
Retry Wait Element //span[text()='${message}']
${message_type_class}= Create Dictionary success=alert-success info=alert-info warning=alert-warning danger=alert-danger
Retry Wait Element //app-app-level-alerts//clr-alerts[contains(@class,'${message_type_class}[${message_type}]')]
Run Keyword If '${closable}' == '${true}' Retry Wait Element ${banner_message_close_alert}
END
Check Banner Message on other pages
[Arguments] ${message} ${message_type}=${null} ${closable}=${null}
@{pages}= Create List harbor/projects harbor/logs harbor/users harbor/robot-accounts harbor/Registries
... harbor/replications harbor/distribution/instances harbor/labels harbor/project-quotas harbor/interrogation-services/scanners
... harbor/interrogation-services/vulnerability harbor/interrogation-services/security-hub harbor/clearing-job/gc
... harbor/clearing-job/audit-log-purge harbor/job-service-dashboard/pending-jobs harbor/job-service-dashboard/schedules
... harbor/job-service-dashboard/workers harbor/configs/auth harbor/configs/security harbor/configs/setting
... harbor/projects/1/repositories harbor/projects/1/members harbor/projects/1/labels harbor/projects/1/scanner
... harbor/projects/1/p2p-provider/policies harbor/projects/1/tag-strategy/tag-retention harbor/projects/1/tag-strategy/immutable-tag
... harbor/projects/1/robot-account harbor/projects/1/webhook harbor/projects/1/logs harbor/projects/1/configs
FOR ${page} IN @{pages}
Go To ${HARBOR_URL}/${page}
Check Banner Message ${message} ${message_type} ${closable}
END
Logout Harbor
Check Banner Message ${message} ${message_type} ${closable}

View File

@ -65,3 +65,11 @@ ${skip_audit_log_database_checkbox} //*[@id='skipAuditLogDatabase']
${skip_audit_log_database_label} //clr-checkbox-wrapper//label[contains(@class,'clr-control-label') and contains(@for,'skipAuditLogDatabase')]
${retain_image_last_pull_time_label} //clr-checkbox-wrapper//label[contains(@class,'clr-control-label') and contains(@for,'scannerSkipUpdatePullTime')]
${retain_image_last_pull_time_checkbox} //*[@id='scannerSkipUpdatePullTime']
${banner_message_input_id} //*[@id='banner-message']
${banner_message_type_select_id} //*[@id='banner-message-type']
${banner_message_closable_checkbox} //div[contains(@class,'clr-checkbox-wrapper')]//label[contains(@class,'clr-control-label')]
${banner_message_from_date} (//clr-date-container)[1]//button
${banner_message_to_date} (//clr-date-container)[2]//button
${banner_message_date_next_month} //button[@aria-label='Next month']
${banner_message_close_alert} //clr-alert//button[@aria-label='Close alert']
${banner_message_alert} //app-app-level-alerts

View File

@ -1096,3 +1096,51 @@ Test Case - Retain Image Last Pull Time
${last_pull_time}= Get Text //clr-dg-row//clr-dg-cell[9]
Should Not Be Empty ${last_pull_time}
Close Browser
Test Case - Banner Message
[Tags] banner_message
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
${message}= Set Variable This is a test message.
${message_type}= Set Variable success
${in_duration}= Set Variable ${true}
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Retry Double Keywords When Error Retry Element Click ${banner_message_close_alert} Retry Wait Element Not Visible ${banner_message_alert}
Switch To Configuration System Setting
Set Banner Message ${message} ${message_type} ${true} ${in_duration}
Check Banner Message ${message} ${message_type} ${true}
${message_type}= Set Variable info
Set Banner Message ${message} ${message_type} ${true} ${null}
Check Banner Message ${message} ${message_type} ${false}
${message_type}= Set Variable warning
Set Banner Message ${message} ${message_type} ${false} ${null}
Check Banner Message ${message} ${message_type} ${false}
${message_type}= Set Variable danger
Set Banner Message ${message} ${message_type} ${true} ${null}
Check Banner Message ${message} ${message_type} ${true}
${in_duration}= Set Variable ${false}
Set Banner Message ${message} ${message_type} ${true} ${in_duration}
Check Banner Message ${null}
Set Banner Message ${null}
Reload Page
${in_duration}= Set Variable ${true}
Set Banner Message ${message} ${message_type} ${true} ${in_duration}
Check Banner Message ${message} ${message_type} ${true}
Set Banner Message ${null}
Check Banner Message ${null}
Reload Page
Set Banner Message ${message} ${message_type} ${true} ${in_duration}
Check Banner Message ${message} ${message_type} ${true}
Check Banner Message on other pages ${message} ${message_type} ${true}
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Retry Double Keywords When Error Retry Element Click ${banner_message_close_alert} Retry Wait Element Not Visible ${banner_message_alert}
Go Into Project library
Check Banner Message ${null}
Switch To Logs
Check Banner Message ${null}
Switch To Configuration System Setting
Check Banner Message ${null}
Set Banner Message ${null}
Reload Page
Check Banner Message ${null}
Close Browser

View File

@ -37,8 +37,12 @@ Test Case - Main Menu Routing
... harbor/project-quotas=//app-project-quotas//h2[contains(.,'Project Quotas')]
... harbor/interrogation-services/scanners=//config-scanner//div//h4[contains(.,'Image Scanners')]
... harbor/interrogation-services/vulnerability=//vulnerability-config//div//button[contains(.,'SCAN NOW')]
... harbor/interrogation-services/security-hub=//h1[text()='Vulnerabilities']
... harbor/clearing-job/gc=//gc-history//h5[contains(.,'GC History')]
... harbor/clearing-job/audit-log-purge=//app-purge-history//h5[contains(.,'Purge History')]
... harbor/job-service-dashboard/pending-jobs=//app-pending-job-list//button//span[text()=' STOP ']
... harbor/job-service-dashboard/schedules=//app-schedule-list//clr-dg-cell[text()='SYSTEM_ARTIFACT_CLEANUP']
... harbor/job-service-dashboard/workers=//app-worker-list//button//span[text()=' Free ']
... harbor/configs/auth=//config//config-auth//label[contains(.,'Auth Mode')]
... harbor/configs/security=//config//app-security//span[contains(.,'CVE allowlist')]
... harbor/configs/setting=//config//system-settings//label[contains(.,'Project Creation')]