blob: 8996ea7f8d6486de5970355284161fc337ab4721 (
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
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Projects::TracingController, feature_category: :tracing do
let_it_be(:group) { create(:group) }
let_it_be(:project) { create(:project, group: group) }
let_it_be(:user) { create(:user) }
let(:path) { nil }
let(:observability_tracing_ff) { true }
subject do
get path
response
end
before do
stub_feature_flags(observability_tracing: observability_tracing_ff)
sign_in(user)
end
shared_examples 'tracing route request' do
it_behaves_like 'observability csp policy' do
before_all do
project.add_developer(user)
end
let(:tested_path) { path }
end
context 'when user does not have permissions' do
it 'returns 404' do
expect(subject).to have_gitlab_http_status(:not_found)
end
end
context 'when user has permissions' do
before_all do
project.add_developer(user)
end
it 'returns 200' do
expect(subject).to have_gitlab_http_status(:ok)
end
context 'when feature is disabled' do
let(:observability_tracing_ff) { false }
it 'returns 404' do
expect(subject).to have_gitlab_http_status(:not_found)
end
end
end
end
describe 'GET #index' do
let(:path) { project_tracing_index_path(project) }
it_behaves_like 'tracing route request'
describe 'html response' do
before_all do
project.add_developer(user)
end
it 'renders the js-tracing element correctly' do
element = Nokogiri::HTML.parse(subject.body).at_css('#js-tracing')
expected_view_model = {
tracingUrl: Gitlab::Observability.tracing_url(project),
provisioningUrl: Gitlab::Observability.provisioning_url(project),
oauthUrl: Gitlab::Observability.oauth_url
}.to_json
expect(element.attributes['data-view-model'].value).to eq(expected_view_model)
end
end
end
describe 'GET #show' do
let(:path) { project_tracing_path(project, id: "test-trace-id") }
it_behaves_like 'tracing route request'
describe 'html response' do
before_all do
project.add_developer(user)
end
it 'renders the js-tracing element correctly' do
element = Nokogiri::HTML.parse(subject.body).at_css('#js-tracing-details')
expected_view_model = {
tracingIndexUrl: project_tracing_index_path(project),
traceId: 'test-trace-id',
tracingUrl: Gitlab::Observability.tracing_url(project),
provisioningUrl: Gitlab::Observability.provisioning_url(project),
oauthUrl: Gitlab::Observability.oauth_url
}.to_json
expect(element.attributes['data-view-model'].value).to eq(expected_view_model)
end
end
end
end
|