summaryrefslogtreecommitdiff
path: root/qa/qa/specs/features/browser_ui/4_verify/pipeline/update_ci_file_with_pipeline_editor_spec.rb
blob: a749da4608a1c7c51f46f7e57cdcb4d617f24ba1 (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# frozen_string_literal: true

module QA
  RSpec.describe 'Verify' do
    describe 'Update CI file with pipeline editor', product_group: :pipeline_authoring do
      let(:random_test_string) { SecureRandom.hex(10) }

      let(:project) do
        Resource::Project.fabricate_via_api! do |project|
          project.name = 'pipeline-editor-project'
        end
      end

      let!(:runner) do
        Resource::ProjectRunner.fabricate_via_api! do |runner|
          runner.project = project
          runner.name = random_test_string
          runner.tags = [random_test_string]
        end
      end

      let!(:commit) do
        Resource::Repository::Commit.fabricate_via_api! do |commit|
          commit.project = project
          commit.commit_message = 'Add .gitlab-ci.yml'
          commit.add_files(
            [
              {
                file_path: '.gitlab-ci.yml',
                content: <<~YAML
                  test_job:
                    tags: ['#{random_test_string}']
                    script:
                      - echo "Simple test!"
                YAML
              }
            ]
          )
        end
      end

      before do
        Flow::Login.sign_in
        project.visit!
        Support::Waiter.wait_until { !project.pipelines.empty? && project.pipelines.first[:status] == 'success' }
        Page::Project::Menu.perform(&:go_to_pipeline_editor)
      end

      after do
        [runner, project].each(&:remove_via_api!)
      end

      it 'creates new pipeline and target branch', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/349005' do
        Page::Project::PipelineEditor::Show.perform do |show|
          show.write_to_editor(random_test_string)
          show.set_source_branch(random_test_string)
          show.submit_changes

          Support::Waiter.wait_until { project.pipelines.size > 1 }

          aggregate_failures do
            expect(show.source_branch_name).to eq(random_test_string)
            expect(show.current_branch).to eq(random_test_string)
            expect(show.editing_content).to have_content(random_test_string)
            expect { show.pipeline_id }.to eventually_eq(project.pipelines.pluck(:id).max).within(max_duration: 60, sleep_interval: 3)
          end
        end

        expect(project).to have_branch(random_test_string)
      end
    end
  end
end