Commit 2f425df3 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch '350315-order-roadmap-epics-by-start-date-and-then-title' into 'master'

Order child epics in roadmap by configured sort order

See merge request gitlab-org/gitlab!78249
parents 1f93b9f6 53a095bf
......@@ -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