Commit 94852ee7 authored by Denys Mishunov's avatar Denys Mishunov

Merge branch...

Merge branch '212984-fix-fetchgroupepics-exported-as-vuex-action-but-doesn-t-follow-api' into 'master'

Fix `fetchGroupEpics` exported as Vuex action but doesn't follow API

Closes #212984

See merge request gitlab-org/gitlab!30183
parents eba6affb dd987bef
......@@ -22,7 +22,7 @@ export const setInitialData = ({ commit }, data) => commit(types.SET_INITIAL_DAT
export const setWindowResizeInProgress = ({ commit }, inProgress) =>
commit(types.SET_WINDOW_RESIZE_IN_PROGRESS, inProgress);
export const fetchGroupEpics = (
const fetchGroupEpics = (
{ epicIid, fullPath, epicsState, sortedBy, presetType, filterParams, timeframe },
defaultTimeframe,
) => {
......
import MockAdapter from 'axios-mock-adapter';
import * as actions from 'ee/roadmap/store/actions';
import * as types from 'ee/roadmap/store/mutation_types';
import defaultState from 'ee/roadmap/store/state';
import { getTimeframeForMonthsView } from 'ee/roadmap/utils/roadmap_utils';
import * as epicUtils from 'ee/roadmap/utils/epic_utils';
import * as roadmapItemUtils from 'ee/roadmap/utils/roadmap_item_utils';
import { PRESET_TYPES, EXTEND_AS } from 'ee/roadmap/constants';
import groupEpics from 'ee/roadmap/queries/groupEpics.query.graphql';
import groupMilestones from 'ee/roadmap/queries/groupMilestones.query.graphql';
import epicChildEpics from 'ee/roadmap/queries/epicChildEpics.query.graphql';
import testAction from 'helpers/vuex_action_helper';
import axios from '~/lib/utils/axios_utils';
import createFlash from '~/flash';
import {
mockGroupId,
basePath,
......@@ -29,7 +23,6 @@ import {
mockSortedBy,
mockGroupEpicsQueryResponse,
mockGroupEpicsQueryResponseFormatted,
mockEpicChildEpicsQueryResponse,
mockGroupMilestonesQueryResponse,
rawMilestones,
mockMilestone,
......@@ -88,65 +81,6 @@ describe('Roadmap Vuex Actions', () => {
});
});
describe('fetchGroupEpics', () => {
let mockState;
let expectedVariables;
beforeEach(() => {
mockState = {
fullPath: 'gitlab-org',
epicsState: 'all',
sortedBy: 'start_date_asc',
presetType: PRESET_TYPES.MONTHS,
filterParams: {},
timeframe: mockTimeframeMonths,
};
expectedVariables = {
fullPath: 'gitlab-org',
state: mockState.epicsState,
sort: mockState.sortedBy,
startDate: '2017-11-1',
dueDate: '2018-6-30',
};
});
it('should fetch Group Epics using GraphQL client when epicIid is not present in state', () => {
jest.spyOn(epicUtils.gqClient, 'query').mockReturnValue(
Promise.resolve({
data: mockGroupEpicsQueryResponse.data,
}),
);
return actions.fetchGroupEpics(mockState).then(() => {
expect(epicUtils.gqClient.query).toHaveBeenCalledWith({
query: groupEpics,
variables: expectedVariables,
});
});
});
it('should fetch child Epics of an Epic using GraphQL client when epicIid is present in state', () => {
jest.spyOn(epicUtils.gqClient, 'query').mockReturnValue(
Promise.resolve({
data: mockEpicChildEpicsQueryResponse.data,
}),
);
mockState.epicIid = '1';
return actions.fetchGroupEpics(mockState).then(() => {
expect(epicUtils.gqClient.query).toHaveBeenCalledWith({
query: epicChildEpics,
variables: {
iid: '1',
...expectedVariables,
},
});
});
});
});
describe('requestEpics', () => {
it('should set `epicsFetchInProgress` to true', () => {
return testAction(actions.requestEpics, {}, state, [{ type: 'REQUEST_EPICS' }], []);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment