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

pipeline_header.rb « fixtures « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3fdc45b1194d07cb3a78864ef9ee00afddd6e01b (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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe "GraphQL Pipeline Header", '(JavaScript fixtures)', type: :request, feature_category: :pipeline_composition do
  include ApiHelpers
  include GraphqlHelpers
  include JavaScriptFixturesHelpers

  let_it_be(:namespace) { create(:namespace, name: 'frontend-fixtures') }
  let_it_be(:project) { create(:project, :public, :repository) }
  let_it_be(:user) { project.first_owner }
  let_it_be(:commit) { create(:commit, project: project) }

  let(:query_path) { 'pipelines/graphql/queries/get_pipeline_header_data.query.graphql' }

  context 'with successful pipeline' do
    let_it_be(:pipeline) do
      create(
        :ci_pipeline,
        project: project,
        sha: commit.id,
        ref: 'master',
        user: user,
        status: :success,
        duration: 7210,
        created_at: 2.hours.ago,
        started_at: 1.hour.ago,
        finished_at: Time.current
      )
    end

    it "graphql/pipelines/pipeline_header_success.json" do
      query = get_graphql_query_as_string(query_path)

      post_graphql(query, current_user: user, variables: { fullPath: project.full_path, iid: pipeline.iid })

      expect_graphql_errors_to_be_empty
    end
  end

  context 'with running pipeline' do
    let_it_be(:pipeline) do
      create(
        :ci_pipeline,
        project: project,
        sha: commit.id,
        ref: 'master',
        user: user,
        status: :running,
        created_at: 2.hours.ago,
        started_at: 1.hour.ago
      )
    end

    let_it_be(:build) { create(:ci_build, :running, pipeline: pipeline, ref: 'master') }

    it "graphql/pipelines/pipeline_header_running.json" do
      query = get_graphql_query_as_string(query_path)

      post_graphql(query, current_user: user, variables: { fullPath: project.full_path, iid: pipeline.iid })

      expect_graphql_errors_to_be_empty
    end
  end

  context 'with running pipeline and duration' do
    let_it_be(:pipeline) do
      create(
        :ci_pipeline,
        project: project,
        sha: commit.id,
        ref: 'master',
        user: user,
        status: :running,
        duration: 7210,
        created_at: 2.hours.ago,
        started_at: 1.hour.ago
      )
    end

    let_it_be(:build) { create(:ci_build, :running, pipeline: pipeline, ref: 'master') }

    it "graphql/pipelines/pipeline_header_running_with_duration.json" do
      query = get_graphql_query_as_string(query_path)

      post_graphql(query, current_user: user, variables: { fullPath: project.full_path, iid: pipeline.iid })

      expect_graphql_errors_to_be_empty
    end
  end

  context 'with failed pipeline' do
    let_it_be(:pipeline) do
      create(
        :ci_pipeline,
        project: project,
        sha: commit.id,
        ref: 'master',
        user: user,
        status: :failed,
        duration: 7210,
        started_at: 1.hour.ago,
        finished_at: Time.current
      )
    end

    let_it_be(:build) { create(:ci_build, :canceled, pipeline: pipeline, ref: 'master') }

    it "graphql/pipelines/pipeline_header_failed.json" do
      query = get_graphql_query_as_string(query_path)

      post_graphql(query, current_user: user, variables: { fullPath: project.full_path, iid: pipeline.iid })

      expect_graphql_errors_to_be_empty
    end
  end
end