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
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Observability rendering', :js, feature_category: :metrics do
let_it_be(:group) { create(:group, :public) }
let_it_be(:project) { create(:project, :repository, group: group) }
let_it_be(:user) { create(:user) }
let_it_be(:observable_url) { "https://observe.gitlab.com/#{group.id}/some-dashboard" }
let_it_be(:expected) do
%(<iframe src="#{observable_url}?theme=light&kiosk" frameborder="0")
end
before do
group.add_developer(user)
sign_in(user)
end
context 'when user is a developer of the embedded group' do
context 'when embedding in an issue' do
let(:issue) do
create(:issue, project: project, description: observable_url)
end
before do
visit project_issue_path(project, issue)
wait_for_requests
end
it_behaves_like 'embeds observability'
end
context 'when embedding in an MR' do
let(:merge_request) do
create(:merge_request, source_project: project, target_project: project, description: observable_url)
end
before do
visit merge_request_path(merge_request)
wait_for_requests
end
it_behaves_like 'embeds observability'
end
end
shared_examples 'does not embed observability in issues and MRs' do
context 'when embedding in an issue' do
let(:issue) do
create(:issue, project: project, description: observable_url)
end
before do
visit project_issue_path(project, issue)
wait_for_requests
end
it_behaves_like 'does not embed observability'
end
context 'when embedding in an MR' do
let(:merge_request) do
create(:merge_request, source_project: project, target_project: project, description: observable_url)
end
before do
visit merge_request_path(merge_request)
wait_for_requests
end
it_behaves_like 'does not embed observability'
end
end
context 'when user is not a developer of the embeded group' do
it_behaves_like 'does not embed observability in issues and MRs' do
let_it_be(:observable_url) { "https://observe.gitlab.com/1234/some-dashboard" }
end
end
context 'when feature flag is disabled' do
before do
stub_feature_flags(observability_group_tab: false)
end
it_behaves_like 'does not embed observability in issues and MRs'
end
end
|