summaryrefslogtreecommitdiff
path: root/qa/qa/specs/features/api/1_manage/migration/gitlab_migration_pipeline_spec.rb
blob: 3db4ff4351ec5a06c0d9e27a6f9dd23fdd00192c (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
52
53
54
55
56
57
58
59
# frozen_string_literal: true

require_relative 'gitlab_project_migration_common'

module QA
  RSpec.describe 'Manage' do
    describe 'Gitlab migration', product_group: :import do
      include_context 'with gitlab project migration'

      context 'with ci pipeline' do
        let!(:source_project_with_readme) { true }

        let(:source_pipelines) do
          source_project.pipelines.map do |pipeline|
            pipeline.except(:id, :web_url, :project_id)
          end
        end

        let(:imported_pipelines) do
          imported_project.pipelines.map do |pipeline|
            pipeline.except(:id, :web_url, :project_id)
          end
        end

        before do
          Resource::Repository::Commit.fabricate_via_api! do |commit|
            commit.api_client = api_client
            commit.project = source_project
            commit.commit_message = 'Add .gitlab-ci.yml'
            commit.add_files(
              [
                {
                  file_path: '.gitlab-ci.yml',
                  content: <<~YML
                    test-success:
                      script: echo 'OK'
                  YML
                }
              ]
            )
          end

          Support::Waiter.wait_until(max_duration: 10, sleep_interval: 1) do
            !source_project.pipelines.empty?
          end
        end

        it(
          'successfully imports ci pipeline',
          testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/354650'
        ) do
          expect_import_finished

          expect(imported_pipelines).to eq(source_pipelines)
        end
      end
    end
  end
end