diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-03-18 23:02:30 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-03-18 23:02:30 +0300 |
commit | 41fe97390ceddf945f3d967b8fdb3de4c66b7dea (patch) | |
tree | 9c8d89a8624828992f06d892cd2f43818ff5dcc8 /spec/frontend/cycle_analytics/value_stream_filters_spec.js | |
parent | 0804d2dc31052fb45a1efecedc8e06ce9bc32862 (diff) |
Add latest changes from gitlab-org/gitlab@14-9-stable-eev14.9.0-rc42
Diffstat (limited to 'spec/frontend/cycle_analytics/value_stream_filters_spec.js')
-rw-r--r-- | spec/frontend/cycle_analytics/value_stream_filters_spec.js | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/spec/frontend/cycle_analytics/value_stream_filters_spec.js b/spec/frontend/cycle_analytics/value_stream_filters_spec.js index 6e96a6d756a..5a0b046393a 100644 --- a/spec/frontend/cycle_analytics/value_stream_filters_spec.js +++ b/spec/frontend/cycle_analytics/value_stream_filters_spec.js @@ -1,4 +1,5 @@ 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'; @@ -29,6 +30,7 @@ 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(); @@ -57,6 +59,10 @@ 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'); @@ -88,4 +94,52 @@ 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(); + }); + }); }); |