Commit 561f6c28 authored by Mark Lapierre's avatar Mark Lapierre

Merge branch 'acunskis-validate-issues-migration' into 'master'

E2E: Validate project issues are imported correctly

See merge request gitlab-org/gitlab!72420
parents 6eccba12 cdef13e5
...@@ -9,6 +9,7 @@ module QA ...@@ -9,6 +9,7 @@ module QA
Project.fabricate! do |resource| Project.fabricate! do |resource|
resource.name = 'project-for-issues' resource.name = 'project-for-issues'
resource.description = 'project for adding issues' resource.description = 'project for adding issues'
resource.api_client = api_client
end end
end end
...@@ -93,6 +94,52 @@ module QA ...@@ -93,6 +94,52 @@ module QA
attempts: attempts attempts: attempts
) )
end end
# Object comparison
#
# @param [QA::Resource::Issue] other
# @return [Boolean]
def ==(other)
other.is_a?(Issue) && comparable_issue == other.comparable_issue
end
# Override inspect for a better rspec failure diff output
#
# @return [String]
def inspect
JSON.pretty_generate(comparable_issue)
end
protected
# Return subset of fields for comparing issues
#
# @return [Hash]
def comparable_issue
reload! if api_response.nil?
api_resource.slice(
:state,
:description,
:type,
:title,
:labels,
:milestone,
:upvotes,
:downvotes,
:merge_requests_count,
:user_notes_count,
:due_date,
:has_tasks,
:task_status,
:confidential,
:discussion_locked,
:issue_type,
:task_completion_status,
:closed_at,
:created_at
)
end
end end
end end
end end
...@@ -44,6 +44,10 @@ module QA ...@@ -44,6 +44,10 @@ module QA
end end
end end
let(:imported_projects) do
imported_group.reload!.projects
end
before do before do
Runtime::Feature.enable(:bulk_import_projects) Runtime::Feature.enable(:bulk_import_projects)
Runtime::Feature.enable(:top_level_group_creation_enabled) if staging? Runtime::Feature.enable(:top_level_group_creation_enabled) if staging?
...@@ -67,13 +71,48 @@ module QA ...@@ -67,13 +71,48 @@ module QA
) do ) do
expect { imported_group.import_status }.to eventually_eq('finished').within(import_wait_duration) expect { imported_group.import_status }.to eventually_eq('finished').within(import_wait_duration)
imported_projects = imported_group.reload!.projects
aggregate_failures do aggregate_failures do
expect(imported_projects.count).to eq(1) expect(imported_projects.count).to eq(1)
expect(imported_projects.first).to eq(source_project) expect(imported_projects.first).to eq(source_project)
end end
end end
end end
context 'with project issues' do
let(:source_issue) do
Resource::Issue.fabricate_via_api! do |issue|
issue.api_client = api_client
issue.project = source_project
issue.labels = %w[label_one label_two]
end
end
let(:imported_issues) do
imported_projects.first.issues
end
let(:imported_issue) do
issue = imported_issues.first
Resource::Issue.init do |resource|
resource.api_client = api_client
resource.project = imported_projects.first
resource.iid = issue[:iid]
end
end
before do
source_issue # fabricate source group, project, issue
end
it 'successfully imports issue' do
expect { imported_group.import_status }.to eventually_eq('finished').within(import_wait_duration)
aggregate_failures do
expect(imported_issues.count).to eq(1)
expect(imported_issue.reload!).to eq(source_issue)
end
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