diff options
Diffstat (limited to 'spec/frontend/analytics')
8 files changed, 31 insertions, 30 deletions
diff --git a/spec/frontend/analytics/components/activity_chart_spec.js b/spec/frontend/analytics/components/activity_chart_spec.js index a6b45ffe20f..c26407f5c1d 100644 --- a/spec/frontend/analytics/components/activity_chart_spec.js +++ b/spec/frontend/analytics/components/activity_chart_spec.js @@ -18,7 +18,7 @@ describe('Activity Chart Bundle', () => { wrapper = null; }); - const findChart = () => wrapper.find(GlColumnChart); + const findChart = () => wrapper.findComponent(GlColumnChart); const findNoData = () => wrapper.find('[data-testid="noActivityChartData"]'); describe('Activity Chart', () => { diff --git a/spec/frontend/analytics/shared/components/daterange_spec.js b/spec/frontend/analytics/shared/components/daterange_spec.js index a38df274243..7a09fe3319d 100644 --- a/spec/frontend/analytics/shared/components/daterange_spec.js +++ b/spec/frontend/analytics/shared/components/daterange_spec.js @@ -1,5 +1,5 @@ -import { GlDaterangePicker, GlSprintf } from '@gitlab/ui'; -import { shallowMount, mount } from '@vue/test-utils'; +import { GlDaterangePicker } from '@gitlab/ui'; +import { shallowMountExtended, mountExtended } from 'helpers/vue_test_utils_helper'; import { useFakeDate } from 'helpers/fake_date'; import Daterange from '~/analytics/shared/components/daterange.vue'; @@ -13,13 +13,12 @@ describe('Daterange component', () => { let wrapper; - const factory = (props = defaultProps, mountFn = shallowMount) => { + const factory = (props = defaultProps, mountFn = shallowMountExtended) => { wrapper = mountFn(Daterange, { propsData: { ...defaultProps, ...props, }, - stubs: { GlSprintf }, }); }; @@ -28,7 +27,7 @@ describe('Daterange component', () => { }); const findDaterangePicker = () => wrapper.findComponent(GlDaterangePicker); - const findDateRangeIndicator = () => wrapper.findComponent(GlSprintf); + const findDateRangeIndicator = () => wrapper.findByTestId('daterange-picker-indicator'); describe('template', () => { describe('when show is false', () => { @@ -52,7 +51,7 @@ describe('Daterange component', () => { const endDate = new Date('2019-09-30'); const minDate = new Date('2019-06-01'); - factory({ show: true, startDate, endDate, minDate }, mount); + factory({ show: true, startDate, endDate, minDate }, mountExtended); const input = findDaterangePicker().find('input'); input.setValue('2019-01-01'); @@ -64,7 +63,7 @@ describe('Daterange component', () => { describe('with a maxDateRange being set', () => { beforeEach(() => { - factory({ maxDateRange: 30 }); + factory({ maxDateRange: 30 }, mountExtended); }); it('displays the max date range indicator', () => { @@ -72,7 +71,7 @@ describe('Daterange component', () => { }); it('displays the correct number of selected days in the indicator', () => { - expect(findDateRangeIndicator().text()).toMatchInterpolatedText('10 days selected'); + expect(findDateRangeIndicator().text()).toBe('10 days selected'); }); it('sets the tooltip', () => { diff --git a/spec/frontend/analytics/shared/components/metric_popover_spec.js b/spec/frontend/analytics/shared/components/metric_popover_spec.js index ffec77c2708..6a58f8c6d29 100644 --- a/spec/frontend/analytics/shared/components/metric_popover_spec.js +++ b/spec/frontend/analytics/shared/components/metric_popover_spec.js @@ -30,7 +30,7 @@ describe('MetricPopover', () => { const findAllMetricLinks = () => wrapper.findAll('[data-testid="metric-link"]'); const findMetricDescription = () => wrapper.findByTestId('metric-description'); const findMetricDocsLink = () => wrapper.findByTestId('metric-docs-link'); - const findMetricDocsLinkIcon = () => findMetricDocsLink().find(GlIcon); + const findMetricDocsLinkIcon = () => findMetricDocsLink().findComponent(GlIcon); afterEach(() => { wrapper.destroy(); @@ -83,7 +83,9 @@ describe('MetricPopover', () => { const allLinkContainers = findAllMetricLinks(); expect(allLinkContainers.at(idx).text()).toContain(link.name); - expect(allLinkContainers.at(idx).find(GlLink).attributes('href')).toBe(link.url); + expect(allLinkContainers.at(idx).findComponent(GlLink).attributes('href')).toBe( + link.url, + ); }); }); diff --git a/spec/frontend/analytics/shared/components/projects_dropdown_filter_spec.js b/spec/frontend/analytics/shared/components/projects_dropdown_filter_spec.js index 69918c1db65..3871fd530d8 100644 --- a/spec/frontend/analytics/shared/components/projects_dropdown_filter_spec.js +++ b/spec/frontend/analytics/shared/components/projects_dropdown_filter_spec.js @@ -79,11 +79,11 @@ describe('ProjectsDropdownFilter component', () => { const findClearAllButton = () => wrapper.findByText('Clear all'); const findSelectedProjectsLabel = () => wrapper.findComponent(GlTruncate); - const findDropdown = () => wrapper.find(GlDropdown); + const findDropdown = () => wrapper.findComponent(GlDropdown); const findDropdownItems = () => findDropdown() - .findAll(GlDropdownItem) + .findAllComponents(GlDropdownItem) .filter((w) => w.text() !== 'No matching results'); const findDropdownAtIndex = (index) => findDropdownItems().at(index); @@ -106,7 +106,7 @@ describe('ProjectsDropdownFilter component', () => { }; // NOTE: Selected items are now visually separated from unselected items - const findSelectedDropdownItems = () => findHighlightedItems().findAll(GlDropdownItem); + const findSelectedDropdownItems = () => findHighlightedItems().findAllComponents(GlDropdownItem); const findSelectedDropdownAtIndex = (index) => findSelectedDropdownItems().at(index); const findSelectedButtonIdentIconAtIndex = (index) => diff --git a/spec/frontend/analytics/usage_trends/components/app_spec.js b/spec/frontend/analytics/usage_trends/components/app_spec.js index 156be26f895..c732dc22322 100644 --- a/spec/frontend/analytics/usage_trends/components/app_spec.js +++ b/spec/frontend/analytics/usage_trends/components/app_spec.js @@ -21,13 +21,13 @@ describe('UsageTrendsApp', () => { }); it('displays the usage counts component', () => { - expect(wrapper.find(UsageCounts).exists()).toBe(true); + expect(wrapper.findComponent(UsageCounts).exists()).toBe(true); }); ['Total projects & groups', 'Pipelines', 'Issues & merge requests'].forEach((usage) => { it(`displays the ${usage} chart`, () => { const chartTitles = wrapper - .findAll(UsageTrendsCountChart) + .findAllComponents(UsageTrendsCountChart) .wrappers.map((chartComponent) => chartComponent.props('chartTitle')); expect(chartTitles).toContain(usage); @@ -35,6 +35,6 @@ describe('UsageTrendsApp', () => { }); it('displays the users chart component', () => { - expect(wrapper.find(UsersChart).exists()).toBe(true); + expect(wrapper.findComponent(UsersChart).exists()).toBe(true); }); }); diff --git a/spec/frontend/analytics/usage_trends/components/usage_trends_count_chart_spec.js b/spec/frontend/analytics/usage_trends/components/usage_trends_count_chart_spec.js index 02cf7f42a0b..ad6089f74b5 100644 --- a/spec/frontend/analytics/usage_trends/components/usage_trends_count_chart_spec.js +++ b/spec/frontend/analytics/usage_trends/components/usage_trends_count_chart_spec.js @@ -50,9 +50,9 @@ describe('UsageTrendsCountChart', () => { wrapper = null; }); - const findLoader = () => wrapper.find(ChartSkeletonLoader); - const findChart = () => wrapper.find(GlLineChart); - const findAlert = () => wrapper.find(GlAlert); + const findLoader = () => wrapper.findComponent(ChartSkeletonLoader); + const findChart = () => wrapper.findComponent(GlLineChart); + const findAlert = () => wrapper.findComponent(GlAlert); describe('while loading', () => { beforeEach(() => { @@ -61,7 +61,7 @@ describe('UsageTrendsCountChart', () => { }); it('requests data', () => { - expect(queryHandler).toBeCalledTimes(1); + expect(queryHandler).toHaveBeenCalledTimes(1); }); it('displays the skeleton loader', () => { @@ -105,7 +105,7 @@ describe('UsageTrendsCountChart', () => { }); it('requests data', () => { - expect(queryHandler).toBeCalledTimes(1); + expect(queryHandler).toHaveBeenCalledTimes(1); }); it('hides the skeleton loader', () => { @@ -141,7 +141,7 @@ describe('UsageTrendsCountChart', () => { }); it('requests data twice', () => { - expect(queryHandler).toBeCalledTimes(2); + expect(queryHandler).toHaveBeenCalledTimes(2); }); it('passes the data to the line chart', () => { diff --git a/spec/frontend/analytics/usage_trends/components/users_chart_spec.js b/spec/frontend/analytics/usage_trends/components/users_chart_spec.js index 32a664a5026..e7abd4d4323 100644 --- a/spec/frontend/analytics/usage_trends/components/users_chart_spec.js +++ b/spec/frontend/analytics/usage_trends/components/users_chart_spec.js @@ -47,9 +47,9 @@ describe('UsersChart', () => { wrapper = null; }); - const findLoader = () => wrapper.find(ChartSkeletonLoader); - const findAlert = () => wrapper.find(GlAlert); - const findChart = () => wrapper.find(GlAreaChart); + const findLoader = () => wrapper.findComponent(ChartSkeletonLoader); + const findAlert = () => wrapper.findComponent(GlAlert); + const findChart = () => wrapper.findComponent(GlAreaChart); describe('while loading', () => { beforeEach(() => { @@ -139,7 +139,7 @@ describe('UsersChart', () => { }); it('requests data twice', () => { - expect(queryHandler).toBeCalledTimes(2); + expect(queryHandler).toHaveBeenCalledTimes(2); }); it('calls fetchMore', () => { diff --git a/spec/frontend/analytics/usage_trends/utils_spec.js b/spec/frontend/analytics/usage_trends/utils_spec.js index 656f310dda7..9982e96735e 100644 --- a/spec/frontend/analytics/usage_trends/utils_spec.js +++ b/spec/frontend/analytics/usage_trends/utils_spec.js @@ -16,17 +16,17 @@ describe('getAverageByMonth', () => { expect(getAverageByMonth(mockCountsData2)).toStrictEqual(countsMonthlyChartData2); }); - it('it transforms a data point to the first of the month', () => { + 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', () => { + it('uses sane defaults', () => { expect(getAverageByMonth()).toStrictEqual([]); }); - it('it errors when passing null', () => { + it('errors when passing null', () => { expect(() => { getAverageByMonth(null); }).toThrow(); |