diff options
Diffstat (limited to 'spec/services/metrics/dashboard/gitlab_alert_embed_service_spec.rb')
-rw-r--r-- | spec/services/metrics/dashboard/gitlab_alert_embed_service_spec.rb | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/spec/services/metrics/dashboard/gitlab_alert_embed_service_spec.rb b/spec/services/metrics/dashboard/gitlab_alert_embed_service_spec.rb index 29c941826b5..dd9d498e307 100644 --- a/spec/services/metrics/dashboard/gitlab_alert_embed_service_spec.rb +++ b/spec/services/metrics/dashboard/gitlab_alert_embed_service_spec.rb @@ -72,12 +72,18 @@ RSpec.describe Metrics::Dashboard::GitlabAlertEmbedService do it_behaves_like 'valid embedded dashboard service response' it_behaves_like 'raises error for users with insufficient permissions' - it 'uses the metric info corresponding to the alert' do + it 'generates an panel based on the alert' do result = service_call - metrics = result[:dashboard][:panel_groups][0][:panels][0][:metrics] - - expect(metrics.length).to eq 1 - expect(metrics.first[:metric_id]).to eq alert.prometheus_metric_id + panel = result[:dashboard][:panel_groups][0][:panels][0] + metric = panel[:metrics].first + + expect(panel[:metrics].length).to eq 1 + expect(panel).to include( + title: alert.prometheus_metric.title, + y_label: alert.prometheus_metric.y_label, + type: 'area-chart' + ) + expect(metric[:metric_id]).to eq alert.prometheus_metric_id end context 'when the metric does not exist' do @@ -87,7 +93,8 @@ RSpec.describe Metrics::Dashboard::GitlabAlertEmbedService do end it 'does not cache the unprocessed dashboard' do - expect(Gitlab::Metrics::Dashboard::Cache).not_to receive(:fetch) + # Fail spec if any method of Cache class is called. + stub_const('Gitlab::Metrics::Dashboard::Cache', double) described_class.new(*service_params).get_dashboard end |