diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-01 21:07:56 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-01 21:07:56 +0300 |
commit | 33aa02e7a38d8dfc5e470dd5d776c8d4ce5b2dd5 (patch) | |
tree | 8cd2bc4711d3a017d839760c7fbea267e2ba4951 /spec | |
parent | 1219a9dce91f4edbc135dfc08299b4122b4825a8 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
7 files changed, 114 insertions, 41 deletions
diff --git a/spec/frontend/blob_edit/blob_bundle_spec.js b/spec/frontend/blob_edit/blob_bundle_spec.js index be438781850..f5cd623ebce 100644 --- a/spec/frontend/blob_edit/blob_bundle_spec.js +++ b/spec/frontend/blob_edit/blob_bundle_spec.js @@ -1,31 +1,72 @@ import $ from 'jquery'; import blobBundle from '~/blob_edit/blob_bundle'; +import { mockTracking, unmockTracking } from 'helpers/tracking_helper'; jest.mock('~/blob_edit/edit_blob'); describe('BlobBundle', () => { - beforeEach(() => { - setFixtures(` + describe('No Suggest Popover', () => { + beforeEach(() => { + setFixtures(` <div class="js-edit-blob-form" data-blob-filename="blah"> <button class="js-commit-button"></button> <a class="btn btn-cancel" href="#"></a> </div>`); - blobBundle(); - }); - it('sets the window beforeunload listener to a function returning a string', () => { - expect(window.onbeforeunload()).toBe(''); - }); + blobBundle(); + }); + + it('sets the window beforeunload listener to a function returning a string', () => { + expect(window.onbeforeunload()).toBe(''); + }); - it('removes beforeunload listener if commit button is clicked', () => { - $('.js-commit-button').click(); + it('removes beforeunload listener if commit button is clicked', () => { + $('.js-commit-button').click(); - expect(window.onbeforeunload).toBeNull(); + expect(window.onbeforeunload).toBeNull(); + }); + + it('removes beforeunload listener when cancel link is clicked', () => { + $('.btn.btn-cancel').click(); + + expect(window.onbeforeunload).toBeNull(); + }); }); - it('removes beforeunload listener when cancel link is clicked', () => { - $('.btn.btn-cancel').click(); + describe('Suggest Popover', () => { + let trackingSpy; + + beforeEach(() => { + setFixtures(` + <div class="js-edit-blob-form" data-blob-filename="blah" id="target"> + <div class="js-suggest-gitlab-ci-yml" + data-target="#target" + data-track-label="suggest_gitlab_ci_yml" + data-dismiss-key="1" + data-human-access="owner"> + <button id='commit-changes' class="js-commit-button"></button> + <a class="btn btn-cancel" href="#"></a> + </div> + </div>`); + + trackingSpy = mockTracking('_category_', $('#commit-changes').element, jest.spyOn); + document.body.dataset.page = 'projects:blob:new'; + + blobBundle(); + }); + + afterEach(() => { + unmockTracking(); + }); + + it('sends a tracking event when the commit button is clicked', () => { + $('#commit-changes').click(); - expect(window.onbeforeunload).toBeNull(); + expect(trackingSpy).toHaveBeenCalledTimes(1); + expect(trackingSpy).toHaveBeenCalledWith(undefined, undefined, { + label: 'suggest_gitlab_ci_yml', + property: 'owner', + }); + }); }); }); diff --git a/spec/frontend/jobs/components/log/mock_data.js b/spec/frontend/jobs/components/log/mock_data.js index cdf5a3e10b1..d92c009756a 100644 --- a/spec/frontend/jobs/components/log/mock_data.js +++ b/spec/frontend/jobs/components/log/mock_data.js @@ -34,7 +34,7 @@ export const utilsMockData = [ content: [ { text: - 'Using Docker executor with image dev.gitlab.org:5005/gitlab/gitlab-build-images:ruby-2.6.5-golang-1.12-git-2.24-lfs-2.9-chrome-73.0-node-12.x-yarn-1.16-postgresql-9.6-graphicsmagick-1.3.34', + 'Using Docker executor with image dev.gitlab.org:5005/gitlab/gitlab-build-images:ruby-2.6.5-golang-1.12-git-2.26-lfs-2.9-chrome-73.0-node-12.x-yarn-1.16-postgresql-9.6-graphicsmagick-1.3.34', }, ], section: 'prepare-executor', diff --git a/spec/frontend/monitoring/components/charts/single_stat_spec.js b/spec/frontend/monitoring/components/charts/single_stat_spec.js index 1aa7ba867b4..fb0682d0338 100644 --- a/spec/frontend/monitoring/components/charts/single_stat_spec.js +++ b/spec/frontend/monitoring/components/charts/single_stat_spec.js @@ -20,25 +20,25 @@ describe('Single Stat Chart component', () => { describe('computed', () => { describe('statValue', () => { it('should interpolate the value and unit props', () => { - expect(singleStatChart.vm.statValue).toBe('91MB'); + expect(singleStatChart.vm.statValue).toBe('91.00MB'); }); it('should change the value representation to a percentile one', () => { singleStatChart.setProps({ graphData: { ...graphDataPrometheusQuery, - max_value: 120, + maxValue: 120, }, }); - expect(singleStatChart.vm.statValue).toContain('75.8'); + expect(singleStatChart.vm.statValue).toContain('75.83%'); }); - it('should display NaN for non numeric max_value values', () => { + it('should display NaN for non numeric maxValue values', () => { singleStatChart.setProps({ graphData: { ...graphDataPrometheusQuery, - max_value: 'not a number', + maxValue: 'not a number', }, }); @@ -60,7 +60,7 @@ describe('Single Stat Chart component', () => { ], }, ], - max_value: 120, + maxValue: 120, }, }); diff --git a/spec/frontend/monitoring/components/charts/time_series_spec.js b/spec/frontend/monitoring/components/charts/time_series_spec.js index 02b59d46c71..129d6eda7cf 100644 --- a/spec/frontend/monitoring/components/charts/time_series_spec.js +++ b/spec/frontend/monitoring/components/charts/time_series_spec.js @@ -1,10 +1,14 @@ -import { shallowMount } from '@vue/test-utils'; +import { mount } from '@vue/test-utils'; import { setTestTimeout } from 'helpers/timeout'; import { GlLink } from '@gitlab/ui'; -import { GlAreaChart, GlLineChart, GlChartSeriesLabel } from '@gitlab/ui/dist/charts'; +import { + GlAreaChart, + GlLineChart, + GlChartSeriesLabel, + GlChartLegend, +} from '@gitlab/ui/dist/charts'; import { cloneDeep } from 'lodash'; import { shallowWrapperContainsSlotText } from 'helpers/vue_test_utils_helper'; -import { chartColorValues } from '~/monitoring/constants'; import { createStore } from '~/monitoring/stores'; import TimeSeries from '~/monitoring/components/charts/time_series.vue'; import * as types from '~/monitoring/stores/mutation_types'; @@ -42,13 +46,16 @@ describe('Time series component', () => { let store; const makeTimeSeriesChart = (graphData, type) => - shallowMount(TimeSeries, { + mount(TimeSeries, { propsData: { graphData: { ...graphData, type }, deploymentData: store.state.monitoringDashboard.deploymentData, projectPath: `${mockHost}${mockProjectDir}`, }, store, + stubs: { + GlPopover: true, + }, }); describe('With a single time series', () => { @@ -308,10 +315,6 @@ describe('Time series component', () => { it('formats line width correctly', () => { expect(chartData[0].lineStyle.width).toBe(2); }); - - it('formats line color correctly', () => { - expect(chartData[0].lineStyle.color).toBe(chartColorValues[0]); - }); }); describe('chartOptions', () => { @@ -557,19 +560,39 @@ describe('Time series component', () => { timeSeriesChart.destroy(); }); - describe('computed', () => { - let chartData; + describe('Color match', () => { + let lineColors; beforeEach(() => { - ({ chartData } = timeSeriesChart.vm); + lineColors = timeSeriesChart + .find(GlAreaChart) + .vm.series.map(item => item.lineStyle.color); + }); + + it('should contain different colors for contiguous time series', () => { + lineColors.forEach((color, index) => { + expect(color).not.toBe(lineColors[index + 1]); + }); }); - it('should contain different colors for each time series', () => { - expect(chartData[0].lineStyle.color).toBe('#1f78d1'); - expect(chartData[1].lineStyle.color).toBe('#1aaa55'); - expect(chartData[2].lineStyle.color).toBe('#fc9403'); - expect(chartData[3].lineStyle.color).toBe('#6d49cb'); - expect(chartData[4].lineStyle.color).toBe('#1f78d1'); + it('should match series color with tooltip label color', () => { + const labels = timeSeriesChart.findAll(GlChartSeriesLabel); + + lineColors.forEach((color, index) => { + const labelColor = labels.at(index).props('color'); + expect(color).toBe(labelColor); + }); + }); + + it('should match series color with legend color', () => { + const legendColors = timeSeriesChart + .find(GlChartLegend) + .props('seriesInfo') + .map(item => item.color); + + lineColors.forEach((color, index) => { + expect(color).toBe(legendColors[index]); + }); }); }); }); diff --git a/spec/frontend/monitoring/store/utils_spec.js b/spec/frontend/monitoring/store/utils_spec.js index 4bbbe33647c..3e83ba2858e 100644 --- a/spec/frontend/monitoring/store/utils_spec.js +++ b/spec/frontend/monitoring/store/utils_spec.js @@ -220,6 +220,15 @@ describe('mapToDashboardViewModel', () => { expect(getMappedPanel().yAxis.format).toBe(SUPPORTED_FORMATS.number); }); + + // This property allows single_stat panels to render percentile values + it('group maxValue', () => { + setupWithPanel({ + max_value: 100, + }); + + expect(getMappedPanel().maxValue).toBe(100); + }); }); describe('metrics mapping', () => { diff --git a/spec/frontend/pages/projects/shared/permissions/components/settings_panel_spec.js b/spec/frontend/pages/projects/shared/permissions/components/settings_panel_spec.js index 76948f3ff4c..d3932ca09ff 100644 --- a/spec/frontend/pages/projects/shared/permissions/components/settings_panel_spec.js +++ b/spec/frontend/pages/projects/shared/permissions/components/settings_panel_spec.js @@ -31,9 +31,9 @@ const defaultProps = { registryAvailable: false, registryHelpPath: '/help/user/packages/container_registry/index', lfsAvailable: true, - lfsHelpPath: '/help/workflow/lfs/manage_large_binaries_with_git_lfs', + lfsHelpPath: '/help/topics/git/lfs/index', lfsObjectsExist: false, - lfsObjectsRemovalHelpPath: `/help/administration/lfs/manage_large_binaries_with_git_lfs#removing-objects-from-lfs`, + lfsObjectsRemovalHelpPath: `/help/topics/git/lfs/index#removing-objects-from-lfs`, pagesAvailable: true, pagesAccessControlEnabled: false, pagesAccessControlForced: false, @@ -363,7 +363,7 @@ describe('Settings Panel', () => { ); expect(link.text()).toEqual('How do I remove them?'); expect(link.attributes('href')).toEqual( - '/help/administration/lfs/manage_large_binaries_with_git_lfs#removing-objects-from-lfs', + '/help/topics/git/lfs/index#removing-objects-from-lfs', ); }); } else { diff --git a/spec/support/shared_examples/tasks/gitlab/import_export/measurable_shared_examples.rb b/spec/support/shared_examples/tasks/gitlab/import_export/measurable_shared_examples.rb index 45b2c5eac3a..5950a1a53e2 100644 --- a/spec/support/shared_examples/tasks/gitlab/import_export/measurable_shared_examples.rb +++ b/spec/support/shared_examples/tasks/gitlab/import_export/measurable_shared_examples.rb @@ -5,7 +5,7 @@ RSpec.shared_examples 'measurable' do let(:measurement_enabled) { true } it 'prints measurement results' do - expect { subject }.to output(including('Measuring enabled...', 'Number of sql calls:', 'Total GC count:', 'Total GC count:')).to_stdout + expect { subject }.to output(including('Measuring enabled...', 'Number of sql calls:', 'GC stats:')).to_stdout end end |