2023-01-13 00:05:48 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require "spec_helper"
|
|
|
|
|
|
|
|
RSpec.describe Groups::ObservabilityHelper do
|
|
|
|
let(:group) { build_stubbed(:group) }
|
|
|
|
|
|
|
|
describe '#observability_iframe_src' do
|
2023-05-27 22:25:52 +05:30
|
|
|
before do
|
|
|
|
allow(Gitlab::Observability).to receive(:build_full_url).and_return('full-url')
|
2023-01-13 00:05:48 +05:30
|
|
|
end
|
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
it 'returns the iframe src for action: dashboards' do
|
|
|
|
allow(helper).to receive(:params).and_return({ action: 'dashboards', observability_path: '/foo?bar=foobar' })
|
|
|
|
expect(helper.observability_iframe_src(group)).to eq('full-url')
|
|
|
|
expect(Gitlab::Observability).to have_received(:build_full_url).with(group, '/foo?bar=foobar', '/')
|
2023-01-13 00:05:48 +05:30
|
|
|
end
|
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
it 'returns the iframe src for action: manage' do
|
|
|
|
allow(helper).to receive(:params).and_return({ action: 'manage', observability_path: '/foo?bar=foobar' })
|
|
|
|
expect(helper.observability_iframe_src(group)).to eq('full-url')
|
|
|
|
expect(Gitlab::Observability).to have_received(:build_full_url).with(group, '/foo?bar=foobar', '/dashboards')
|
|
|
|
end
|
2023-01-13 00:05:48 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
it 'returns the iframe src for action: explore' do
|
|
|
|
allow(helper).to receive(:params).and_return({ action: 'explore', observability_path: '/foo?bar=foobar' })
|
|
|
|
expect(helper.observability_iframe_src(group)).to eq('full-url')
|
|
|
|
expect(Gitlab::Observability).to have_received(:build_full_url).with(group, '/foo?bar=foobar', '/explore')
|
|
|
|
end
|
2023-01-13 00:05:48 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
it 'returns the iframe src for action: datasources' do
|
|
|
|
allow(helper).to receive(:params).and_return({ action: 'datasources', observability_path: '/foo?bar=foobar' })
|
|
|
|
expect(helper.observability_iframe_src(group)).to eq('full-url')
|
|
|
|
expect(Gitlab::Observability).to have_received(:build_full_url).with(group, '/foo?bar=foobar', '/datasources')
|
|
|
|
end
|
2023-01-13 00:05:48 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
it 'returns the iframe src when action is not recognised' do
|
|
|
|
allow(helper).to receive(:params).and_return({ action: 'unrecognised', observability_path: '/foo?bar=foobar' })
|
|
|
|
expect(helper.observability_iframe_src(group)).to eq('full-url')
|
|
|
|
expect(Gitlab::Observability).to have_received(:build_full_url).with(group, '/foo?bar=foobar', '/')
|
|
|
|
end
|
2023-03-17 16:20:25 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
it 'returns the iframe src when observability_path is missing' do
|
|
|
|
allow(helper).to receive(:params).and_return({ action: 'dashboards' })
|
|
|
|
expect(helper.observability_iframe_src(group)).to eq('full-url')
|
|
|
|
expect(Gitlab::Observability).to have_received(:build_full_url).with(group, nil, '/')
|
2023-01-13 00:05:48 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#observability_page_title' do
|
|
|
|
it 'returns the title for action: dashboards' do
|
|
|
|
allow(helper).to receive(:params).and_return({ action: 'dashboards' })
|
|
|
|
expect(helper.observability_page_title).to eq("Dashboards")
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns the title for action: manage' do
|
|
|
|
allow(helper).to receive(:params).and_return({ action: 'manage' })
|
2023-03-17 16:20:25 +05:30
|
|
|
expect(helper.observability_page_title).to eq("Manage dashboards")
|
2023-01-13 00:05:48 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns the title for action: explore' do
|
|
|
|
allow(helper).to receive(:params).and_return({ action: 'explore' })
|
2023-03-17 16:20:25 +05:30
|
|
|
expect(helper.observability_page_title).to eq("Explore telemetry data")
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns the title for action: datasources' do
|
|
|
|
allow(helper).to receive(:params).and_return({ action: 'datasources' })
|
|
|
|
expect(helper.observability_page_title).to eq("Data sources")
|
2023-01-13 00:05:48 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns the default title for unknown action' do
|
|
|
|
allow(helper).to receive(:params).and_return({ action: 'unknown' })
|
|
|
|
expect(helper.observability_page_title).to eq("Dashboards")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|