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 ...@@ -218,6 +218,7 @@ module QA
autoload :GroupIteration, 'qa/ee/resource/group_iteration' autoload :GroupIteration, 'qa/ee/resource/group_iteration'
autoload :ImportRepoWithCiCd, 'qa/ee/resource/import_repo_with_ci_cd' autoload :ImportRepoWithCiCd, 'qa/ee/resource/import_repo_with_ci_cd'
autoload :PipelineSubscriptions, 'qa/ee/resource/pipeline_subscriptions' autoload :PipelineSubscriptions, 'qa/ee/resource/pipeline_subscriptions'
autoload :GroupBase, 'qa/ee/resource/group_base'
module Board module Board
autoload :BaseBoard, 'qa/ee/resource/board/base_board' autoload :BaseBoard, 'qa/ee/resource/board/base_board'
......
...@@ -4,25 +4,22 @@ module QA ...@@ -4,25 +4,22 @@ module QA
module EE module EE
module Resource module Resource
class Epic < QA::Resource::Base 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 attribute :group do
QA::Resource::Group.fabricate! QA::Resource::Group.fabricate!
end 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 def initialize
@start_date_is_fixed = false @start_date_is_fixed = false
@start_date_fixed = nil
@due_date_is_fixed = false @due_date_is_fixed = false
@due_date_fixed = nil
@confidential = false @confidential = false
end end
...@@ -33,31 +30,70 @@ module QA ...@@ -33,31 +30,70 @@ module QA
QA::EE::Page::Group::Epic::Index.perform(&:click_new_epic) QA::EE::Page::Group::Epic::Index.perform(&:click_new_epic)
QA::EE::Page::Group::Epic::New.perform do |new| QA::EE::Page::Group::Epic::New.perform do |new_epic_page|
new.set_title(@title) new_epic_page.set_title(title)
new.enable_confidential_epic if @confidential new_epic_page.enable_confidential_epic if @confidential
new.create_new_epic new_epic_page.create_new_epic
end end
end end
def api_get_path def api_get_path
"/groups/#{group.id}/epics/#{id}" "/groups/#{CGI.escape(group.full_path)}/epics/#{iid}"
end end
def api_post_path def api_post_path
"/groups/#{group.id}/epics" "/groups/#{CGI.escape(group.full_path)}/epics"
end end
def api_post_body def api_post_body
{ {
title: title, title: @title,
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,
due_date_fixed: @due_date_fixed, due_date_fixed: @due_date_fixed,
confidential: @confidential confidential: @confidential,
parent_id: @parent_id
} }
end 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 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 ...@@ -101,3 +101,5 @@ module QA
end end
end end
end end
QA::Resource::GroupBase.prepend_mod_with('Resource::GroupBase', namespace: QA)
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
module QA module QA
RSpec.describe 'Manage', :requires_admin do 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!(: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 }
......
...@@ -57,10 +57,7 @@ module QA ...@@ -57,10 +57,7 @@ module QA
# Non blocking issues: # Non blocking issues:
# https://gitlab.com/gitlab-org/gitlab/-/issues/331252 # 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 # https://gitlab.com/gitlab-org/gitlab/-/issues/333678 <- can cause 500 when creating user and group back to back
it( it 'imports group from UI', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1785' do
'imports group with subgroups and labels',
testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1785'
) do
Page::Group::BulkImport.perform do |import_page| Page::Group::BulkImport.perform do |import_page|
import_page.import_group(imported_group.path, imported_group.sandbox.path) 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