summaryrefslogtreecommitdiff
path: root/qa/qa/specs/features/browser_ui/4_verify/pipeline/create_and_process_pipeline_spec.rb
blob: 25cbe41c6842a59e2a9ccc01dcaefae8f3658ed2 (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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# frozen_string_literal: true

module QA
  context 'Verify', :orchestrated, :docker do
    describe 'Pipeline creation and processing' do
      let(:executor) { "qa-runner-#{Time.now.to_i}" }

      after do
        Service::Runner.new(executor).remove!
      end

      it 'users creates a pipeline which gets processed' do
        Runtime::Browser.visit(:gitlab, Page::Main::Login)
        Page::Main::Login.act { sign_in_using_credentials }

        project = Resource::Project.fabricate! do |project|
          project.name = 'project-with-pipelines'
          project.description = 'Project with CI/CD Pipelines.'
        end

        Resource::Runner.fabricate! do |runner|
          runner.project = project
          runner.name = executor
          runner.tags = %w[qa test]
        end

        Resource::Repository::ProjectPush.fabricate! do |push|
          push.project = project
          push.file_name = '.gitlab-ci.yml'
          push.commit_message = 'Add .gitlab-ci.yml'
          push.file_content = <<~EOF
            test-success:
              tags:
                - qa
                - test
              script: echo 'OK'

            test-failure:
              tags:
                - qa
                - test
              script:
                - echo 'FAILURE'
                - exit 1

            test-tags:
              tags:
                - qa
                - docker
              script: echo 'NOOP'

            test-artifacts:
              tags:
                - qa
                - test
              script: mkdir my-artifacts; echo "CONTENTS" > my-artifacts/artifact.txt
              artifacts:
                paths:
                - my-artifacts/
          EOF
        end

        Page::Project::Show.act { wait_for_push }

        expect(page).to have_content('Add .gitlab-ci.yml')

        Page::Project::Menu.act { click_ci_cd_pipelines }

        expect(page).to have_content('All 1')
        expect(page).to have_content('Add .gitlab-ci.yml')

        puts 'Waiting for the runner to process the pipeline'
        sleep 15 # Runner should process all jobs within 15 seconds.

        Page::Project::Pipeline::Index.act { go_to_latest_pipeline }

        Page::Project::Pipeline::Show.perform do |pipeline|
          expect(pipeline).to be_running
          expect(pipeline).to have_build('test-success', status: :success)
          expect(pipeline).to have_build('test-failure', status: :failed)
          expect(pipeline).to have_build('test-tags', status: :pending)
          expect(pipeline).to have_build('test-artifacts', status: :success)
        end
      end
    end
  end
end