Skip to content
Snippets Groups Projects
Commit 165a756a authored by winniehell's avatar winniehell
Browse files

Use global Vue instance in Jest (analytics)

parent 6c464495
No related branches found
No related tags found
No related merge requests found
Showing
with 47 additions and 75 deletions
import { GlLoadingIcon, GlEmptyState, GlBadge, GlPagination } from '@gitlab/ui';
import { createLocalVue, shallowMount } from '@vue/test-utils';
import { shallowMount } from '@vue/test-utils';
import Vue from 'vue';
import Vuex from 'vuex';
import CodeReviewAnalyticsApp from 'ee/analytics/code_review_analytics/components/app.vue';
import FilterBar from 'ee/analytics/code_review_analytics/components/filter_bar.vue';
Loading
Loading
@@ -9,8 +10,7 @@ import createMergeRequestsState from 'ee/analytics/code_review_analytics/store/m
import { TEST_HOST } from 'helpers/test_constants';
import createFiltersState from '~/vue_shared/components/filtered_search_bar/store/modules/filters/state';
 
const localVue = createLocalVue();
localVue.use(Vuex);
Vue.use(Vuex);
 
describe('CodeReviewAnalyticsApp component', () => {
let wrapper;
Loading
Loading
@@ -57,7 +57,6 @@ describe('CodeReviewAnalyticsApp component', () => {
 
const createComponent = (store) =>
shallowMount(CodeReviewAnalyticsApp, {
localVue,
store,
propsData: {
projectId: 1,
Loading
Loading
import { createLocalVue, shallowMount } from '@vue/test-utils';
import { shallowMount } from '@vue/test-utils';
import axios from 'axios';
import MockAdapter from 'axios-mock-adapter';
import Vue from 'vue';
import Vuex from 'vuex';
import FilterBar from 'ee/analytics/code_review_analytics/components/filter_bar.vue';
import storeConfig from 'ee/analytics/code_review_analytics/store';
Loading
Loading
@@ -19,8 +20,7 @@ import * as utils from '~/vue_shared/components/filtered_search_bar/filtered_sea
import initialFiltersState from '~/vue_shared/components/filtered_search_bar/store/modules/filters/state';
import UrlSync from '~/vue_shared/components/url_sync.vue';
 
const localVue = createLocalVue();
localVue.use(Vuex);
Vue.use(Vuex);
 
const milestoneTokenType = 'milestone';
const labelsTokenType = 'labels';
Loading
Loading
@@ -81,7 +81,6 @@ describe('Filter bar', () => {
 
function createComponent(initialStore) {
return shallowMount(FilterBar, {
localVue,
store: initialStore,
propsData: {
projectPath: 'foo',
Loading
Loading
import { GlTable } from '@gitlab/ui';
import { createLocalVue, mount } from '@vue/test-utils';
import { mount } from '@vue/test-utils';
import Vue from 'vue';
import Vuex from 'vuex';
import MergeRequestTable from 'ee/analytics/code_review_analytics/components/merge_request_table.vue';
import createState from 'ee/analytics/code_review_analytics/store/modules/merge_requests/state';
import { mockMergeRequests } from '../mock_data';
 
const localVue = createLocalVue();
localVue.use(Vuex);
Vue.use(Vuex);
 
describe('MergeRequestTable component', () => {
let wrapper;
Loading
Loading
@@ -27,7 +27,6 @@ describe('MergeRequestTable component', () => {
 
const createComponent = (store) =>
mount(MergeRequestTable, {
localVue,
store,
});
 
Loading
Loading
import { GlEmptyState } from '@gitlab/ui';
import { createLocalVue, shallowMount, mount } from '@vue/test-utils';
import { shallowMount, mount } from '@vue/test-utils';
import axios from 'axios';
import MockAdapter from 'axios-mock-adapter';
import Vue from 'vue';
import Vuex from 'vuex';
import Component from 'ee/analytics/cycle_analytics/components/base.vue';
import DurationChart from 'ee/analytics/cycle_analytics/components/duration_chart.vue';
Loading
Loading
@@ -48,8 +49,7 @@ const noAccessSvgPath = 'path/to/no/access';
const emptyStateSvgPath = 'path/to/empty/state';
const stage = null;
 
const localVue = createLocalVue();
localVue.use(Vuex);
Vue.use(Vuex);
jest.mock('~/flash');
 
const defaultStubs = {
Loading
Loading
@@ -132,7 +132,6 @@ describe('EE Value Stream Analytics component', () => {
 
const func = shallow ? shallowMount : mount;
const comp = func(Component, {
localVue,
store,
propsData: {
emptyStateSvgPath,
Loading
Loading
import { GlDropdownItem } from '@gitlab/ui';
import { shallowMount, mount, createLocalVue } from '@vue/test-utils';
import { shallowMount, mount } from '@vue/test-utils';
import Vue from 'vue';
import Vuex from 'vuex';
import DurationChart from 'ee/analytics/cycle_analytics/components/duration_chart.vue';
import StageDropdownFilter from 'ee/analytics/cycle_analytics/components/stage_dropdown_filter.vue';
Loading
Loading
@@ -7,8 +8,7 @@ import Scatterplot from 'ee/analytics/shared/components/scatterplot.vue';
import ChartSkeletonLoader from '~/vue_shared/components/resizable_chart/skeleton_loader.vue';
import { allowedStages as stages, durationChartPlottableData as durationData } from '../mock_data';
 
const localVue = createLocalVue();
localVue.use(Vuex);
Vue.use(Vuex);
 
const actionSpies = {
fetchDurationData: jest.fn(),
Loading
Loading
@@ -41,7 +41,6 @@ function createComponent({
props = {},
} = {}) {
return mountFn(DurationChart, {
localVue,
store: fakeStore({ initialState, initialGetters }),
propsData: {
stages,
Loading
Loading
import { GlDropdownItem, GlSegmentedControl, GlSprintf } from '@gitlab/ui';
import { shallowMount, mount, createLocalVue } from '@vue/test-utils';
import { shallowMount, mount } from '@vue/test-utils';
import axios from 'axios';
import MockAdapter from 'axios-mock-adapter';
import Vue from 'vue';
import Vuex from 'vuex';
import LabelsSelector from 'ee/analytics/cycle_analytics/components/labels_selector.vue';
import TasksByTypeFilters from 'ee/analytics/cycle_analytics/components/tasks_by_type/tasks_by_type_filters.vue';
Loading
Loading
@@ -32,15 +33,13 @@ const selectLabelAtIndex = (ctx, index) => {
const mockGroupLabelsRequest = () => new MockAdapter(axios).onGet().reply(200, groupLabels);
 
let store = null;
const localVue = createLocalVue();
localVue.use(Vuex);
Vue.use(Vuex);
 
jest.mock('~/flash');
 
function createComponent({ props = {}, mountFn = shallowMount } = {}) {
store = createStore();
return mountFn(TasksByTypeFilters, {
localVue,
store: {
...store,
getters: {
Loading
Loading
import { GlModal, GlFormInput } from '@gitlab/ui';
import { shallowMount, createLocalVue } from '@vue/test-utils';
import { shallowMount } from '@vue/test-utils';
import Vue from 'vue';
import Vuex from 'vuex';
import {
PRESET_OPTIONS_BLANK,
Loading
Loading
@@ -19,8 +20,7 @@ import { customStageEvents as formEvents, defaultStageConfig, rawCustomStage } f
const scrollIntoViewMock = jest.fn();
HTMLElement.prototype.scrollIntoView = scrollIntoViewMock;
 
const localVue = createLocalVue();
localVue.use(Vuex);
Vue.use(Vuex);
 
describe('ValueStreamForm', () => {
let wrapper = null;
Loading
Loading
@@ -68,7 +68,6 @@ describe('ValueStreamForm', () => {
const createComponent = ({ props = {}, data = {}, stubs = {}, state = {} } = {}) =>
extendedWrapper(
shallowMount(ValueStreamForm, {
localVue,
store: fakeStore({ state }),
data() {
return {
Loading
Loading
import { GlDropdown } from '@gitlab/ui';
import { mount, shallowMount, createLocalVue } from '@vue/test-utils';
import { mount, shallowMount } from '@vue/test-utils';
import Vue from 'vue';
import Vuex from 'vuex';
import ValueStreamSelect from 'ee/analytics/cycle_analytics/components/value_stream_select.vue';
import { mockTracking, unmockTracking } from 'helpers/tracking_helper';
Loading
Loading
@@ -7,8 +8,7 @@ import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import { findDropdownItemText } from '../helpers';
import { valueStreams, defaultStageConfig } from '../mock_data';
 
const localVue = createLocalVue();
localVue.use(Vuex);
Vue.use(Vuex);
 
describe('ValueStreamSelect', () => {
let wrapper = null;
Loading
Loading
@@ -41,7 +41,6 @@ describe('ValueStreamSelect', () => {
const createComponent = ({ data = {}, initialState = {}, mountFn = shallowMount } = {}) =>
extendedWrapper(
mountFn(ValueStreamSelect, {
localVue,
store: fakeStore({ initialState }),
data() {
return {
Loading
Loading
import { GlDropdown, GlLoadingIcon, GlSearchBoxByType } from '@gitlab/ui';
import * as Sentry from '@sentry/browser';
import { createLocalVue } from '@vue/test-utils';
import Vue from 'vue';
import VueApollo from 'vue-apollo';
import DevopsAdoptionAddDropdown from 'ee/analytics/devops_reports/devops_adoption/components/devops_adoption_add_dropdown.vue';
Loading
Loading
@@ -23,7 +22,6 @@ import {
genericDeleteErrorMessage,
} from '../mock_data';
 
const localVue = createLocalVue();
Vue.use(VueApollo);
 
const mutateAdd = jest.fn().mockResolvedValue({
Loading
Loading
@@ -59,7 +57,6 @@ describe('DevopsAdoptionAddDropdown', () => {
]);
 
wrapper = shallowMountExtended(DevopsAdoptionAddDropdown, {
localVue,
apolloProvider: mockApollo,
propsData: {
groups: [],
Loading
Loading
import { GlAlert, GlTabs } from '@gitlab/ui';
import * as Sentry from '@sentry/browser';
import { createLocalVue } from '@vue/test-utils';
import Vue from 'vue';
import VueApollo from 'vue-apollo';
import DevopsAdoptionAddDropdown from 'ee/analytics/devops_reports/devops_adoption/components/devops_adoption_add_dropdown.vue';
Loading
Loading
@@ -29,7 +28,6 @@ jest.mock('ee/analytics/devops_reports/devops_adoption/utils/cache_updates', ()
addEnabledNamespacesToCache: jest.fn(),
}));
 
const localVue = createLocalVue();
Vue.use(VueApollo);
 
const NETWORK_ERROR = new Error('foo!');
Loading
Loading
@@ -117,7 +115,6 @@ describe('DevopsAdoptionApp', () => {
const { mockApollo, data = {}, provide = {} } = options;
 
return shallowMountExtended(DevopsAdoptionApp, {
localVue,
apolloProvider: mockApollo,
provide,
data() {
Loading
Loading
import { GlModal, GlSprintf, GlAlert } from '@gitlab/ui';
import * as Sentry from '@sentry/browser';
import { createLocalVue, shallowMount } from '@vue/test-utils';
import { shallowMount } from '@vue/test-utils';
import Vue from 'vue';
import VueApollo from 'vue-apollo';
import DevopsAdoptionDeleteModal from 'ee/analytics/devops_reports/devops_adoption/components/devops_adoption_delete_modal.vue';
Loading
Loading
@@ -13,7 +13,6 @@ import {
devopsAdoptionNamespaceData,
} from '../mock_data';
 
const localVue = createLocalVue();
Vue.use(VueApollo);
 
const mockEvent = { preventDefault: jest.fn() };
Loading
Loading
@@ -45,7 +44,6 @@ describe('DevopsAdoptionDeleteModal', () => {
]);
 
wrapper = shallowMount(DevopsAdoptionDeleteModal, {
localVue,
apolloProvider: mockApollo,
propsData: {
modalId,
Loading
Loading
import { createLocalVue, shallowMount } from '@vue/test-utils';
import { shallowMount } from '@vue/test-utils';
import Vue from 'vue';
import VueApollo from 'vue-apollo';
import { GlStackedColumnChart } from '@gitlab/ui/dist/charts';
import ChartSkeletonLoader from '~/vue_shared/components/resizable_chart/skeleton_loader.vue';
Loading
Loading
@@ -7,8 +8,7 @@ import getSnapshotsQuery from 'ee/analytics/devops_reports/devops_adoption/graph
import createMockApollo from 'helpers/mock_apollo_helper';
import { namespaceWithSnapotsData } from '../mock_data';
 
const localVue = createLocalVue();
localVue.use(VueApollo);
Vue.use(VueApollo);
 
const mockWithData = jest.fn().mockResolvedValue(namespaceWithSnapotsData);
 
Loading
Loading
@@ -23,7 +23,6 @@ describe('DevopsAdoptionOverviewChart', () => {
const handlers = [[getSnapshotsQuery, mockSnapshotsQuery]];
 
wrapper = shallowMount(DevopsAdoptionOverviewChart, {
localVue,
provide: {
groupGid:
namespaceWithSnapotsData.data.devopsAdoptionEnabledNamespaces.nodes[0].namespace.id,
Loading
Loading
import { GlSkeletonLoader, GlCard } from '@gitlab/ui';
import { shallowMount, createLocalVue } from '@vue/test-utils';
import { shallowMount } from '@vue/test-utils';
import { merge } from 'lodash';
import Vue from 'vue';
import VueApollo from 'vue-apollo';
Loading
Loading
@@ -8,7 +8,6 @@ import groupReleaseStatsQuery from 'ee/analytics/group_ci_cd_analytics/graphql/g
import createMockApollo from 'helpers/mock_apollo_helper';
import { groupReleaseStatsQueryResponse } from './mock_data';
 
const localVue = createLocalVue();
Vue.use(VueApollo);
 
describe('Release stats card', () => {
Loading
Loading
@@ -16,7 +15,6 @@ describe('Release stats card', () => {
 
const createComponent = ({ apolloProvider }) => {
wrapper = shallowMount(ReleaseStatsCard, {
localVue,
apolloProvider,
stubs: {
GlCard,
Loading
Loading
import { createLocalVue, shallowMount } from '@vue/test-utils';
import { shallowMount } from '@vue/test-utils';
import axios from 'axios';
import MockAdapter from 'axios-mock-adapter';
import Vue from 'vue';
import Vuex from 'vuex';
import FilterBar from 'ee/analytics/merge_request_analytics/components/filter_bar.vue';
import storeConfig from 'ee/analytics/merge_request_analytics/store';
Loading
Loading
@@ -22,8 +23,7 @@ import * as utils from '~/vue_shared/components/filtered_search_bar/filtered_sea
import initialFiltersState from '~/vue_shared/components/filtered_search_bar/store/modules/filters/state';
import UrlSync from '~/vue_shared/components/url_sync.vue';
 
const localVue = createLocalVue();
localVue.use(Vuex);
Vue.use(Vuex);
 
const sourceBranchTokenType = 'source_branch';
const targetBranchTokenType = 'target_branch';
Loading
Loading
@@ -103,7 +103,6 @@ describe('Filter bar', () => {
function createComponent(initialStore, options = {}) {
const { type = ITEM_TYPE.PROJECT } = options;
return shallowMount(FilterBar, {
localVue,
store: initialStore,
provide: () => ({
fullPath: 'foo',
Loading
Loading
import { GlAlert } from '@gitlab/ui';
import { GlAreaChart } from '@gitlab/ui/dist/charts';
import { shallowMount, createLocalVue } from '@vue/test-utils';
import { shallowMount } from '@vue/test-utils';
import Vue from 'vue';
import Vuex from 'vuex';
import ThroughputChart from 'ee/analytics/merge_request_analytics/components/throughput_chart.vue';
import ThroughputStats from 'ee/analytics/merge_request_analytics/components/throughput_stats.vue';
Loading
Loading
@@ -15,8 +16,7 @@ import {
fullPath,
} from '../mock_data';
 
const localVue = createLocalVue();
localVue.use(Vuex);
Vue.use(Vuex);
 
const defaultQueryVariables = {
assigneeUsername: null,
Loading
Loading
@@ -45,7 +45,6 @@ describe('ThroughputChart', () => {
function createComponent(options = {}) {
const { mocks = defaultMocks } = options;
return shallowMount(ThroughputChart, {
localVue,
store,
mocks,
provide: {
Loading
Loading
Loading
Loading
@@ -6,7 +6,8 @@ import {
GlAvatarsInline,
GlPagination,
} from '@gitlab/ui';
import { mount, shallowMount, createLocalVue } from '@vue/test-utils';
import { mount, shallowMount } from '@vue/test-utils';
import Vue from 'vue';
import Vuex from 'vuex';
import ThroughputTable from 'ee/analytics/merge_request_analytics/components/throughput_table.vue';
import {
Loading
Loading
@@ -23,8 +24,7 @@ import {
pageInfo,
} from '../mock_data';
 
const localVue = createLocalVue();
localVue.use(Vuex);
Vue.use(Vuex);
 
const defaultQueryVariables = {
assigneeUsername: null,
Loading
Loading
@@ -47,7 +47,6 @@ describe('ThroughputTable', () => {
function createComponent(options = {}) {
const { mocks = defaultMocks, func = shallowMount } = options;
return func(ThroughputTable, {
localVue,
store,
mocks,
provide: {
Loading
Loading
Loading
Loading
@@ -7,9 +7,10 @@ import {
GlAlert,
} from '@gitlab/ui';
import { GlColumnChart } from '@gitlab/ui/dist/charts';
import { createLocalVue, shallowMount } from '@vue/test-utils';
import { shallowMount } from '@vue/test-utils';
import axios from 'axios';
import MockAdapter from 'axios-mock-adapter';
import Vue from 'vue';
import Vuex from 'vuex';
import ProductivityApp from 'ee/analytics/productivity_analytics/components/app.vue';
import MetricChart from 'ee/analytics/productivity_analytics/components/metric_chart.vue';
Loading
Loading
@@ -23,8 +24,7 @@ import * as commonUtils from '~/lib/utils/common_utils';
import httpStatusCodes from '~/lib/utils/http_status';
import * as urlUtils from '~/lib/utils/url_utility';
 
const localVue = createLocalVue();
localVue.use(Vuex);
Vue.use(Vuex);
 
describe('ProductivityApp component', () => {
let wrapper;
Loading
Loading
@@ -75,7 +75,6 @@ describe('ProductivityApp component', () => {
},
});
wrapper = shallowMount(ProductivityApp, {
localVue,
store: mockStore,
mixins: [UrlSyncMixin],
propsData: {
Loading
Loading
import { createLocalVue, shallowMount } from '@vue/test-utils';
import { shallowMount } from '@vue/test-utils';
import Vue from 'vue';
import Vuex from 'vuex';
import FilterDropdowns from 'ee/analytics/productivity_analytics/components/filter_dropdowns.vue';
import { getStoreConfig } from 'ee/analytics/productivity_analytics/store';
Loading
Loading
@@ -6,8 +7,7 @@ import GroupsDropdownFilter from 'ee/analytics/shared/components/groups_dropdown
import ProjectsDropdownFilter from '~/analytics/shared/components/projects_dropdown_filter.vue';
import resetStore from '../helpers';
 
const localVue = createLocalVue();
localVue.use(Vuex);
Vue.use(Vuex);
 
describe('FilterDropdowns component', () => {
let wrapper;
Loading
Loading
@@ -43,7 +43,6 @@ describe('FilterDropdowns component', () => {
});
 
wrapper = shallowMount(FilterDropdowns, {
localVue,
store: mockStore,
propsData: {},
});
Loading
Loading
import { GlAlert, GlDropdown, GlDropdownItem, GlModal } from '@gitlab/ui';
import { shallowMount, createLocalVue } from '@vue/test-utils';
import { shallowMount } from '@vue/test-utils';
import DownloadTestCoverage from 'ee/analytics/repository_analytics/components/download_test_coverage.vue';
import SelectProjectsDropdown from 'ee/analytics/repository_analytics/components/select_projects_dropdown.vue';
 
const localVue = createLocalVue();
describe('Download test coverage component', () => {
let wrapper;
 
Loading
Loading
@@ -27,7 +25,6 @@ describe('Download test coverage component', () => {
 
const createComponent = () => {
wrapper = shallowMount(DownloadTestCoverage, {
localVue,
data() {
return {
hasError: false,
Loading
Loading
import { shallowMount, createLocalVue } from '@vue/test-utils';
import { shallowMount } from '@vue/test-utils';
import DownloadTestCoverage from 'ee/analytics/repository_analytics/components/download_test_coverage.vue';
import GroupRepositoryAnalytics, {
VISIT_EVENT_FEATURE_FLAG,
Loading
Loading
@@ -6,14 +6,13 @@ import GroupRepositoryAnalytics, {
} from 'ee/analytics/repository_analytics/components/group_repository_analytics.vue';
import Api from '~/api';
 
const localVue = createLocalVue();
jest.mock('~/api.js');
 
describe('Group repository analytics app', () => {
let wrapper;
 
const createComponent = (glFeatures = {}) => {
wrapper = shallowMount(GroupRepositoryAnalytics, { localVue, provide: { glFeatures } });
wrapper = shallowMount(GroupRepositoryAnalytics, { provide: { glFeatures } });
};
 
afterEach(() => {
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment