Commit 7141eeb8 authored by Andrejs Cunskis's avatar Andrejs Cunskis Committed by Mark Lapierre

E2E: Add labels and parent/child validation for epic imports

Disable test run on staging
Validate correct epic author 
Add award emoji validation
parent 66169230
......@@ -4,14 +4,18 @@ module QA
module EE
module Resource
class Epic < QA::Resource::Base
attributes :iid,
attributes :id,
:iid,
:title,
:description,
:labels,
:parent_id,
:start_date_is_fixed,
:start_date_fixed,
:due_date_is_fixed,
:due_date_fixed,
:confidential
:confidential,
:author
attribute :group do
QA::Resource::Group.fabricate!
......@@ -45,9 +49,14 @@ module QA
"/groups/#{CGI.escape(group.full_path)}/epics"
end
def api_award_emoji_path
"#{api_get_path}/award_emoji"
end
def api_post_body
{
title: @title,
title: title,
labels: @labels,
start_date_is_fixed: @start_date_is_fixed,
start_date_fixed: @start_date_fixed,
due_date_is_fixed: @due_date_is_fixed,
......@@ -57,6 +66,16 @@ module QA
}
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
#
# @param [QA::EE::Resource::Epic] other
......
......@@ -12,6 +12,7 @@ module QA
Epic.init do |resource|
resource.group = self
resource.api_client = api_client
resource.id = epic[:id]
resource.iid = epic[:iid]
resource.title = epic[:title]
resource.description = epic[:description]
......
......@@ -117,6 +117,10 @@ module QA
'/users'
end
def api_put_path
"/users/#{id}"
end
def api_block_path
"/users/#{id}/block"
end
......@@ -153,6 +157,16 @@ module QA
raise ResourceUpdateFailedError, "Failed to block user. Request returned (#{response.code}): `#{response}`."
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
def ldap_post_body
......
# frozen_string_literal: true
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
let!(:staging?) { Runtime::Scenario.gitlab_address.include?('staging.gitlab.com') }
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
Resource::User.fabricate_via_api! do |usr|
usr.api_client = admin_api_client
......@@ -13,8 +17,12 @@ module QA
end
end
let(:api_client) { Runtime::API::Client.new(user: user) }
let(:personal_access_token) { api_client.personal_access_token }
let(:author) do
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
Resource::Sandbox.fabricate_via_api! do |group|
......@@ -37,8 +45,16 @@ module QA
end
end
let(:imported_epics) do
imported_group.epics
let(:source_epics) { source_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
before do
......@@ -46,29 +62,50 @@ module QA
Runtime::Feature.enable(:top_level_group_creation_enabled) if staging?
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|
epic.api_client = api_client
parent_epic = EE::Resource::Epic.fabricate_via_api! do |epic|
epic.api_client = author_api_client
epic.group = source_group
epic.title = "Bulk group import test"
epic.confidential = true
epic.title = 'Parent epic'
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
expect { imported_group.import_status }.to(
eventually_eq('finished').within(max_duration: 300, sleep_interval: 2)
)
expect(imported_epics).to eq(source_group.epics)
child_epic.award_emoji('thumbsup')
child_epic.award_emoji('thumbsdown')
end
after do
user.remove_via_api!
author.remove_via_api!
ensure
Runtime::Feature.disable(:bulk_import) unless staging?
Runtime::Feature.disable(:top_level_group_creation_enabled) if staging?
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
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