Commit 53a095bf authored by Andrew Smith's avatar Andrew Smith Committed by Andrew Smith

Order child epics in roadmap by configured sort order

Changelog: fixed
EE: true
parent 0dc65764
......@@ -69,12 +69,18 @@ const fetchGroupEpics = (
export const fetchChildrenEpics = (state, { parentItem }) => {
const { iid, group } = parentItem;
const { filterParams, epicsState } = state;
const { filterParams, epicsState, sortedBy } = state;
return epicUtils.gqClient
.query({
query: epicChildEpics,
variables: { iid, fullPath: group?.fullPath, state: epicsState, ...filterParams },
variables: {
iid,
fullPath: group?.fullPath,
state: epicsState,
sort: sortedBy,
...filterParams,
},
})
.then(({ data }) => {
const edges = data?.group?.epic?.children?.edges || [];
......
import MockAdapter from 'axios-mock-adapter';
import { DATE_RANGES, PRESET_TYPES } from 'ee/roadmap/constants';
import groupMilestones from 'ee/roadmap/queries/groupMilestones.query.graphql';
import epicChildEpics from 'ee/roadmap/queries/epicChildEpics.query.graphql';
import * as actions from 'ee/roadmap/store/actions';
import * as types from 'ee/roadmap/store/mutation_types';
import defaultState from 'ee/roadmap/store/state';
......@@ -29,6 +30,7 @@ import {
mockMilestone,
mockFormattedMilestone,
mockPageInfo,
mockEpic,
} from '../mock_data';
jest.mock('~/flash');
......@@ -75,6 +77,38 @@ describe('Roadmap Vuex Actions', () => {
});
});
describe('fetchChildrenEpics', () => {
it('should fetch children epics for provided epic iid along with other parameters', () => {
jest.spyOn(epicUtils.gqClient, 'query').mockReturnValue(
Promise.resolve({
data: mockEpicChildEpicsQueryResponse.data,
}),
);
const mockState = {
fullPath: 'gitlab-org',
sortedBy: mockSortedBy,
epicsState: 'opened',
};
return actions
.fetchChildrenEpics(mockState, {
parentItem: mockEpic,
})
.then(() => {
expect(epicUtils.gqClient.query).toHaveBeenCalledWith({
query: epicChildEpics,
variables: {
iid: mockEpic.iid,
fullPath: '/groups/gitlab-org/',
sort: mockState.sortedBy,
state: mockState.epicsState,
},
});
});
});
});
describe('receiveEpicsSuccess', () => {
it('should set formatted epics array and epicId to IDs array in state based on provided epics list', () => {
return testAction(
......
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