Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-10 12:09:39 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-10 12:09:39 +0300
commitc52b81f45762cb7f05a950689dfc6d51b197ea73 (patch)
treec44830c2fc21d13b81814958c44b09fa8d11c805 /spec
parent187ee320b39af22929d74c5a2d9b0650bf50a09b (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/frontend/monitoring/components/charts/time_series_spec.js101
-rw-r--r--spec/lib/gitlab/alerting/alert_spec.rb10
-rw-r--r--spec/services/metrics/dashboard/custom_metric_embed_service_spec.rb25
3 files changed, 90 insertions, 46 deletions
diff --git a/spec/frontend/monitoring/components/charts/time_series_spec.js b/spec/frontend/monitoring/components/charts/time_series_spec.js
index c9b670fd7a8..3aad4c87237 100644
--- a/spec/frontend/monitoring/components/charts/time_series_spec.js
+++ b/spec/frontend/monitoring/components/charts/time_series_spec.js
@@ -155,43 +155,56 @@ describe('Time series component', () => {
describe('methods', () => {
describe('formatTooltipText', () => {
- let mockDate;
- let mockCommitUrl;
- let generateSeriesData;
-
- beforeEach(() => {
- mockDate = deploymentData[0].created_at;
- mockCommitUrl = deploymentData[0].commitUrl;
- generateSeriesData = type => ({
- seriesData: [
- {
- seriesName: timeSeriesChart.vm.chartData[0].name,
- componentSubType: type,
- value: [mockDate, 5.55555],
- dataIndex: 0,
- ...(type === 'scatter' && { name: 'deployments' }),
- },
- ],
- value: mockDate,
- });
+ const mockCommitUrl = deploymentData[0].commitUrl;
+ const mockDate = deploymentData[0].created_at;
+ const mockSha = 'f5bcd1d9';
+ const mockLineSeriesData = () => ({
+ seriesData: [
+ {
+ seriesName: timeSeriesChart.vm.chartData[0].name,
+ componentSubType: 'line',
+ value: [mockDate, 5.55555],
+ dataIndex: 0,
+ },
+ ],
+ value: mockDate,
});
+ const annotationsMetadata = {
+ tooltipData: {
+ sha: mockSha,
+ commitUrl: mockCommitUrl,
+ },
+ };
+
+ const mockAnnotationsSeriesData = {
+ seriesData: [
+ {
+ componentSubType: 'scatter',
+ seriesName: 'series01',
+ dataIndex: 0,
+ value: [mockDate, 5.55555],
+ type: 'scatter',
+ name: 'deployments',
+ },
+ ],
+ value: mockDate,
+ };
+
it('does not throw error if data point is outside the zoom range', () => {
- const seriesDataWithoutValue = generateSeriesData('line');
- expect(
- timeSeriesChart.vm.formatTooltipText({
- ...seriesDataWithoutValue,
- seriesData: seriesDataWithoutValue.seriesData.map(data => ({
- ...data,
- value: undefined,
- })),
- }),
- ).toBeUndefined();
+ const seriesDataWithoutValue = {
+ ...mockLineSeriesData(),
+ seriesData: mockLineSeriesData().seriesData.map(data => ({
+ ...data,
+ value: undefined,
+ })),
+ };
+ expect(timeSeriesChart.vm.formatTooltipText(seriesDataWithoutValue)).toBeUndefined();
});
describe('when series is of line type', () => {
beforeEach(done => {
- timeSeriesChart.vm.formatTooltipText(generateSeriesData('line'));
+ timeSeriesChart.vm.formatTooltipText(mockLineSeriesData());
timeSeriesChart.vm.$nextTick(done);
});
@@ -223,7 +236,14 @@ describe('Time series component', () => {
describe('when series is of scatter type, for deployments', () => {
beforeEach(() => {
- timeSeriesChart.vm.formatTooltipText(generateSeriesData('scatter'));
+ timeSeriesChart.vm.formatTooltipText({
+ ...mockAnnotationsSeriesData,
+ seriesData: mockAnnotationsSeriesData.seriesData.map(data => ({
+ ...data,
+ data: annotationsMetadata,
+ })),
+ });
+ return timeSeriesChart.vm.$nextTick;
});
it('set tooltip type to deployments', () => {
@@ -242,6 +262,25 @@ describe('Time series component', () => {
expect(timeSeriesChart.vm.tooltip.commitUrl).toBe(mockCommitUrl);
});
});
+
+ describe('when series is of scatter type and deployments data is missing', () => {
+ beforeEach(() => {
+ timeSeriesChart.vm.formatTooltipText(mockAnnotationsSeriesData);
+ return timeSeriesChart.vm.$nextTick;
+ });
+
+ it('formats tooltip title', () => {
+ expect(timeSeriesChart.vm.tooltip.title).toBe('16 Jul 2019, 10:14AM');
+ });
+
+ it('formats tooltip sha', () => {
+ expect(timeSeriesChart.vm.tooltip.sha).toBeUndefined();
+ });
+
+ it('formats tooltip commit url', () => {
+ expect(timeSeriesChart.vm.tooltip.commitUrl).toBeUndefined();
+ });
+ });
});
describe('setSvg', () => {
diff --git a/spec/lib/gitlab/alerting/alert_spec.rb b/spec/lib/gitlab/alerting/alert_spec.rb
index aaded28954e..8b67cf949ce 100644
--- a/spec/lib/gitlab/alerting/alert_spec.rb
+++ b/spec/lib/gitlab/alerting/alert_spec.rb
@@ -192,6 +192,16 @@ describe Gitlab::Alerting::Alert do
end
end
+ describe '#y_label' do
+ subject { alert.y_label }
+
+ it_behaves_like 'parse payload', 'annotations/gitlab_y_label'
+
+ context 'when y_label is not included in the payload' do
+ it_behaves_like 'parse payload', 'annotations/title'
+ end
+ end
+
describe '#alert_markdown' do
subject { alert.alert_markdown }
diff --git a/spec/services/metrics/dashboard/custom_metric_embed_service_spec.rb b/spec/services/metrics/dashboard/custom_metric_embed_service_spec.rb
index 2f03d18cd1f..1a9ddc87ab0 100644
--- a/spec/services/metrics/dashboard/custom_metric_embed_service_spec.rb
+++ b/spec/services/metrics/dashboard/custom_metric_embed_service_spec.rb
@@ -121,11 +121,18 @@ describe Metrics::Dashboard::CustomMetricEmbedService do
it_behaves_like 'valid embedded dashboard service response'
- it 'includes both metrics' do
+ it 'includes both metrics in a single panel' do
result = service_call
- included_queries = all_queries(result[:dashboard])
- expect(included_queries).to include('avg(metric_2)', 'avg(metric)')
+ panel_groups = result[:dashboard][:panel_groups]
+ panels = panel_groups[0][:panels]
+ metrics = panels[0][:metrics]
+ queries = metrics.map { |metric| metric[:query_range] }
+
+ expect(panel_groups.length).to eq(1)
+ expect(panels.length).to eq(1)
+ expect(metrics.length).to eq(2)
+ expect(queries).to include('avg(metric_2)', 'avg(metric)')
end
end
end
@@ -136,16 +143,4 @@ describe Metrics::Dashboard::CustomMetricEmbedService do
it_behaves_like 'misconfigured dashboard service response', :not_found
end
end
-
- private
-
- def all_queries(dashboard)
- dashboard[:panel_groups].flat_map do |group|
- group[:panels].flat_map do |panel|
- panel[:metrics].map do |metric|
- metric[:query_range]
- end
- end
- end
- end
end