diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-11 09:10:29 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-11 09:10:29 +0300 |
commit | b7eed2ea49477a8baa7d9b0cf8034c799cde2e0f (patch) | |
tree | 38df0de2d4c7344a07d55f7cf5914344ba88e8e6 /qa | |
parent | 11bfe6f3835256acf60ef98f9e2a37f417418681 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'qa')
-rw-r--r-- | qa/qa.rb | 1 | ||||
-rw-r--r-- | qa/qa/page/group/bulk_import.rb | 47 | ||||
-rw-r--r-- | qa/qa/page/group/new.rb | 26 | ||||
-rw-r--r-- | qa/qa/page/main/menu.rb | 23 | ||||
-rw-r--r-- | qa/qa/resource/user.rb | 20 | ||||
-rw-r--r-- | qa/qa/specs/features/browser_ui/1_manage/group/bulk_import_group_spec.rb | 94 | ||||
-rw-r--r-- | qa/spec/spec_helper.rb | 1 | ||||
-rw-r--r-- | qa/spec/specs/runner_spec.rb | 2 |
8 files changed, 197 insertions, 17 deletions
@@ -225,6 +225,7 @@ module QA autoload :Show, 'qa/page/group/show' autoload :Menu, 'qa/page/group/menu' autoload :Members, 'qa/page/group/members' + autoload :BulkImport, 'qa/page/group/bulk_import' module Milestone autoload :Index, 'qa/page/group/milestone/index' diff --git a/qa/qa/page/group/bulk_import.rb b/qa/qa/page/group/bulk_import.rb new file mode 100644 index 00000000000..11741bdf4cb --- /dev/null +++ b/qa/qa/page/group/bulk_import.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +module QA + module Page + module Group + class BulkImport < Page::Base + view "app/assets/javascripts/import_entities/import_groups/components/import_table.vue" do + element :import_table + end + + view "app/assets/javascripts/import_entities/import_groups/components/import_table_row.vue" do + element :import_item + element :target_namespace_selector_dropdown + element :target_group_dropdown_item + element :import_status_indicator + element :import_group_button + end + + # Import source group in to target group + # + # @param [String] source_group_name + # @param [String] target_group_name + # @return [void] + def import_group(source_group_name, target_group_name) + finished_loading? + + within_element(:import_item, source_group: source_group_name) do + click_element(:target_namespace_selector_dropdown) + click_element(:target_group_dropdown_item, group_name: target_group_name) + click_element(:import_group_button) + end + end + + # Check if import page has a successfully imported group + # + # @param [String] source_group_name + # @param [Integer] wait + # @return [Boolean] + def has_imported_group?(source_group_name, wait: QA::Support::WaitForRequests::DEFAULT_MAX_WAIT_TIME) + within_element(:import_item, source_group: source_group_name) do + has_element?(:import_status_indicator, text: "Complete", wait: wait) + end + end + end + end + end +end diff --git a/qa/qa/page/group/new.rb b/qa/qa/page/group/new.rb index 9a4e53d6053..5a908266597 100644 --- a/qa/qa/page/group/new.rb +++ b/qa/qa/page/group/new.rb @@ -15,6 +15,12 @@ module QA element :create_group_button, "submit _('Create group')" # rubocop:disable QA/ElementWithPattern end + view 'app/views/groups/_import_group_from_another_instance_panel.html.haml' do + element :import_gitlab_url + element :import_gitlab_token + element :connect_instance_button + end + def set_path(path) fill_element(:group_path_field, path) fill_element(:group_name_field, path) @@ -23,6 +29,26 @@ module QA def create click_button 'Create group' end + + def set_gitlab_url(url) + fill_element(:import_gitlab_url, url) + end + + def set_gitlab_token(token) + fill_element(:import_gitlab_token, token) + end + + # Connect gitlab instance + # + # @param [String] gitlab_url + # @param [String] gitlab_token + # @return [void] + def connect_gitlab_instance(gitlab_url, gitlab_token) + set_gitlab_url(gitlab_url) + set_gitlab_token(gitlab_token) + + click_element(:connect_instance_button) + end end end end diff --git a/qa/qa/page/main/menu.rb b/qa/qa/page/main/menu.rb index 693f61ba97c..656ccf75814 100644 --- a/qa/qa/page/main/menu.rb +++ b/qa/qa/page/main/menu.rb @@ -35,17 +35,24 @@ module QA element :your_projects_link end + view 'app/views/layouts/nav/groups_dropdown/_show.html.haml' do + element :create_group_link + element :import_group_link + end + view 'app/views/layouts/_search.html.haml' do element :search_term_field end def go_to_groups - within_top_menu do - click_element :groups_dropdown + within_groups_menu do + click_element :your_groups_link end + end - page.within('.qa-groups-dropdown-sidebar') do - click_element :your_groups_link + def go_to_import_group + within_groups_menu do + click_element :import_group_link end end @@ -173,6 +180,14 @@ module QA end end + def within_groups_menu(&block) + within_top_menu do + click_element :groups_dropdown + end + + page.within('.qa-groups-dropdown-sidebar', &block) + end + def click_admin_area within_top_menu { click_element :admin_area_link } end diff --git a/qa/qa/resource/user.rb b/qa/qa/resource/user.rb index d98b7d7c79d..8957dbcbe84 100644 --- a/qa/qa/resource/user.rb +++ b/qa/qa/resource/user.rb @@ -9,7 +9,7 @@ module QA attr_reader :unique_id attr_writer :username, :password - attr_accessor :admin, :provider, :extern_uid, :expect_fabrication_success + attr_accessor :admin, :provider, :extern_uid, :expect_fabrication_success, :hard_delete_on_api_removal attribute :id attribute :name @@ -19,6 +19,7 @@ module QA def initialize @admin = false + @hard_delete_on_api_removal = false @unique_id = SecureRandom.hex(8) @expect_fabrication_success = true end @@ -77,9 +78,7 @@ module QA def fabricate! # Don't try to log-out if we're not logged-in - if Page::Main::Menu.perform { |p| p.has_personal_area?(wait: 0) } - Page::Main::Menu.perform { |main| main.sign_out } - end + Page::Main::Menu.perform(&:sign_out) if Page::Main::Menu.perform { |p| p.has_personal_area?(wait: 0) } if credentials_given? Page::Main::Login.perform do |login| @@ -103,9 +102,9 @@ module QA end def api_delete_path - "/users/#{id}" + "/users/#{id}?hard_delete=#{hard_delete_on_api_removal}" rescue NoValueError - "/users/#{fetch_id(username)}" + "/users/#{fetch_id(username)}?hard_delete=#{hard_delete_on_api_removal}" end def api_get_path @@ -135,12 +134,12 @@ module QA def self.fabricate_or_use(username = nil, password = nil) if Runtime::Env.signup_disabled? - self.fabricate_via_api! do |user| + fabricate_via_api! do |user| user.username = username user.password = password end else - self.fabricate! do |user| + fabricate! do |user| user.username = username if username user.password = password if password end @@ -149,10 +148,9 @@ module QA def block! response = post(Runtime::API::Request.new(api_client, api_block_path).url, nil) + return if response.code == HTTP_STATUS_CREATED - unless response.code == HTTP_STATUS_CREATED - raise ResourceUpdateFailedError, "Failed to block user. Request returned (#{response.code}): `#{response}`." - end + raise ResourceUpdateFailedError, "Failed to block user. Request returned (#{response.code}): `#{response}`." end private diff --git a/qa/qa/specs/features/browser_ui/1_manage/group/bulk_import_group_spec.rb b/qa/qa/specs/features/browser_ui/1_manage/group/bulk_import_group_spec.rb new file mode 100644 index 00000000000..f09ffb1c9fb --- /dev/null +++ b/qa/qa/specs/features/browser_ui/1_manage/group/bulk_import_group_spec.rb @@ -0,0 +1,94 @@ +# frozen_string_literal: true + +module QA + RSpec.describe "Manage", :requires_admin do + describe "Group bulk import" do + let!(:api_client) { Runtime::API::Client.as_admin } + let!(:user) do + Resource::User.fabricate_via_api! do |usr| + usr.api_client = api_client + usr.hard_delete_on_api_removal = true + end + end + + let!(:personal_access_token) { Runtime::API::Client.new(user: user).personal_access_token } + + let!(:sandbox) do + Resource::Sandbox.fabricate_via_api! do |group| + group.api_client = api_client + end + end + + let!(:source_group) do + Resource::Sandbox.fabricate_via_api! do |group| + group.api_client = api_client + group.path = "source-group-for-import-#{SecureRandom.hex(4)}" + end + end + + let(:imported_group) do + Resource::Group.new.tap do |group| + group.api_client = api_client + group.path = source_group.path + end.reload! + rescue Resource::ApiFabricator::ResourceNotFoundError + nil + end + + # Return subset of fields for comparing groups + # + # @param [Resource::Group, nil] group + # @return [Hash] + def comparable_group(group) + group&.api_resource&.except( + :id, + :web_url, + :visibility, + :full_name, + :full_path, + :created_at, + :parent_id, + :runners_token + ) + end + + before(:all) do + Runtime::Feature.enable(:bulk_import) + end + + before do + sandbox.add_member(user, Resource::Members::AccessLevel::MAINTAINER) + source_group.add_member(user, Resource::Members::AccessLevel::MAINTAINER) + + Flow::Login.sign_in(as: user) + Page::Main::Menu.new.go_to_import_group + Page::Group::New.new.connect_gitlab_instance(Runtime::Scenario.gitlab_address, personal_access_token) + end + + it( + "performs bulk group import from another gitlab instance", + testcase: "https://gitlab.com/gitlab-org/quality/testcases/-/issues/1785", + # https://gitlab.com/gitlab-org/gitlab/-/issues/330344 + exclude: { job: ["ce:relative_url", "ee:relative_url"] } + ) do + Page::Group::BulkImport.perform do |import_page| + import_page.import_group(source_group.path, sandbox.path) + + aggregate_failures do + expect(import_page).to have_imported_group(source_group.path, wait: 120) + expect(comparable_group(imported_group)).to eq(comparable_group(source_group)) + end + end + end + + after do + user.remove_via_api! + source_group.remove_via_api! + end + + after(:all) do + Runtime::Feature.disable(:bulk_import) + end + end + end +end diff --git a/qa/spec/spec_helper.rb b/qa/spec/spec_helper.rb index 631ebf65893..0c9643c830b 100644 --- a/qa/spec/spec_helper.rb +++ b/qa/spec/spec_helper.rb @@ -3,6 +3,7 @@ require_relative '../qa' require 'rspec/retry' require 'rspec-parameterized' +require 'active_support/core_ext/hash' if ENV['CI'] && QA::Runtime::Env.knapsack? && !ENV['NO_KNAPSACK'] require 'knapsack' diff --git a/qa/spec/specs/runner_spec.rb b/qa/spec/specs/runner_spec.rb index 642d9e0745b..021ce9091e0 100644 --- a/qa/spec/specs/runner_spec.rb +++ b/qa/spec/specs/runner_spec.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -require 'active_support/core_ext/hash' - RSpec.describe QA::Specs::Runner do shared_examples 'excludes orchestrated, transient, and geo' do it 'excludes the orchestrated, transient, and geo tags, and includes default args' do |