diff options
Diffstat (limited to 'spec/lib/banzai/filter/inline_grafana_metrics_filter_spec.rb')
-rw-r--r-- | spec/lib/banzai/filter/inline_grafana_metrics_filter_spec.rb | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/spec/lib/banzai/filter/inline_grafana_metrics_filter_spec.rb b/spec/lib/banzai/filter/inline_grafana_metrics_filter_spec.rb index fd6f8816b63..9ac06a90efd 100644 --- a/spec/lib/banzai/filter/inline_grafana_metrics_filter_spec.rb +++ b/spec/lib/banzai/filter/inline_grafana_metrics_filter_spec.rb @@ -8,40 +8,26 @@ describe Banzai::Filter::InlineGrafanaMetricsFilter do let_it_be(:project) { create(:project) } let_it_be(:grafana_integration) { create(:grafana_integration, project: project) } - let(:input) { %(<a href="#{url}">example</a>) } + let(:input) { %(<a href="#{trigger_url}">example</a>) } let(:doc) { filter(input) } - - let(:url) { grafana_integration.grafana_url + dashboard_path } let(:dashboard_path) do '/d/XDaNK6amz/gitlab-omnibus-redis' \ '?from=1570397739557&to=1570484139557' \ '&var-instance=All&panelId=14' end - it 'appends a metrics charts placeholder with dashboard url after metrics links' do - node = doc.at_css('.js-render-metrics') - expect(node).to be_present - - dashboard_url = urls.project_grafana_api_metrics_dashboard_url( + let(:trigger_url) { grafana_integration.grafana_url + dashboard_path } + let(:dashboard_url) do + urls.project_grafana_api_metrics_dashboard_url( project, embedded: true, - grafana_url: url, + grafana_url: trigger_url, start: "2019-10-06T21:35:39Z", end: "2019-10-07T21:35:39Z" ) - - expect(node.attribute('data-dashboard-url').to_s).to eq(dashboard_url) end - context 'when the dashboard link is part of a paragraph' do - let(:paragraph) { %(This is an <a href="#{url}">example</a> of metrics.) } - let(:input) { %(<p>#{paragraph}</p>) } - - it 'appends the charts placeholder after the enclosing paragraph' do - expect(unescape(doc.at_css('p').to_s)).to include(paragraph) - expect(doc.at_css('.js-render-metrics')).to be_present - end - end + it_behaves_like 'a metrics embed filter' context 'when grafana is not configured' do before do |