diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-10 09:09:39 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-10 09:09:39 +0000 |
commit | c52b81f45762cb7f05a950689dfc6d51b197ea73 (patch) | |
tree | c44830c2fc21d13b81814958c44b09fa8d11c805 /spec/frontend | |
parent | 187ee320b39af22929d74c5a2d9b0650bf50a09b (diff) | |
download | gitlab-ce-c52b81f45762cb7f05a950689dfc6d51b197ea73.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend')
-rw-r--r-- | spec/frontend/monitoring/components/charts/time_series_spec.js | 101 |
1 files changed, 70 insertions, 31 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', () => { |