summaryrefslogtreecommitdiff
path: root/qa/qa/specs/features/api/1_manage/migration/gitlab_migration_issue_spec.rb
blob: bb4b04723980e7ca59a1c9a835242e7c325695d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# frozen_string_literal: true

require_relative 'gitlab_project_migration_common'

module QA
  RSpec.describe 'Manage' do
    describe 'Gitlab migration' do
      include_context 'with gitlab project migration'

      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!(:source_comment) { source_issue.add_comment(body: 'This is a test comment!') }

        let(:imported_issues) { imported_projects.first.issues }

        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

        let(:imported_comments) { imported_issue.comments }

        it(
          'successfully imports issue',
          testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347608'
        ) do
          expect_import_finished
          expect(imported_issues.count).to eq(1)

          aggregate_failures do
            expect(imported_issue).to eq(source_issue.reload!)

            expect(imported_comments.count).to eq(1)
            expect(imported_comments.first&.fetch(:body)).to include(source_comment[:body])
          end
        end
      end
    end
  end
end