summaryrefslogtreecommitdiff
path: root/spec/support/helpers/metrics_dashboard_helpers.rb
blob: b8a641d5911ebd0a9039d9f65beab445f1a37121 (plain)
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
# frozen_string_literal: true

module MetricsDashboardHelpers
  def project_with_dashboard(dashboard_path, dashboard_yml = nil)
    dashboard_yml ||= fixture_file('lib/gitlab/metrics/dashboard/sample_dashboard.yml')

    create(:project, :custom_repo, files: { dashboard_path => dashboard_yml })
  end

  def delete_project_dashboard(project, user, dashboard_path)
    project.repository.delete_file(
      user,
      dashboard_path,
      branch_name: 'master',
      message: 'Delete dashboard'
    )

    project.repository.refresh_method_caches([:metrics_dashboard])
  end

  def system_dashboard_path
    Metrics::Dashboard::SystemDashboardService::DASHBOARD_PATH
  end

  def pod_dashboard_path
    Metrics::Dashboard::PodDashboardService::DASHBOARD_PATH
  end

  def business_metric_title
    PrometheusMetricEnums.group_details[:business][:group_title]
  end

  def self_monitoring_dashboard_path
    Metrics::Dashboard::SelfMonitoringDashboardService::DASHBOARD_PATH
  end
end