Welcome to mirror list, hosted at ThFree Co, Russian Federation.

update_ci_file_with_pipeline_editor_spec.rb « pipeline « 4_verify « browser_ui « features « specs « qa « qa - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7c8567c7729e20653270ce9c6186db6b0d9541d5 (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
# frozen_string_literal: true

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

      let!(:commit) do
        create(:commit, project: project, commit_message: 'Add .gitlab-ci.yml', actions: [
          {
            action: 'create',
            file_path: '.gitlab-ci.yml',
            content: <<~YAML
              'This is to make pipeline fail immediately to save test execution time and resources.'
            YAML
          }
        ])
      end

      let(:new_content) do
        <<~YAML
          'This is to do the exact same thing as the above.'
        YAML
      end

      before do
        Flow::Login.sign_in
        project.visit!
        Support::Waiter.wait_until(message: 'Wait for first pipeline to be created') { project.pipelines.size == 1 }

        edit_ci_file_content_and_create_merge_request
      end

      it 'creates new pipelines, target branch, and merge request',
        testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/349005' do
        # Verify a new MR is created from the update
        Page::MergeRequest::Show.perform do |show|
          expect(show).to have_title('Update .gitlab-ci.yml file')
        end

        # The target branch is also created and new pipeline respectively
        aggregate_failures do
          expect(project).to have_branch(new_branch_name)
          expect { project.pipelines.size > 1 }.to eventually_be_truthy
        end
      end

      private

      def edit_ci_file_content_and_create_merge_request
        Page::Project::Menu.perform(&:go_to_pipeline_editor)
        Support::WaitForRequests.wait_for_requests

        Page::Project::PipelineEditor::Show.perform do |show|
          show.write_to_editor(new_content)
          show.set_source_branch(new_branch_name)
          show.select_new_mr_checkbox
          show.submit_changes
        end

        Page::MergeRequest::New.perform(&:create_merge_request)
      end
    end
  end
end