Commit 654df34d authored by Mark Lapierre's avatar Mark Lapierre

Merge branch 'acunskis-epic-import-labels' into 'master'

E2E: Add labels, parent/child, award emojis and author validation for epic imports

See merge request gitlab-org/gitlab!68345
parents e66837f0 7141eeb8
...@@ -4,14 +4,18 @@ module QA ...@@ -4,14 +4,18 @@ module QA
module EE module EE
module Resource module Resource
class Epic < QA::Resource::Base class Epic < QA::Resource::Base
attributes :iid, attributes :id,
:iid,
:title, :title,
:description, :description,
:labels,
:parent_id,
:start_date_is_fixed, :start_date_is_fixed,
:start_date_fixed, :start_date_fixed,
:due_date_is_fixed, :due_date_is_fixed,
:due_date_fixed, :due_date_fixed,
:confidential :confidential,
:author
attribute :group do attribute :group do
QA::Resource::Group.fabricate! QA::Resource::Group.fabricate!
...@@ -45,9 +49,14 @@ module QA ...@@ -45,9 +49,14 @@ module QA
"/groups/#{CGI.escape(group.full_path)}/epics" "/groups/#{CGI.escape(group.full_path)}/epics"
end end
def api_award_emoji_path
"#{api_get_path}/award_emoji"
end
def api_post_body def api_post_body
{ {
title: @title, title: title,
labels: @labels,
start_date_is_fixed: @start_date_is_fixed, start_date_is_fixed: @start_date_is_fixed,
start_date_fixed: @start_date_fixed, start_date_fixed: @start_date_fixed,
due_date_is_fixed: @due_date_is_fixed, due_date_is_fixed: @due_date_is_fixed,
...@@ -57,6 +66,16 @@ module QA ...@@ -57,6 +66,16 @@ module QA
} }
end end
# Create new award emoji
#
# @param [String] name
# @return [Hash]
def award_emoji(name)
response = post(::QA::Runtime::API::Request.new(api_client, api_award_emoji_path).url, { name: name })
parse_body(response)
end
# Object comparison # Object comparison
# #
# @param [QA::EE::Resource::Epic] other # @param [QA::EE::Resource::Epic] other
......
...@@ -12,6 +12,7 @@ module QA ...@@ -12,6 +12,7 @@ module QA
Epic.init do |resource| Epic.init do |resource|
resource.group = self resource.group = self
resource.api_client = api_client resource.api_client = api_client
resource.id = epic[:id]
resource.iid = epic[:iid] resource.iid = epic[:iid]
resource.title = epic[:title] resource.title = epic[:title]
resource.description = epic[:description] resource.description = epic[:description]
......
...@@ -117,6 +117,10 @@ module QA ...@@ -117,6 +117,10 @@ module QA
'/users' '/users'
end end
def api_put_path
"/users/#{id}"
end
def api_block_path def api_block_path
"/users/#{id}/block" "/users/#{id}/block"
end end
...@@ -153,6 +157,16 @@ module QA ...@@ -153,6 +157,16 @@ module QA
raise ResourceUpdateFailedError, "Failed to block user. Request returned (#{response.code}): `#{response}`." raise ResourceUpdateFailedError, "Failed to block user. Request returned (#{response.code}): `#{response}`."
end end
def set_public_email
response = put(Runtime::API::Request.new(api_client, api_put_path).url, { public_email: email })
return if response.code == HTTP_STATUS_OK
raise(
ResourceUpdateFailedError,
"Failed to set public email. Request returned (#{response.code}): `#{response}`."
)
end
private private
def ldap_post_body def ldap_post_body
......
# frozen_string_literal: true # frozen_string_literal: true
module QA module QA
RSpec.describe 'Manage', :requires_admin do # Do not run on staging since another top level group has to be created which doesn't have premium license
RSpec.describe 'Manage', :requires_admin, except: { subdomain: :staging } do
describe 'Bulk group import' do describe 'Bulk group import' do
let!(:staging?) { Runtime::Scenario.gitlab_address.include?('staging.gitlab.com') } let!(:staging?) { Runtime::Scenario.gitlab_address.include?('staging.gitlab.com') }
let(:admin_api_client) { Runtime::API::Client.as_admin } let(:admin_api_client) { Runtime::API::Client.as_admin }
let(:api_client) { Runtime::API::Client.new(user: user) }
let(:author_api_client) { Runtime::API::Client.new(user: author) }
let(:user) do let(:user) do
Resource::User.fabricate_via_api! do |usr| Resource::User.fabricate_via_api! do |usr|
usr.api_client = admin_api_client usr.api_client = admin_api_client
...@@ -13,8 +17,12 @@ module QA ...@@ -13,8 +17,12 @@ module QA
end end
end end
let(:api_client) { Runtime::API::Client.new(user: user) } let(:author) do
let(:personal_access_token) { api_client.personal_access_token } Resource::User.fabricate_via_api! do |usr|
usr.api_client = admin_api_client
usr.hard_delete_on_api_removal = true
end
end
let(:sandbox) do let(:sandbox) do
Resource::Sandbox.fabricate_via_api! do |group| Resource::Sandbox.fabricate_via_api! do |group|
...@@ -37,8 +45,16 @@ module QA ...@@ -37,8 +45,16 @@ module QA
end end
end end
let(:imported_epics) do let(:source_epics) { source_group.epics }
imported_group.epics let(:imported_epics) { imported_group.epics }
# Find epic by title
#
# @param [Array] epics
# @param [String] title
# @return [EE::Resource::Epic]
def find_epic(epics, title)
epics.find { |epic| epic.title == title }
end end
before do before do
...@@ -46,29 +62,50 @@ module QA ...@@ -46,29 +62,50 @@ module QA
Runtime::Feature.enable(:top_level_group_creation_enabled) if staging? Runtime::Feature.enable(:top_level_group_creation_enabled) if staging?
sandbox.add_member(user, Resource::Members::AccessLevel::MAINTAINER) sandbox.add_member(user, Resource::Members::AccessLevel::MAINTAINER)
source_group.add_member(author, Resource::Members::AccessLevel::MAINTAINER)
author.set_public_email
EE::Resource::Epic.fabricate_via_api! do |epic| parent_epic = EE::Resource::Epic.fabricate_via_api! do |epic|
epic.api_client = api_client epic.api_client = author_api_client
epic.group = source_group epic.group = source_group
epic.title = "Bulk group import test" epic.title = 'Parent epic'
epic.confidential = true
end end
child_epic = EE::Resource::Epic.fabricate_via_api! do |child_epic|
child_epic.api_client = api_client
child_epic.group = source_group
child_epic.title = 'Child epic'
child_epic.confidential = true
child_epic.labels = 'label1,label2'
child_epic.parent_id = parent_epic.id
end end
it 'imports group epics', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1874' do child_epic.award_emoji('thumbsup')
expect { imported_group.import_status }.to( child_epic.award_emoji('thumbsdown')
eventually_eq('finished').within(max_duration: 300, sleep_interval: 2)
)
expect(imported_epics).to eq(source_group.epics)
end end
after do after do
user.remove_via_api! user.remove_via_api!
author.remove_via_api!
ensure ensure
Runtime::Feature.disable(:bulk_import) unless staging? Runtime::Feature.disable(:bulk_import) unless staging?
Runtime::Feature.disable(:top_level_group_creation_enabled) if staging? Runtime::Feature.disable(:top_level_group_creation_enabled) if staging?
end end
it 'imports group epics', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1874' do
expect { imported_group.import_status }.to(
eventually_eq('finished').within(max_duration: 300, sleep_interval: 2)
)
source_parent_epic = find_epic(source_epics, 'Parent epic')
imported_parent_epic = find_epic(imported_epics, 'Parent epic')
imported_child_epic = find_epic(imported_epics, 'Child epic')
aggregate_failures 'epics imported incorrectly' do
expect(imported_epics).to eq(source_epics)
expect(imported_child_epic.parent_id).to eq(imported_parent_epic.id)
expect(imported_parent_epic.author).to eq(source_parent_epic.author)
end
end
end end
end end
end end
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