Commit a369f8e7 authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Merge branch 'rp-add-metrics-button-self-monitor-dashboard' into 'master'

Make "add metrics" button visible on self monitoring dashboard

See merge request gitlab-org/gitlab!36169
parents 19fe2d0e 18aa62ba
...@@ -29,7 +29,7 @@ module Metrics ...@@ -29,7 +29,7 @@ module Metrics
path: DASHBOARD_PATH, path: DASHBOARD_PATH,
display_name: _(DASHBOARD_NAME), display_name: _(DASHBOARD_NAME),
default: true, default: true,
system_dashboard: false, system_dashboard: true,
out_of_the_box_dashboard: out_of_the_box_dashboard? out_of_the_box_dashboard: out_of_the_box_dashboard?
}] }]
end end
......
---
title: Make Add metrics button visible on self monitoring dashboard
merge_request: 36169
author:
type: fixed
...@@ -385,4 +385,72 @@ describe('Dashboard header', () => { ...@@ -385,4 +385,72 @@ describe('Dashboard header', () => {
}); });
}); });
}); });
describe('Add metric button', () => {
const findAddMetricButton = () => wrapper.find('[data-qa-selector="add_metric_button"]');
it('is not rendered when custom metrics are not available', () => {
store.state.monitoringDashboard.emptyState = false;
createShallowWrapper({
customMetricsAvailable: false,
});
setupAllDashboards(store, dashboardGitResponse[0].path);
return wrapper.vm.$nextTick(() => {
expect(findAddMetricButton().exists()).toBe(false);
});
});
it('is not rendered when displaying empty state', () => {
store.state.monitoringDashboard.emptyState = true;
createShallowWrapper({
customMetricsAvailable: true,
});
setupAllDashboards(store, dashboardGitResponse[0].path);
return wrapper.vm.$nextTick(() => {
expect(findAddMetricButton().exists()).toBe(false);
});
});
describe('system dashboards', () => {
const systemDashboards = [
dashboardGitResponse[0].path,
selfMonitoringDashboardGitResponse[0].path,
];
const nonSystemDashboards = [
dashboardGitResponse[1].path,
dashboardGitResponse[2].path,
selfMonitoringDashboardGitResponse[1].path,
];
beforeEach(() => {
store.state.monitoringDashboard.emptyState = false;
createShallowWrapper({
customMetricsAvailable: true,
});
});
test.each(systemDashboards)('is rendered for system dashboards', dashboardPath => {
setupAllDashboards(store, dashboardPath);
return wrapper.vm.$nextTick(() => {
expect(findAddMetricButton().exists()).toBe(true);
});
});
test.each(nonSystemDashboards)('is not rendered for non-system dashboards', dashboardPath => {
setupAllDashboards(store, dashboardPath);
return wrapper.vm.$nextTick(() => {
expect(findAddMetricButton().exists()).toBe(false);
});
});
});
});
}); });
...@@ -209,7 +209,7 @@ export const selfMonitoringDashboardGitResponse = [ ...@@ -209,7 +209,7 @@ export const selfMonitoringDashboardGitResponse = [
default: true, default: true,
display_name: 'Default', display_name: 'Default',
can_edit: false, can_edit: false,
system_dashboard: false, system_dashboard: true,
out_of_the_box_dashboard: true, out_of_the_box_dashboard: true,
project_blob_path: null, project_blob_path: null,
path: 'config/prometheus/self_monitoring_default.yml', path: 'config/prometheus/self_monitoring_default.yml',
......
...@@ -165,7 +165,7 @@ RSpec.describe Gitlab::Metrics::Dashboard::Finder, :use_clean_rails_memory_store ...@@ -165,7 +165,7 @@ RSpec.describe Gitlab::Metrics::Dashboard::Finder, :use_clean_rails_memory_store
path: self_monitoring_dashboard_path, path: self_monitoring_dashboard_path,
display_name: 'Default dashboard', display_name: 'Default dashboard',
default: true, default: true,
system_dashboard: false, system_dashboard: true,
out_of_the_box_dashboard: true out_of_the_box_dashboard: true
} }
end end
......
...@@ -50,7 +50,7 @@ RSpec.describe Metrics::Dashboard::SelfMonitoringDashboardService, :use_clean_ra ...@@ -50,7 +50,7 @@ RSpec.describe Metrics::Dashboard::SelfMonitoringDashboardService, :use_clean_ra
path: described_class::DASHBOARD_PATH, path: described_class::DASHBOARD_PATH,
display_name: described_class::DASHBOARD_NAME, display_name: described_class::DASHBOARD_NAME,
default: true, default: true,
system_dashboard: false, system_dashboard: true,
out_of_the_box_dashboard: true out_of_the_box_dashboard: true
}] }]
) )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment