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
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-09 12:10:17 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-09 12:10:17 +0300
commitad0265eead72a624ce7a020847db4f0f0c877e57 (patch)
tree206e0564b02aa9530e3c95f70eb10a77e074bdf0 /spec/frontend/monitoring
parent4dfc8711171fe0c04bc6b8b224687603026dea46 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/monitoring')
-rw-r--r--spec/frontend/monitoring/components/charts/annotations_spec.js73
-rw-r--r--spec/frontend/monitoring/components/charts/time_series_spec.js11
-rw-r--r--spec/frontend/monitoring/mock_data.js24
3 files changed, 102 insertions, 6 deletions
diff --git a/spec/frontend/monitoring/components/charts/annotations_spec.js b/spec/frontend/monitoring/components/charts/annotations_spec.js
index 100b13eabf4..69bf1fe4ced 100644
--- a/spec/frontend/monitoring/components/charts/annotations_spec.js
+++ b/spec/frontend/monitoring/components/charts/annotations_spec.js
@@ -1,27 +1,90 @@
import { generateAnnotationsSeries } from '~/monitoring/components/charts/annotations';
-import { deploymentData } from '../../mock_data';
+import { deploymentData, annotationsData } from '../../mock_data';
describe('annotations spec', () => {
describe('generateAnnotationsSeries', () => {
- it('default options', () => {
+ it('with default options', () => {
const annotations = generateAnnotationsSeries();
- expect(annotations).toEqual([]);
+
+ expect(annotations).toEqual(
+ expect.objectContaining({
+ type: 'scatter',
+ yAxisIndex: 1,
+ data: [],
+ markLine: {
+ data: [],
+ symbol: 'none',
+ silent: true,
+ },
+ }),
+ );
});
- it('with deployments', () => {
- const annotations = generateAnnotationsSeries(deploymentData);
+ it('when only deployments data is passed', () => {
+ const annotations = generateAnnotationsSeries({ deployments: deploymentData });
expect(annotations).toEqual(
expect.objectContaining({
type: 'scatter',
yAxisIndex: 1,
data: expect.any(Array),
+ markLine: {
+ data: [],
+ symbol: 'none',
+ silent: true,
+ },
}),
);
annotations.data.forEach(annotation => {
expect(annotation).toEqual(expect.any(Object));
});
+
+ expect(annotations.data).toHaveLength(deploymentData.length);
+ });
+
+ it('when only annotations data is passed', () => {
+ const annotations = generateAnnotationsSeries({
+ annotations: annotationsData,
+ });
+
+ expect(annotations).toEqual(
+ expect.objectContaining({
+ type: 'scatter',
+ yAxisIndex: 1,
+ data: expect.any(Array),
+ markLine: expect.any(Object),
+ }),
+ );
+
+ annotations.markLine.data.forEach(annotation => {
+ expect(annotation).toEqual(expect.any(Object));
+ });
+
+ expect(annotations.data).toHaveLength(annotationsData.length);
+ expect(annotations.markLine.data).toHaveLength(annotationsData.length);
+ });
+
+ it('when deploments and annotations data is passed', () => {
+ const annotations = generateAnnotationsSeries({
+ deployments: deploymentData,
+ annotations: annotationsData,
+ });
+
+ expect(annotations).toEqual(
+ expect.objectContaining({
+ type: 'scatter',
+ yAxisIndex: 1,
+ data: expect.any(Array),
+ markLine: expect.any(Object),
+ }),
+ );
+
+ annotations.markLine.data.forEach(annotation => {
+ expect(annotation).toEqual(expect.any(Object));
+ });
+
+ expect(annotations.data).toHaveLength(deploymentData.length + annotationsData.length);
});
});
});
diff --git a/spec/frontend/monitoring/components/charts/time_series_spec.js b/spec/frontend/monitoring/components/charts/time_series_spec.js
index f2478a583dc..c9b670fd7a8 100644
--- a/spec/frontend/monitoring/components/charts/time_series_spec.js
+++ b/spec/frontend/monitoring/components/charts/time_series_spec.js
@@ -169,6 +169,7 @@ describe('Time series component', () => {
componentSubType: type,
value: [mockDate, 5.55555],
dataIndex: 0,
+ ...(type === 'scatter' && { name: 'deployments' }),
},
],
value: mockDate,
@@ -225,6 +226,10 @@ describe('Time series component', () => {
timeSeriesChart.vm.formatTooltipText(generateSeriesData('scatter'));
});
+ it('set tooltip type to deployments', () => {
+ expect(timeSeriesChart.vm.tooltip.type).toBe('deployments');
+ });
+
it('formats tooltip title', () => {
expect(timeSeriesChart.vm.tooltip.title).toBe('16 Jul 2019, 10:14AM');
});
@@ -521,7 +526,11 @@ describe('Time series component', () => {
const commitUrl = `${mockProjectDir}/-/commit/${mockSha}`;
beforeEach(done => {
- timeSeriesAreaChart.vm.tooltip.isDeployment = true;
+ timeSeriesAreaChart.setData({
+ tooltip: {
+ type: 'deployments',
+ },
+ });
timeSeriesAreaChart.vm.$nextTick(done);
});
diff --git a/spec/frontend/monitoring/mock_data.js b/spec/frontend/monitoring/mock_data.js
index dde47178c1d..c9f2b110147 100644
--- a/spec/frontend/monitoring/mock_data.js
+++ b/spec/frontend/monitoring/mock_data.js
@@ -210,6 +210,30 @@ export const deploymentData = [
},
];
+export const annotationsData = [
+ {
+ id: 'gid://gitlab/Metrics::Dashboard::Annotation/1',
+ from: '2020-04-01T12:51:58.373Z',
+ to: null,
+ panelId: null,
+ description: 'This is a test annotation',
+ },
+ {
+ id: 'gid://gitlab/Metrics::Dashboard::Annotation/2',
+ description: 'test annotation 2',
+ from: '2020-04-02T12:51:58.373Z',
+ to: null,
+ panelId: null,
+ },
+ {
+ id: 'gid://gitlab/Metrics::Dashboard::Annotation/3',
+ description: 'test annotation 3',
+ from: '2020-04-04T12:51:58.373Z',
+ to: null,
+ panelId: null,
+ },
+];
+
export const metricsNewGroupsAPIResponse = [
{
group: 'System metrics (Kubernetes)',