From 6e91fbf77476011a7fd86ca3467aad6d7b110ff3 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Tue, 13 Oct 2020 12:08:41 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- .../components/instance_counts_spec.js | 6 +- .../analytics/instance_statistics/mock_data.js | 28 ++++- .../analytics/instance_statistics/utils_spec.js | 41 +++++++ .../remove_cluster_confirmation_spec.js.snap | 90 ++++++++++++--- .../ide/components/commit_sidebar/form_spec.js | 37 +++++-- spec/frontend/ide/lib/errors_spec.js | 46 +++----- spec/frontend/ide/stores/getters_spec.js | 10 +- .../ide/stores/modules/commit/actions_spec.js | 82 +++++++------- spec/frontend/ide/utils_spec.js | 40 +++++++ .../incidents/components/incidents_list_spec.js | 18 ++- .../components/issuable_description_spec.js | 41 +++++++ .../components/issuable_edit_form_spec.js | 122 +++++++++++++++++++++ .../components/issuable_title_spec.js | 100 +++++++++++++++++ spec/frontend/monitoring/router_spec.js | 3 +- .../components/composer_installation_spec.js | 7 +- .../packages/details/store/getters_spec.js | 26 ++++- .../__snapshots__/split_button_spec.js.snap | 37 +++++-- .../vue_shared/components/split_button_spec.js | 6 +- 18 files changed, 602 insertions(+), 138 deletions(-) create mode 100644 spec/frontend/analytics/instance_statistics/utils_spec.js create mode 100644 spec/frontend/issuable_show/components/issuable_description_spec.js create mode 100644 spec/frontend/issuable_show/components/issuable_edit_form_spec.js create mode 100644 spec/frontend/issuable_show/components/issuable_title_spec.js (limited to 'spec/frontend') diff --git a/spec/frontend/analytics/instance_statistics/components/instance_counts_spec.js b/spec/frontend/analytics/instance_statistics/components/instance_counts_spec.js index 2274f4c3fde..12b5e14b9c4 100644 --- a/spec/frontend/analytics/instance_statistics/components/instance_counts_spec.js +++ b/spec/frontend/analytics/instance_statistics/components/instance_counts_spec.js @@ -1,7 +1,7 @@ import { shallowMount } from '@vue/test-utils'; import InstanceCounts from '~/analytics/instance_statistics/components/instance_counts.vue'; import MetricCard from '~/analytics/shared/components/metric_card.vue'; -import countsMockData from '../mock_data'; +import { mockInstanceCounts } from '../mock_data'; describe('InstanceCounts', () => { let wrapper; @@ -44,11 +44,11 @@ describe('InstanceCounts', () => { describe('with data', () => { beforeEach(() => { - createComponent({ data: { counts: countsMockData } }); + createComponent({ data: { counts: mockInstanceCounts } }); }); it('passes the counts data to the metric card', () => { - expect(findMetricCard().props('metrics')).toEqual(countsMockData); + expect(findMetricCard().props('metrics')).toEqual(mockInstanceCounts); }); }); }); diff --git a/spec/frontend/analytics/instance_statistics/mock_data.js b/spec/frontend/analytics/instance_statistics/mock_data.js index 9fabf3a4c65..c3f5069da28 100644 --- a/spec/frontend/analytics/instance_statistics/mock_data.js +++ b/spec/frontend/analytics/instance_statistics/mock_data.js @@ -1,4 +1,30 @@ -export default [ +export const mockInstanceCounts = [ { key: 'projects', value: 10, label: 'Projects' }, { key: 'groups', value: 20, label: 'Group' }, ]; + +export const mockCountsData1 = [ + { recordedAt: '2020-07-23', count: 52 }, + { recordedAt: '2020-07-22', count: 40 }, + { recordedAt: '2020-07-21', count: 31 }, + { recordedAt: '2020-06-14', count: 23 }, + { recordedAt: '2020-06-12', count: 20 }, +]; + +export const countsMonthlyChartData1 = [ + ['2020-07-01', 41], // average of 2020-07-x items + ['2020-06-01', 21.5], // average of 2020-06-x items +]; + +export const mockCountsData2 = [ + { recordedAt: '2020-07-28', count: 10 }, + { recordedAt: '2020-07-27', count: 9 }, + { recordedAt: '2020-06-26', count: 14 }, + { recordedAt: '2020-06-25', count: 23 }, + { recordedAt: '2020-06-24', count: 25 }, +]; + +export const countsMonthlyChartData2 = [ + ['2020-07-01', 9.5], // average of 2020-07-x items + ['2020-06-01', 20.666666666666668], // average of 2020-06-x items +]; diff --git a/spec/frontend/analytics/instance_statistics/utils_spec.js b/spec/frontend/analytics/instance_statistics/utils_spec.js new file mode 100644 index 00000000000..f6ea81eb678 --- /dev/null +++ b/spec/frontend/analytics/instance_statistics/utils_spec.js @@ -0,0 +1,41 @@ +import { getAverageByMonth } from '~/analytics/instance_statistics/utils'; +import { + mockCountsData1, + mockCountsData2, + countsMonthlyChartData1, + countsMonthlyChartData2, +} from './mock_data'; + +describe('getAverageByMonth', () => { + it('collects data into average by months', () => { + expect(getAverageByMonth(mockCountsData1)).toStrictEqual(countsMonthlyChartData1); + expect(getAverageByMonth(mockCountsData2)).toStrictEqual(countsMonthlyChartData2); + }); + + it('it transforms a data point to the first of the month', () => { + const item = mockCountsData1[0]; + const firstOfTheMonth = item.recordedAt.replace(/-[0-9]{2}$/, '-01'); + expect(getAverageByMonth([item])).toStrictEqual([[firstOfTheMonth, item.count]]); + }); + + it('it uses sane defaults', () => { + expect(getAverageByMonth()).toStrictEqual([]); + }); + + it('it errors when passing null', () => { + expect(() => { + getAverageByMonth(null); + }).toThrow(); + }); + + describe('when shouldRound = true', () => { + const options = { shouldRound: true }; + + it('rounds the averages', () => { + const roundedData1 = countsMonthlyChartData1.map(([date, avg]) => [date, Math.round(avg)]); + const roundedData2 = countsMonthlyChartData2.map(([date, avg]) => [date, Math.round(avg)]); + expect(getAverageByMonth(mockCountsData1, options)).toStrictEqual(roundedData1); + expect(getAverageByMonth(mockCountsData2, options)).toStrictEqual(roundedData2); + }); + }); +}); diff --git a/spec/frontend/clusters/components/__snapshots__/remove_cluster_confirmation_spec.js.snap b/spec/frontend/clusters/components/__snapshots__/remove_cluster_confirmation_spec.js.snap index 93b757e008a..15eeadcc8b8 100644 --- a/spec/frontend/clusters/components/__snapshots__/remove_cluster_confirmation_spec.js.snap +++ b/spec/frontend/clusters/components/__snapshots__/remove_cluster_confirmation_spec.js.snap @@ -5,14 +5,17 @@ exports[`Remove cluster confirmation modal renders splitbutton with modal includ class="gl-display-flex gl-justify-content-end" >