Commit 0ecbf7f6 authored by Sanad Liaquat's avatar Sanad Liaquat

Merge branch 'qa-shl-fix-transfer-project-spec-2' into 'master'

Fix transfer project spec

Closes #231242

See merge request gitlab-org/gitlab!42078
parents 5fc9e48c efcfc614
...@@ -8,6 +8,10 @@ module QA ...@@ -8,6 +8,10 @@ module QA
find('.select2-result-label', text: item_text, match: :prefer_exact).click find('.select2-result-label', text: item_text, match: :prefer_exact).click
end end
def has_item?(item_text)
has_css?('.select2-result-label', text: item_text, match: :prefer_exact)
end
def current_selection def current_selection
find('.select2-chosen').text find('.select2-chosen').text
end end
...@@ -25,8 +29,12 @@ module QA ...@@ -25,8 +29,12 @@ module QA
end end
def search_and_select(item_text) def search_and_select(item_text)
QA::Runtime::Logger.info "Searching and selecting: #{item_text}"
search_item(item_text) search_item(item_text)
raise QA::Page::Base::ElementNotFound, %Q(Couldn't find option named "#{item_text}") unless has_item?(item_text)
select_item(item_text) select_item(item_text)
end end
......
...@@ -38,20 +38,16 @@ module QA ...@@ -38,20 +38,16 @@ module QA
click_element :change_path_button click_element :change_path_button
end end
def select_transfer_option(namespace)
search_and_select(namespace)
end
def transfer_project!(project_name, namespace) def transfer_project!(project_name, namespace)
# Retry added here due to seldom seen inconsistent UI state issue: QA::Runtime::Logger.info "Transferring project: #{project_name} to namespace: #{namespace}"
# https://gitlab.com/gitlab-org/gitlab/-/issues/231242
retry_on_exception do click_element_coordinates(:archive_project_content)
click_element_coordinates(:archive_project_content)
expand_select_list expand_select_list
# Workaround for a failure to search when there are no spaces around the /
# https://gitlab.com/gitlab-org/gitlab/-/issues/218965 # Workaround for a failure to search when there are no spaces around the /
select_transfer_option(namespace.gsub(/([^\s])\/([^\s])/, '\1 / \2')) # https://gitlab.com/gitlab-org/gitlab/-/issues/218965
end search_and_select(namespace.gsub(/([^\s])\/([^\s])/, '\1 / \2'))
click_element(:transfer_button) click_element(:transfer_button)
fill_confirmation_text(project_name) fill_confirmation_text(project_name)
......
...@@ -11,14 +11,14 @@ module QA ...@@ -11,14 +11,14 @@ module QA
let(:target_group) do let(:target_group) do
Resource::Group.fabricate_via_api! do |group| Resource::Group.fabricate_via_api! do |group|
group.path = 'target-group' group.path = "target-group-for-transfer_#{SecureRandom.hex(8)}"
end end
end end
let(:project) do let(:project) do
Resource::Project.fabricate_via_api! do |project| Resource::Project.fabricate_via_api! do |project|
project.group = source_group project.group = source_group
project.name = 'transfer-project' project.name = 'transfer-project'
project.initialize_with_readme = true project.initialize_with_readme = true
end end
end end
...@@ -44,12 +44,15 @@ module QA ...@@ -44,12 +44,15 @@ module QA
end end
it 'user transfers a project between groups', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/406' do it 'user transfers a project between groups', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/406' do
Page::File::Show.perform(&:go_to_general_settings) # Retry is needed here as the target group is not avaliable for transfer right away.
QA::Support::Retrier.retry_on_exception(reload_page: page) do
Page::File::Show.perform(&:go_to_general_settings)
Page::Project::Settings::Main.perform(&:expand_advanced_settings) Page::Project::Settings::Main.perform(&:expand_advanced_settings)
Page::Project::Settings::Advanced.perform do |advanced| Page::Project::Settings::Advanced.perform do |advanced|
advanced.transfer_project!(project.name, target_group.full_path) advanced.transfer_project!(project.name, target_group.full_path)
end
end end
Page::Project::Settings::Main.perform(&:click_project) Page::Project::Settings::Main.perform(&:click_project)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment