Commit 549f5a74 authored by Andrejs Cunskis's avatar Andrejs Cunskis

Merge branch 'acunskis-issue-comments' into 'master'

E2E: Validate issue comments are migrated

See merge request gitlab-org/gitlab!77359
parents 66725424 9f974d3f
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
module QA module QA
module Resource module Resource
class Issue < Base class Issue < Base
attr_writer :description, :milestone, :template, :weight attr_writer :milestone, :template, :weight
attribute :project do attribute :project do
Project.fabricate! do |resource| Project.fabricate! do |resource|
...@@ -95,6 +95,15 @@ module QA ...@@ -95,6 +95,15 @@ module QA
) )
end end
# Create a new comment
#
# @param [String] body
# @param [Boolean] confidential
# @return [Hash]
def add_comment(body:, confidential: false)
api_post_to(api_comments_path, body: body, confidential: confidential)
end
protected protected
# Return subset of fields for comparing issues # Return subset of fields for comparing issues
......
...@@ -5,9 +5,9 @@ module QA ...@@ -5,9 +5,9 @@ module QA
# on staging environment # on staging environment
RSpec.describe 'Manage', :requires_admin, except: { subdomain: :staging } do RSpec.describe 'Manage', :requires_admin, except: { subdomain: :staging } do
describe 'Gitlab migration', quarantine: { describe 'Gitlab migration', quarantine: {
only: { job: "praefect-parallel" }, only: { job: 'praefect-parallel' },
type: :investigating, type: :investigating,
issue: "https://gitlab.com/gitlab-org/gitlab/-/issues/348999" issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/348999'
} do } do
let(:source_project_with_readme) { false } let(:source_project_with_readme) { false }
let(:import_wait_duration) { { max_duration: 300, sleep_interval: 2 } } let(:import_wait_duration) { { max_duration: 300, sleep_interval: 2 } }
...@@ -93,7 +93,7 @@ module QA ...@@ -93,7 +93,7 @@ module QA
end end
context 'with project issues' do context 'with project issues' do
let(:source_issue) do let!(:source_issue) do
Resource::Issue.fabricate_via_api! do |issue| Resource::Issue.fabricate_via_api! do |issue|
issue.api_client = api_client issue.api_client = api_client
issue.project = source_project issue.project = source_project
...@@ -101,9 +101,9 @@ module QA ...@@ -101,9 +101,9 @@ module QA
end end
end end
let(:imported_issues) do let!(:source_comment) { source_issue.add_comment(body: 'This is a test comment!') }
imported_projects.first.issues
end let(:imported_issues) { imported_projects.first.issues }
let(:imported_issue) do let(:imported_issue) do
issue = imported_issues.first issue = imported_issues.first
...@@ -114,9 +114,7 @@ module QA ...@@ -114,9 +114,7 @@ module QA
end end
end end
before do let(:imported_comments) { imported_issue.comments }
source_issue # fabricate source group, project, issue
end
it( it(
'successfully imports issue', 'successfully imports issue',
...@@ -124,8 +122,13 @@ module QA ...@@ -124,8 +122,13 @@ module QA
) do ) do
expect_import_finished expect_import_finished
expect(imported_issues.count).to eq(1) aggregate_failures do
expect(imported_issue).to eq(source_issue) expect(imported_issues.count).to eq(1)
expect(imported_issue).to eq(source_issue.reload!)
expect(imported_comments.count).to eq(1)
expect(imported_comments.first[:body]).to include(source_comment[:body])
end
end end
end end
...@@ -198,22 +201,25 @@ module QA ...@@ -198,22 +201,25 @@ module QA
end end
context 'with merge request' do context 'with merge request' do
let(:source_project_with_readme) { true } let!(:source_project_with_readme) { true }
let(:other_user) do let!(:other_user) do
Resource::User.fabricate_via_api! do |usr| Resource::User
usr.api_client = admin_api_client .fabricate_via_api! { |usr| usr.api_client = admin_api_client }
end .tap do |usr|
usr.set_public_email
source_project.add_member(usr, Resource::Members::AccessLevel::MAINTAINER)
end
end end
let(:source_mr) do let!(:source_mr) do
Resource::MergeRequest.fabricate_via_api! do |mr| Resource::MergeRequest.fabricate_via_api! do |mr|
mr.project = source_project mr.project = source_project
mr.api_client = Runtime::API::Client.new(user: other_user) mr.api_client = Runtime::API::Client.new(user: other_user)
end end
end end
let(:source_comment) { source_mr.add_comment("This is a test comment!") } let!(:source_comment) { source_mr.add_comment('This is a test comment!') }
let(:imported_mrs) { imported_project.merge_requests } let(:imported_mrs) { imported_project.merge_requests }
let(:imported_mr_comments) { imported_mr.comments } let(:imported_mr_comments) { imported_mr.comments }
...@@ -226,21 +232,13 @@ module QA ...@@ -226,21 +232,13 @@ module QA
end end
end end
before do
other_user.set_public_email
source_project.add_member(other_user, Resource::Members::AccessLevel::MAINTAINER)
source_comment # fabricate mr and comment
source_mr.reload! # update notes count attribute on object
end
after do after do
other_user.remove_via_api! other_user.remove_via_api!
end end
it( it(
'successfully imports merge request', 'successfully imports merge request',
tesecase: "https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/348478" tesecase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/348478'
) do ) do
expect_import_finished expect_import_finished
...@@ -248,7 +246,7 @@ module QA ...@@ -248,7 +246,7 @@ module QA
expect(imported_mrs.count).to eq(1) expect(imported_mrs.count).to eq(1)
# TODO: remove custom comparison after member migration is implemented # TODO: remove custom comparison after member migration is implemented
# https://gitlab.com/gitlab-org/gitlab/-/issues/341886 # https://gitlab.com/gitlab-org/gitlab/-/issues/341886
expect(imported_mr.comparable.except(:author)).to eq(source_mr.comparable.except(:author)) expect(imported_mr.comparable.except(:author)).to eq(source_mr.reload!.comparable.except(:author))
expect(imported_mr_comments.count).to eq(1) expect(imported_mr_comments.count).to eq(1)
expect(imported_mr_comments.first[:body]).to include(source_comment[:body]) expect(imported_mr_comments.first[:body]).to include(source_comment[:body])
......
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