Skip to content

Commit

Permalink
Refactor the keyword in the testcase (#18898)
Browse files Browse the repository at this point in the history
Fix #17952

Signed-off-by: Yang Jiao <jiaoya@vmware.com>
  • Loading branch information
YangJiao0817 committed Jul 6, 2023
1 parent c8120d5 commit fb52fdb
Show file tree
Hide file tree
Showing 22 changed files with 198 additions and 368 deletions.
2 changes: 1 addition & 1 deletion tests/apitests/python/test_proxy_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def do_validate(self, registry_type):

image_for_docker = dict(image = "for_proxy", tag = "1.0")
image_for_ctr = dict(image = "redis", tag = "latest")
index_for_docker = dict(image = "index081597864867", tag = "index_tag081597864867")
index_for_docker = dict(image = "index", tag = "index_tag")
access_key = ""
access_secret = ""

Expand Down
4 changes: 0 additions & 4 deletions tests/resources/Harbor-Pages/Project-Config.robot
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@ Resource ../../resources/Util.robot
*** Keywords ***

Goto Project Config
Sleep 3
Retry Element Click //project-detail//ul/li[contains(.,'Summary')]
Sleep 3
Retry Double Keywords When Error Retry Element Click //project-detail//ul/li[contains(.,'Configuration')] Retry Wait Element //clr-checkbox-wrapper/label[contains(.,'Prevent vulnerable images from running.')]
Sleep 2

Click Project Public
Mouse Down //hbr-project-policy-config//input[@name='public']
Expand All @@ -36,7 +33,6 @@ Click Auto Scan
Mouse Up //hbr-project-policy-config//input[@name='scan-image-on-push']

Save Project Config
Sleep 1
Retry Element Click //hbr-project-policy-config//button[contains(.,'SAVE')]

Public Should Be Selected
Expand Down
24 changes: 0 additions & 24 deletions tests/resources/Harbor-Pages/Project-Members.robot
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,6 @@ Resource ../../resources/Util.robot
*** Variables ***

*** Keywords ***
Go Into Project
[Arguments] ${project} ${has_image}=${true}
Retry Keyword N Times When Error 5 Clear Search Input And Go Into Project ${project} ${has_image}

Clear Search Input And Go Into Project
[Arguments] ${project} ${has_image}
# Close prompt in header
Sleep 2
#go To ${url}
Reload Page
Sleep 2
# Clear Search Input
Retry Element Click xpath=//harbor-app/harbor-shell/clr-main-container/navigator/clr-header/div[1]/a/span
Sleep 2
Retry Text Input ${search_input} ${project}
Sleep 2
# Go Into Project
${out} Run Keyword If ${has_image}==${false} Run Keywords Retry Element Click xpath=//*[@id='project-results']//clr-dg-cell[contains(.,'${project}')]/a AND Wait Until Element Is Visible And Enabled xpath=//clr-dg-placeholder[contains(.,\"We couldn\'t find any repositories!\")]
... ELSE Run Keywords Retry Element Click xpath=//*[@id='project-results']//clr-dg-cell[contains(.,'${project}')]/a AND Wait Until Element Is Visible And Enabled xpath=//project-detail//hbr-repository-gridview//clr-dg-cell[contains(.,'${project}/')]
Sleep 1
Capture Page Screenshot

Add User To Project Admin
[Arguments] ${project} ${user}
# *** this keyword has not been used ***
Expand All @@ -50,7 +28,6 @@ Add User To Project Admin
Retry Text Input xpath=${project_member_add_username_xpath} ${user}
Retry Element Click xpath=${project_member_add_admin_xpath}
Retry Element Click xpath=${project_member_add_save_button_xpath}
Sleep 4

Search Project Member
[Arguments] ${project} ${user}
Expand Down Expand Up @@ -112,7 +89,6 @@ Delete Project Member
Retry Double Keywords When Error Retry Element Click ${member_action_xpath} Retry Wait Until Page Contains Element ${delete_action_xpath}
Retry Double Keywords When Error Retry Element Click ${delete_action_xpath} Retry Wait Until Page Contains Element ${repo_delete_on_card_view_btn}
Retry Double Keywords When Error Retry Element Click ${repo_delete_on_card_view_btn} Retry Wait Element xpath=${project_member_xpath}
Sleep 1

User Should Be Owner Of Project
[Arguments] ${user} ${pwd} ${project}
Expand Down
3 changes: 1 addition & 2 deletions tests/resources/Harbor-Pages/Project-P2P-Preheat.robot
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,7 @@ Verify Artifact Is Labeled Event
Go Into Project ${project_name}
Switch To Project Label
Create New Labels ${label}
Switch To Project Repo
Go Into Repo ${image}
Go Into Repo ${project_name} ${image}
Add Labels To Tag ${tag} ${label}
Back Project Home ${project_name}
Switch To P2P Preheat
Expand Down
5 changes: 2 additions & 3 deletions tests/resources/Harbor-Pages/Project-Repository.robot
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ View Scan Error Log

Scan Artifact
[Arguments] ${project} ${repo} ${label_xpath}=//clr-dg-row//label[1]
Go Into Project ${project}
Go Into Repo ${project}/${repo}
Go Into Repo ${project} ${repo}
Retry Element Click ${label_xpath}
Retry Element Click ${scan_artifact_btn}

Expand All @@ -46,4 +45,4 @@ Check Scan Artifact Job Status Is Stopped
Should Be Equal As Strings '${job_status}' 'Scan stopped'

Refresh Repositories
Retry Element Click ${refresh_repositories_xpath}
Retry Element Click ${refresh_repositories_xpath}
3 changes: 0 additions & 3 deletions tests/resources/Harbor-Pages/Project-Tag-Retention.robot
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ Retry Add A Tag Immutability Rule
Add A Tag Immutability Rule
[Arguments] ${scope} ${tag}
Reload Page
Sleep 3
Retry Double Keywords When Error Retry Element Click xpath=${project_tag_retention_add_rule_xpath} Retry Wait Until Page Contains Element xpath=${project_tag_immutability_save_add_button_xpath}
Retry Clear Element Text ${project_tag_immutability_scope_input_xpath}
Retry Text Input ${project_tag_immutability_scope_input_xpath} ${scope}
Expand Down Expand Up @@ -97,9 +96,7 @@ Execute Result Should Be
FOR ${idx} IN RANGE 0 20
${out} Run Keyword And Ignore Error Retry Wait Until Page Contains Element //app-tag-retention-tasks//clr-datagrid//clr-dg-row[contains(., '${image}') and contains(., '${result}')]
Exit For Loop If '${out[0]}'=='PASS'
Sleep 1
Retry Element Click ${project_tag_retention_refresh_xpath}
Sleep 5
Retry Wait Until Page Contains Element xpath=${project_tag_retention_record_yes_xpath}
Retry Element Click ${project_tag_retention_list_expand_icon_xpath}
END
Expand Down
2 changes: 0 additions & 2 deletions tests/resources/Harbor-Pages/Project-Webhooks.robot
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ Resource ../../resources/Util.robot

*** Keywords ***
Switch To Project Webhooks
#Switch To Project Tab Overflow
Retry Element Click xpath=//project-detail//a[contains(.,'Webhooks')]
Sleep 1

Create A New Webhook
[Arguments] ${webhook_name} ${webhook_endpoint_url} ${event_type}=@{EMPTY}
Expand Down
73 changes: 35 additions & 38 deletions tests/resources/Harbor-Pages/Project.robot
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ Create An New Project And Go Into Project
${out} Run Keyword And Ignore Error Retry Button Click xpath=${create_project_button_xpath}
Log All Return value is ${out[0]}
Exit For Loop If '${out[0]}'=='PASS'
Sleep 1
END
Log To Console Project Name: ${projectname}
Retry Text Input xpath=${project_name_xpath} ${projectname}
Expand All @@ -36,7 +35,6 @@ Create An New Project And Go Into Project
Run Keyword If '${storage_quota}'!='${null}' Input Storage Quota ${storage_quota} ${storage_quota_unit}
Run Keyword If '${proxy_cache}' == '${true}' Run Keywords Retry Element Click ${project_proxy_cache_switcher_xpath} AND Retry Element Click ${project_registry_select_id} AND Retry Element Click xpath=//select[@id='registry']//option[contains(.,'${registry}')]
Retry Double Keywords When Error Retry Element Click ${create_project_OK_button_xpath} Retry Wait Until Page Not Contains Element ${create_project_OK_button_xpath}
Sleep 2
Go Into Project ${projectname} has_image=${false}

Create An New Project With New User
Expand All @@ -45,44 +43,35 @@ Create An New Project With New User
Logout Harbor
Sign In Harbor ${url} ${username} ${newPassword}
Create An New Project And Go Into Project ${projectname} ${public}
Sleep 1

Artifact Exist
[Arguments] ${tag_name}
Retry Wait Until Page Contains Element //artifact-list-tab//clr-datagrid//clr-dg-row[contains(.,'sha256') and contains(.,'${tag_name}')]
#It's the log of project.

Go To Project Log
#Switch To Project Tab Overflow
Retry Element Click xpath=${project_log_xpath}
Sleep 2

Switch To Member
Sleep 3
Retry Element Click xpath=${project_member_xpath}
Sleep 1

Switch To Replication
Retry Element Click xpath=${project_replication_xpath}
Sleep 1

Switch To Project Configuration
Retry Element Click ${project_config_tabsheet}
Sleep 1

Switch To Tag Retention
#Switch To Project Tab Overflow
Retry Element Click xpath=${project_tag_strategy_xpath}
Sleep 1

Switch To Tag Immutability
#Switch To Project Tab Overflow
Retry Double Keywords When Error Retry Element Click xpath=${project_tag_strategy_xpath} Retry Wait Until Page Contains Element ${project_tag_immutability_switch}
Retry Double Keywords When Error Retry Element Click xpath=${project_tag_immutability_switch} Retry Wait Until Page Contains Immutability rules
Sleep 1

Switch To Project Tab Overflow
Retry Element Click xpath=${project_tab_overflow_btn}
Sleep 1

Navigate To Projects
Retry Element Click xpath=${projects_xpath}
Expand All @@ -98,7 +87,6 @@ Project Should Not Display
Search Private Projects
Retry Element Click xpath=//select
Retry Element Click xpath=//select/option[@value=1]
Sleep 1

Make Project Private
[Arguments] ${projectname}
Expand Down Expand Up @@ -153,7 +141,6 @@ Delete Repo on CardView
Retry Element Click //hbr-gridview//span[contains(.,'${reponame}')]//clr-dropdown/button
Retry Element Click //hbr-gridview//span[contains(.,'${reponame}')]//clr-dropdown/clr-dropdown-menu/button[contains(.,'Delete')]
Retry Element Click ${repo_delete_on_card_view_btn}
Sleep 2

Delete Project
[Arguments] ${projectname}
Expand All @@ -162,7 +149,6 @@ Delete Project
Retry Element Click ${project_action_xpath}
Retry Element Click xpath=//*[@id='delete-project']
Retry Element Click //clr-modal//button[contains(.,'DELETE')]
Sleep 1

Project Should Not Be Deleted
[Arguments] ${projname}
Expand Down Expand Up @@ -202,9 +188,7 @@ Do Log Advanced Search
Retry Element Click xpath=//audit-log//clr-dropdown//a[contains(.,'Others')]
Retry Element Click xpath=//audit-log//hbr-filter//clr-icon
Retry Text Input xpath=//audit-log//hbr-filter//input harbor-jobservice
Sleep 1
${rc} = Get Element Count //audit-log//clr-dg-row
Should Be Equal As Integers ${rc} 1
Retry Wait Until Page Not Contains Element //audit-log//clr-dg-row[2]

Retry Click Repo Name
[Arguments] ${repo_name_element}
Expand All @@ -220,25 +204,44 @@ Retry Click Repo Name
END
Should Be Equal As Strings '${out[0]}' 'PASS'

Go Into Repo
[Arguments] ${repoName}
Sleep 2
Retry Wait Until Page Not Contains Element ${repo_list_spinner}
${repo_name_element}= Set Variable xpath=//clr-dg-cell[contains(.,'${repoName}')]/a
FOR ${n} IN RANGE 1 3
Retry Element Click ${repo_search_icon}
Retry Clear Element Text ${repo_search_input}
Retry Text Input ${repo_search_input} ${repoName}
${out} Run Keyword And Ignore Error Retry Wait Until Page Contains Element ${repo_name_element}
Go Into Project
[Arguments] ${project} ${has_image}=${true}
FOR ${n} IN RANGE 1 4
${out} Run Keyword And Ignore Error Retry Go Into Project ${project} ${has_image}
Run Keyword If '${out[0]}'=='PASS' Exit For Loop
Reload Page
Sleep 2
Run Keyword If '${out[0]}'=='FAIL' Reload Page
Continue For Loop If '${out[0]}'=='FAIL'
Retry Click Repo Name ${repo_name_element}
END
Run Keyword If '${out[0]}'=='FAIL' Capture Page Screenshot
Should Be Equal As Strings '${out[0]}' 'PASS'

Retry Go Into Project
[Arguments] ${project} ${has_image}
Retry Text Input ${search_input} ${project}
Wait Until Page Contains Element //list-project-ro//a[contains(., '${project}')]
Retry Link Click //list-project-ro//a[contains(., '${project}')]
Wait Until Page Contains Element //project-detail//h1[contains(., '${project}')]
Run Keyword If ${has_image}==${false} Wait Until Element Is Visible And Enabled //clr-dg-placeholder[contains(.,\"We couldn\'t find any repositories!\")]
... ELSE Wait Until Element Is Visible And Enabled //project-detail//hbr-repository-gridview//clr-dg-cell[contains(.,'${project}/')]

Go Into Repo
[Arguments] ${project_name} ${repo_name}
FOR ${n} IN RANGE 1 4
${out} Run Keyword And Ignore Error Retry Go Into Repo ${project_name} ${repo_name}
Run Keyword If '${out[0]}'=='PASS' Exit For Loop
Reload Page
Sleep 2
Exit For Loop
END
Run Keyword If '${out[0]}'=='FAIL' Capture Page Screenshot
Should Be Equal As Strings '${out[0]}' 'PASS'

Retry Go Into Repo
[Arguments] ${project_name} ${repo_name}
Retry Text Input ${search_input} ${project_name}/${repo_name}
Wait Until Page Contains Element //list-repository-ro//a[contains(., '${project_name}/${repo_name}')]
Retry Link Click //list-repository-ro//a[contains(., '${project_name}/${repo_name}')]
Wait Until Page Contains Element //artifact-list-page//h2[contains(., '${repo_name}')]

Click Index Achieve
[Arguments] ${tag_name}
Retry Element Click //artifact-list-tab//clr-datagrid//clr-dg-row[contains(.,'sha256') and contains(.,'${tag_name}')]//clr-dg-cell[1]//clr-tooltip//a
Expand All @@ -261,12 +264,10 @@ Go Into Index And Contain Artifacts

Switch To CardView
Retry Element Click xpath=//hbr-repository-gridview//span[@class='card-btn']/clr-icon
Sleep 5

Expand Repo
[Arguments] ${projectname}
Retry Element Click //repository//clr-dg-row[contains(.,'${projectname}')]//button/clr-icon
Sleep 1

Edit Repo Info
Retry Element Click //*[@id='repo-info']
Expand All @@ -285,11 +286,9 @@ Edit Repo Info

Switch To Project Label
Retry Element Click xpath=//project-detail//a[contains(.,'Labels')]
Sleep 1

Switch To Project Repo
Retry Element Click xpath=//project-detail//a[contains(.,'Repositories')]
Sleep 1

Add Labels To Tag
[Arguments] ${tagName} ${labelName}
Expand All @@ -312,14 +311,12 @@ Filter Labels In Tags
Retry Element Click xpath=//*[@id='search-btn']
Retry Element Click xpath=//*[@id='filterArea']//div//button[contains(.,'${labelName2}')]
Retry Element Click xpath=//app-artifact-filter//clr-icon[contains(@shape,'search')]
Sleep 2
Retry Wait Until Page Contains Element xpath=//clr-dg-row[contains(.,'${labelName2}')]
Retry Wait Until Page Not Contains Element xpath=//clr-dg-row[contains(.,'${labelName1}')]

Get Statics
[Arguments] ${locator}
Reload Page
Sleep 5
${privaterepo}= Get Text ${locator}
[Return] ${privaterepo}

Expand Down

0 comments on commit fb52fdb

Please sign in to comment.