diff options
Diffstat (limited to 'spec/frontend/cycle_analytics')
5 files changed, 28 insertions, 81 deletions
diff --git a/spec/frontend/cycle_analytics/base_spec.js b/spec/frontend/cycle_analytics/base_spec.js index bdf35f904ed..7b1ef71da63 100644 --- a/spec/frontend/cycle_analytics/base_spec.js +++ b/spec/frontend/cycle_analytics/base_spec.js @@ -143,12 +143,9 @@ describe('Value stream analytics component', () => { expect(findFilters().props()).toEqual({ groupId, groupPath, - canToggleAggregation: false, endDate: createdBefore, hasDateRangeFilter: true, hasProjectFilter: false, - isAggregationEnabled: false, - isUpdatingAggregationData: false, selectedProjects: [], startDate: createdAfter, }); diff --git a/spec/frontend/cycle_analytics/mock_data.js b/spec/frontend/cycle_analytics/mock_data.js index c482bd4e910..1fe1dbbb75c 100644 --- a/spec/frontend/cycle_analytics/mock_data.js +++ b/spec/frontend/cycle_analytics/mock_data.js @@ -40,7 +40,7 @@ export const summary = [ { value: '20', title: 'New Issues' }, { value: null, title: 'Commits' }, { value: null, title: 'Deploys' }, - { value: null, title: 'Deployment Frequency', unit: 'per day' }, + { value: null, title: 'Deployment Frequency', unit: '/day' }, ]; export const issueStage = { @@ -130,7 +130,7 @@ export const convertedData = { { value: '20', title: 'New Issues' }, { value: '-', title: 'Commits' }, { value: '-', title: 'Deploys' }, - { value: '-', title: 'Deployment Frequency', unit: 'per day' }, + { value: '-', title: 'Deployment Frequency', unit: '/day' }, ], }; diff --git a/spec/frontend/cycle_analytics/stage_table_spec.js b/spec/frontend/cycle_analytics/stage_table_spec.js index 107fe5fc865..0d15d67866d 100644 --- a/spec/frontend/cycle_analytics/stage_table_spec.js +++ b/spec/frontend/cycle_analytics/stage_table_spec.js @@ -329,7 +329,7 @@ describe('StageTable', () => { ]); }); - it('with sortDesc=false will toggle the direction field', async () => { + it('with sortDesc=false will toggle the direction field', () => { expect(wrapper.emitted('handleUpdatePagination')).toBeUndefined(); triggerTableSort(false); diff --git a/spec/frontend/cycle_analytics/value_stream_filters_spec.js b/spec/frontend/cycle_analytics/value_stream_filters_spec.js index 5a0b046393a..6e96a6d756a 100644 --- a/spec/frontend/cycle_analytics/value_stream_filters_spec.js +++ b/spec/frontend/cycle_analytics/value_stream_filters_spec.js @@ -1,5 +1,4 @@ import { shallowMount } from '@vue/test-utils'; -import { GlToggle } from '@gitlab/ui'; import Daterange from '~/analytics/shared/components/daterange.vue'; import ProjectsDropdownFilter from '~/analytics/shared/components/projects_dropdown_filter.vue'; import FilterBar from '~/cycle_analytics/components/filter_bar.vue'; @@ -30,7 +29,6 @@ describe('ValueStreamFilters', () => { const findProjectsDropdown = () => wrapper.findComponent(ProjectsDropdownFilter); const findDateRangePicker = () => wrapper.findComponent(Daterange); const findFilterBar = () => wrapper.findComponent(FilterBar); - const findAggregationToggle = () => wrapper.findComponent(GlToggle); beforeEach(() => { wrapper = createComponent(); @@ -59,10 +57,6 @@ describe('ValueStreamFilters', () => { expect(findDateRangePicker().exists()).toBe(true); }); - it('will not render the aggregation toggle', () => { - expect(findAggregationToggle().exists()).toBe(false); - }); - it('will emit `selectProject` when a project is selected', () => { findProjectsDropdown().vm.$emit('selected'); @@ -94,52 +88,4 @@ describe('ValueStreamFilters', () => { expect(findProjectsDropdown().exists()).toBe(false); }); }); - - describe('canToggleAggregation = true', () => { - beforeEach(() => { - wrapper = createComponent({ isAggregationEnabled: false, canToggleAggregation: true }); - }); - - it('will render the aggregation toggle', () => { - expect(findAggregationToggle().exists()).toBe(true); - }); - - it('will set the aggregation toggle to the `isAggregationEnabled` value', () => { - expect(findAggregationToggle().props('value')).toBe(false); - - wrapper = createComponent({ - isAggregationEnabled: true, - canToggleAggregation: true, - }); - - expect(findAggregationToggle().props('value')).toBe(true); - }); - - it('will emit `toggleAggregation` when the toggle is changed', async () => { - expect(wrapper.emitted('toggleAggregation')).toBeUndefined(); - - await findAggregationToggle().vm.$emit('change', true); - - expect(wrapper.emitted('toggleAggregation')).toHaveLength(1); - expect(wrapper.emitted('toggleAggregation')).toEqual([[true]]); - }); - }); - - describe('isUpdatingAggregationData = true', () => { - beforeEach(() => { - wrapper = createComponent({ canToggleAggregation: true, isUpdatingAggregationData: true }); - }); - - it('will disable the aggregation toggle', () => { - expect(findAggregationToggle().props('disabled')).toBe(true); - }); - - it('will not emit `toggleAggregation` when the toggle is changed', async () => { - expect(wrapper.emitted('toggleAggregation')).toBeUndefined(); - - await findAggregationToggle().vm.$emit('change', true); - - expect(wrapper.emitted('toggleAggregation')).toBeUndefined(); - }); - }); }); diff --git a/spec/frontend/cycle_analytics/value_stream_metrics_spec.js b/spec/frontend/cycle_analytics/value_stream_metrics_spec.js index 6199e61df0c..4a3e8146b13 100644 --- a/spec/frontend/cycle_analytics/value_stream_metrics_spec.js +++ b/spec/frontend/cycle_analytics/value_stream_metrics_spec.js @@ -1,11 +1,11 @@ import { GlDeprecatedSkeletonLoading as GlSkeletonLoading } from '@gitlab/ui'; -import { shallowMount } from '@vue/test-utils'; import { nextTick } from 'vue'; import metricsData from 'test_fixtures/projects/analytics/value_stream_analytics/summary.json'; +import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import waitForPromises from 'helpers/wait_for_promises'; import ValueStreamMetrics from '~/analytics/shared/components/value_stream_metrics.vue'; import { METRIC_TYPE_SUMMARY } from '~/api/analytics_api'; -import { METRICS_POPOVER_CONTENT } from '~/analytics/shared/constants'; +import { VSA_METRICS_GROUPS, METRICS_POPOVER_CONTENT } from '~/analytics/shared/constants'; import { prepareTimeMetricsData } from '~/analytics/shared/utils'; import MetricTile from '~/analytics/shared/components/metric_tile.vue'; import createFlash from '~/flash'; @@ -27,7 +27,7 @@ describe('ValueStreamMetrics', () => { }); const createComponent = (props = {}) => { - return shallowMount(ValueStreamMetrics, { + return shallowMountExtended(ValueStreamMetrics, { propsData: { requestPath, requestParams: {}, @@ -38,6 +38,7 @@ describe('ValueStreamMetrics', () => { }; const findMetrics = () => wrapper.findAllComponents(MetricTile); + const findMetricsGroups = () => wrapper.findAllByTestId('vsa-metrics-group'); const expectToHaveRequest = (fields) => { expect(mockGetValueStreamSummaryMetrics).toHaveBeenCalledWith({ @@ -63,24 +64,6 @@ describe('ValueStreamMetrics', () => { expect(wrapper.findComponent(GlSkeletonLoading).exists()).toBe(true); }); - it('renders hidden MetricTile components for each metric', async () => { - await waitForPromises(); - - // setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details - // eslint-disable-next-line no-restricted-syntax - wrapper.setData({ isLoading: true }); - - await nextTick(); - - const components = findMetrics(); - - expect(components).toHaveLength(metricsData.length); - - metricsData.forEach((metric, index) => { - expect(components.at(index).isVisible()).toBe(false); - }); - }); - describe('with data loaded', () => { beforeEach(async () => { await waitForPromises(); @@ -160,6 +143,27 @@ describe('ValueStreamMetrics', () => { }); }); }); + + describe('groupBy', () => { + beforeEach(async () => { + mockGetValueStreamSummaryMetrics = jest.fn().mockResolvedValue({ data: metricsData }); + wrapper = createComponent({ groupBy: VSA_METRICS_GROUPS }); + await waitForPromises(); + }); + + it('renders the metrics as separate groups', () => { + const groups = findMetricsGroups(); + expect(groups).toHaveLength(VSA_METRICS_GROUPS.length); + }); + + it('renders titles for each group', () => { + const groups = findMetricsGroups(); + groups.wrappers.forEach((g, index) => { + const { title } = VSA_METRICS_GROUPS[index]; + expect(g.html()).toContain(title); + }); + }); + }); }); }); |