Commit cba5473c authored by Andrejs Cunskis's avatar Andrejs Cunskis

E2E: Group Migration - epic migration validation

Implement spec for epic migration validation

Add ability to fetch and compare epics from group

Make epic confidential

Update test names and add testcase link

Remove irrelevant comments

Remove redundant validation of array size

Fix calling confidential during ui fabrication
parent 192e2526
......@@ -218,6 +218,7 @@ module QA
autoload :GroupIteration, 'qa/ee/resource/group_iteration'
autoload :ImportRepoWithCiCd, 'qa/ee/resource/import_repo_with_ci_cd'
autoload :PipelineSubscriptions, 'qa/ee/resource/pipeline_subscriptions'
autoload :GroupBase, 'qa/ee/resource/group_base'
module Board
autoload :BaseBoard, 'qa/ee/resource/board/base_board'
......
......@@ -4,25 +4,22 @@ module QA
module EE
module Resource
class Epic < QA::Resource::Base
attr_accessor :title
attributes :iid,
:title,
:description,
:start_date_is_fixed,
:start_date_fixed,
:due_date_is_fixed,
:due_date_fixed,
:confidential
attribute :group do
QA::Resource::Group.fabricate!
end
attribute :id
attribute :iid
attribute :start_date_is_fixed
attribute :start_date_fixed
attribute :due_date_is_fixed
attribute :due_date_fixed
attribute :confidential
def initialize
@start_date_is_fixed = false
@start_date_fixed = nil
@due_date_is_fixed = false
@due_date_fixed = nil
@confidential = false
end
......@@ -33,31 +30,70 @@ module QA
QA::EE::Page::Group::Epic::Index.perform(&:click_new_epic)
QA::EE::Page::Group::Epic::New.perform do |new|
new.set_title(@title)
new.enable_confidential_epic if @confidential
new.create_new_epic
QA::EE::Page::Group::Epic::New.perform do |new_epic_page|
new_epic_page.set_title(title)
new_epic_page.enable_confidential_epic if @confidential
new_epic_page.create_new_epic
end
end
def api_get_path
"/groups/#{group.id}/epics/#{id}"
"/groups/#{CGI.escape(group.full_path)}/epics/#{iid}"
end
def api_post_path
"/groups/#{group.id}/epics"
"/groups/#{CGI.escape(group.full_path)}/epics"
end
def api_post_body
{
title: title,
title: @title,
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
confidential: @confidential,
parent_id: @parent_id
}
end
# Object comparison
#
# @param [QA::EE::Resource::Epic] other
# @return [Boolean]
def ==(other)
other.is_a?(Epic) && comparable_epic == other.comparable_epic
end
# Override inspect for a better rspec failure diff output
#
# @return [String]
def inspect
JSON.pretty_generate(comparable_epic)
end
protected
# Return subset of fields for comparing epics
#
# @return [Hash]
def comparable_epic
reload! if api_response.nil?
api_resource.slice(
:title,
:description,
:state,
:start_date_is_fixed,
:start_date_fixed,
:due_date_is_fixed,
:due_date_fixed,
:confidential,
:labels,
:upvotes,
:downvotes
)
end
end
end
end
......
# frozen_string_literal: true
module QA
module EE
module Resource
module GroupBase
# Get group epics
#
# @return [Array<QA::EE::Resource::Epic>]
def epics
parse_body(api_get_from(api_epics_path)).map do |epic|
Epic.init do |resource|
resource.group = self
resource.api_client = api_client
resource.iid = epic[:iid]
resource.title = epic[:title]
resource.description = epic[:description]
end
end
end
def api_epics_path
"#{api_get_path}/epics"
end
end
end
end
end
......@@ -101,3 +101,5 @@ module QA
end
end
end
QA::Resource::GroupBase.prepend_mod_with('Resource::GroupBase', namespace: QA)
......@@ -2,7 +2,7 @@
module QA
RSpec.describe 'Manage', :requires_admin do
describe 'Bulk group import via api' 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 }
......
......@@ -57,10 +57,7 @@ module QA
# Non blocking issues:
# https://gitlab.com/gitlab-org/gitlab/-/issues/331252
# https://gitlab.com/gitlab-org/gitlab/-/issues/333678 <- can cause 500 when creating user and group back to back
it(
'imports group with subgroups and labels',
testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1785'
) do
it 'imports group from UI', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1785' do
Page::Group::BulkImport.perform do |import_page|
import_page.import_group(imported_group.path, imported_group.sandbox.path)
......
# frozen_string_literal: true
module QA
RSpec.describe 'Manage', :requires_admin 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(:user) do
Resource::User.fabricate_via_api! do |usr|
usr.api_client = admin_api_client
usr.hard_delete_on_api_removal = true
end
end
let(:api_client) { Runtime::API::Client.new(user: user) }
let(:personal_access_token) { api_client.personal_access_token }
let(:sandbox) do
Resource::Sandbox.fabricate_via_api! do |group|
group.api_client = admin_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::BulkImportGroup.fabricate_via_api! do |group|
group.api_client = api_client
group.sandbox = sandbox
group.source_group_path = source_group.path
end
end
let(:imported_epics) do
imported_group.epics
end
before do
Runtime::Feature.enable(:bulk_import) unless staging?
Runtime::Feature.enable(:top_level_group_creation_enabled) if staging?
sandbox.add_member(user, Resource::Members::AccessLevel::MAINTAINER)
EE::Resource::Epic.fabricate_via_api! do |epic|
epic.api_client = api_client
epic.group = source_group
epic.title = "Bulk group import test"
epic.confidential = true
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)
end
after do
user.remove_via_api!
ensure
Runtime::Feature.disable(:bulk_import) unless staging?
Runtime::Feature.disable(:top_level_group_creation_enabled) if staging?
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