debian-mirror-gitlab/spec/requests/groups/observability_controller_spec.rb

88 lines
2.5 KiB
Ruby
Raw Normal View History

2022-10-11 01:57:18 +05:30
# frozen_string_literal: true
require 'spec_helper'
2023-03-04 22:38:38 +05:30
RSpec.describe Groups::ObservabilityController, feature_category: :tracing do
2022-10-11 01:57:18 +05:30
let_it_be(:group) { create(:group) }
let_it_be(:user) { create(:user) }
2023-01-13 00:05:48 +05:30
let(:observability_url) { Gitlab::Observability.observability_url }
2023-03-04 22:38:38 +05:30
let(:path) { nil }
let(:expected_observability_path) { nil }
2022-10-11 01:57:18 +05:30
2023-01-13 00:05:48 +05:30
shared_examples 'observability route request' do
subject do
get path
response
2022-10-11 01:57:18 +05:30
end
2023-03-04 22:38:38 +05:30
it_behaves_like 'observability csp policy' do
let(:tested_path) { path }
end
2023-01-13 00:05:48 +05:30
context 'when user is not authenticated' do
2022-10-11 01:57:18 +05:30
it 'returns 404' do
expect(subject).to have_gitlab_http_status(:not_found)
end
end
context 'when user is not a developer' do
before do
sign_in(user)
end
it 'returns 404' do
expect(subject).to have_gitlab_http_status(:not_found)
end
end
context 'when user is authenticated and a developer' do
before do
sign_in(user)
group.add_developer(user)
end
2023-01-13 00:05:48 +05:30
context 'when observability url is missing' do
before do
allow(Gitlab::Observability).to receive(:observability_url).and_return("")
end
it 'returns 404' do
expect(subject).to have_gitlab_http_status(:not_found)
end
end
2022-10-11 01:57:18 +05:30
it 'returns 200' do
expect(subject).to have_gitlab_http_status(:ok)
end
it 'renders the proper layout' do
expect(subject).to render_template("layouts/group")
expect(subject).to render_template("layouts/fullscreen")
expect(subject).not_to render_template('layouts/nav/breadcrumbs')
expect(subject).to render_template("nav/sidebar/_group")
2023-01-13 00:05:48 +05:30
expect(subject).to render_template("groups/observability/observability")
2022-10-11 01:57:18 +05:30
end
2023-01-13 00:05:48 +05:30
it 'renders the js-observability-app element correctly' do
element = Nokogiri::HTML.parse(subject.body).at_css('#js-observability-app')
expect(element.attributes['data-observability-iframe-src'].value).to eq(expected_observability_path)
2022-10-11 01:57:18 +05:30
end
2023-01-13 00:05:48 +05:30
end
end
2022-10-11 01:57:18 +05:30
2023-03-17 16:20:25 +05:30
describe 'GET #explore' do
let(:path) { group_observability_explore_path(group) }
let(:expected_observability_path) { "#{observability_url}/-/#{group.id}/explore" }
2022-10-11 01:57:18 +05:30
2023-01-13 00:05:48 +05:30
it_behaves_like 'observability route request'
end
2022-10-11 01:57:18 +05:30
2023-03-17 16:20:25 +05:30
describe 'GET #datasources' do
let(:path) { group_observability_datasources_path(group) }
let(:expected_observability_path) { "#{observability_url}/-/#{group.id}/datasources" }
2022-10-11 01:57:18 +05:30
2023-01-13 00:05:48 +05:30
it_behaves_like 'observability route request'
end
2022-10-11 01:57:18 +05:30
end