Commit b600e106 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'update-roadmap-graphql-mock-data' into 'master'

Update mock data and fix vacuous group id check in epic roadmap

See merge request gitlab-org/gitlab!56922
parents 8c94271e e46aa19a
<script> <script>
import { GlButton, GlIcon, GlLoadingIcon, GlTooltip } from '@gitlab/ui'; import { GlButton, GlIcon, GlLoadingIcon, GlTooltip } from '@gitlab/ui';
import { mapState } from 'vuex'; import { mapState } from 'vuex';
import { getIdFromGraphQLId } from '~/graphql_shared/utils';
import { __, n__ } from '~/locale'; import { __, n__ } from '~/locale';
import { EPIC_LEVEL_MARGIN } from '../constants'; import { EPIC_LEVEL_MARGIN } from '../constants';
import eventHub from '../event_hub'; import eventHub from '../event_hub';
...@@ -48,8 +49,11 @@ export default { ...@@ -48,8 +49,11 @@ export default {
itemId() { itemId() {
return this.epic.id; return this.epic.id;
}, },
epicGroupId() {
return getIdFromGraphQLId(this.epic.group.id);
},
isEpicGroupDifferent() { isEpicGroupDifferent() {
return this.currentGroupId !== this.epic.groupId; return this.currentGroupId !== this.epicGroupId;
}, },
isExpandIconHidden() { isExpandIconHidden() {
return !this.epic.hasChildren; return !this.epic.hasChildren;
...@@ -147,10 +151,10 @@ export default { ...@@ -147,10 +151,10 @@ export default {
<div class="epic-group-timeframe d-flex text-secondary"> <div class="epic-group-timeframe d-flex text-secondary">
<span <span
v-if="isEpicGroupDifferent && !epic.hasParent" v-if="isEpicGroupDifferent && !epic.hasParent"
:title="epic.groupFullName" :title="epic.group.fullName"
class="epic-group" class="epic-group"
> >
{{ epic.groupName }} {{ epic.group.name }}
</span> </span>
<span v-if="isEpicGroupDifferent && !epic.hasParent" class="mx-1" aria-hidden="true" <span v-if="isEpicGroupDifferent && !epic.hasParent" class="mx-1" aria-hidden="true"
>&middot;</span >&middot;</span
......
...@@ -19,6 +19,7 @@ fragment BaseEpic on Epic { ...@@ -19,6 +19,7 @@ fragment BaseEpic on Epic {
closedEpics closedEpics
} }
group { group {
id
name name
fullName fullName
fullPath fullPath
......
...@@ -57,7 +57,7 @@ const fetchGroupEpics = ( ...@@ -57,7 +57,7 @@ const fetchGroupEpics = (
? data?.group?.epic?.children?.edges || [] ? data?.group?.epic?.children?.edges || []
: data?.group?.epics?.edges || []; : data?.group?.epics?.edges || [];
return epicUtils.extractGroupEpics(edges); return edges.map((e) => e.node);
}); });
}; };
...@@ -72,7 +72,7 @@ export const fetchChildrenEpics = (state, { parentItem }) => { ...@@ -72,7 +72,7 @@ export const fetchChildrenEpics = (state, { parentItem }) => {
}) })
.then(({ data }) => { .then(({ data }) => {
const edges = data?.group?.epic?.children?.edges || []; const edges = data?.group?.epic?.children?.edges || [];
return epicUtils.extractGroupEpics(edges); return edges.map((e) => e.node);
}); });
}; };
......
...@@ -7,23 +7,6 @@ export const gqClient = createGqClient( ...@@ -7,23 +7,6 @@ export const gqClient = createGqClient(
}, },
); );
export const flattenGroupProperty = ({ node: epicNode }) => ({
...epicNode,
// We can get rid of below two lines
// by updating `epic_item_details.vue`
// once we move to GraphQL permanently.
groupName: epicNode.group.name,
groupFullName: epicNode.group.fullName,
});
/**
* Returns array of epics extracted from GraphQL response
* discarding the `edges`->`node` nesting
*
* @param {Object} edges
*/
export const extractGroupEpics = (edges) => edges.map(flattenGroupProperty);
export const addIsChildEpicTrueProperty = (obj) => ({ ...obj, isChildEpic: true }); export const addIsChildEpicTrueProperty = (obj) => ({ ...obj, isChildEpic: true });
export const generateKey = (epic) => `${epic.isChildEpic ? 'child-epic-' : 'epic-'}${epic.id}`; export const generateKey = (epic) => `${epic.isChildEpic ? 'child-epic-' : 'epic-'}${epic.id}`;
...@@ -31,7 +31,7 @@ describe('EpicItemDetails', () => { ...@@ -31,7 +31,7 @@ describe('EpicItemDetails', () => {
currentGroupId: mockGroupId, currentGroupId: mockGroupId,
timeframeString: 'Jul 10, 2017 – Jun 2, 2018', timeframeString: 'Jul 10, 2017 – Jun 2, 2018',
childLevel: 0, childLevel: 0,
childrenFlags: { 41: { itemExpanded: false } }, childrenFlags: { [mockFormattedEpic.id]: { itemExpanded: false } },
hasFiltersApplied: false, hasFiltersApplied: false,
isChildrenEmpty: false, isChildrenEmpty: false,
...props, ...props,
...@@ -88,31 +88,19 @@ describe('EpicItemDetails', () => { ...@@ -88,31 +88,19 @@ describe('EpicItemDetails', () => {
}); });
describe('epic group name', () => { describe('epic group name', () => {
const epic = {
id: '41',
...mockFormattedEpic,
groupId: 1,
groupName: 'Bar',
groupFullName: 'Foo / Bar',
descendantCounts: {
closedIssues: 3,
openedIssues: 2,
},
};
describe('when the epic group ID is different from the current group ID', () => { describe('when the epic group ID is different from the current group ID', () => {
it('is displayed and set to the title attribute', () => { it('is displayed and set to the title attribute', () => {
createWrapper({ epic, currentGroupId: 2 }); createWrapper({ currentGroupId: 123 });
expect(getEpicGroupNameData()).toEqual({ expect(getEpicGroupNameData()).toEqual({
groupName: epic.groupName, groupName: mockFormattedEpic.group.name,
title: epic.groupFullName, title: mockFormattedEpic.group.fullName,
}); });
}); });
}); });
describe('when the epic group ID is the same as the current group ID', () => { describe('when the epic group ID is the same as the current group ID', () => {
it('is hidden', () => { it('is hidden', () => {
createWrapper({ epic, currentGroupId: 1 }); createWrapper({ currentGroupId: mockGroupId });
expect(getGroupName().exists()).toBe(false); expect(getGroupName().exists()).toBe(false);
}); });
}); });
...@@ -178,7 +166,6 @@ describe('EpicItemDetails', () => { ...@@ -178,7 +166,6 @@ describe('EpicItemDetails', () => {
let epic; let epic;
beforeEach(() => { beforeEach(() => {
epic = createMockEpic({ epic = createMockEpic({
id: 41,
hasChildren: true, hasChildren: true,
children: { children: {
edges: [mockFormattedChildEpic1], edges: [mockFormattedChildEpic1],
...@@ -203,7 +190,7 @@ describe('EpicItemDetails', () => { ...@@ -203,7 +190,7 @@ describe('EpicItemDetails', () => {
describe('when child epics are expanded', () => { describe('when child epics are expanded', () => {
const childrenFlags = { const childrenFlags = {
41: { itemExpanded: true }, [mockFormattedEpic.id]: { itemExpanded: true },
}; };
beforeEach(() => { beforeEach(() => {
...@@ -241,7 +228,7 @@ describe('EpicItemDetails', () => { ...@@ -241,7 +228,7 @@ describe('EpicItemDetails', () => {
describe('when child epics are not expanded', () => { describe('when child epics are not expanded', () => {
beforeEach(() => { beforeEach(() => {
const childrenFlags = { const childrenFlags = {
41: { itemExpanded: false }, [mockFormattedEpic.id]: { itemExpanded: false },
}; };
createWrapper({ createWrapper({
epic, epic,
......
...@@ -36,7 +36,7 @@ const createComponent = ({ ...@@ -36,7 +36,7 @@ const createComponent = ({
currentGroupId = mockGroupId, currentGroupId = mockGroupId,
childLevel = 0, childLevel = 0,
childrenEpics = {}, childrenEpics = {},
childrenFlags = { 1: { itemExpanded: false } }, childrenFlags = { [mockEpic.id]: { itemExpanded: false } },
hasFiltersApplied = false, hasFiltersApplied = false,
}) => { }) => {
return mount(EpicItemComponent, { return mount(EpicItemComponent, {
......
...@@ -18,7 +18,6 @@ import { ...@@ -18,7 +18,6 @@ import {
mockEpicsWithParents, mockEpicsWithParents,
mockSortedBy, mockSortedBy,
basePath, basePath,
epicsPath,
} from 'ee_jest/roadmap/mock_data'; } from 'ee_jest/roadmap/mock_data';
const mockTimeframeMonths = getTimeframeForMonthsView(mockTimeframeInitialDate); const mockTimeframeMonths = getTimeframeForMonthsView(mockTimeframeInitialDate);
...@@ -29,7 +28,6 @@ store.dispatch('setInitialData', { ...@@ -29,7 +28,6 @@ store.dispatch('setInitialData', {
presetType: PRESET_TYPES.MONTHS, presetType: PRESET_TYPES.MONTHS,
timeframe: mockTimeframeMonths, timeframe: mockTimeframeMonths,
filterQueryString: '', filterQueryString: '',
initialEpicsPath: epicsPath,
basePath, basePath,
}); });
......
...@@ -9,7 +9,11 @@ import { ...@@ -9,7 +9,11 @@ import {
} from 'ee/roadmap/constants'; } from 'ee/roadmap/constants';
import createStore from 'ee/roadmap/store'; import createStore from 'ee/roadmap/store';
import { getTimeframeForMonthsView } from 'ee/roadmap/utils/roadmap_utils'; import { getTimeframeForMonthsView } from 'ee/roadmap/utils/roadmap_utils';
import { mockTimeframeInitialDate, mockGroupId, rawMilestones } from 'ee_jest/roadmap/mock_data'; import {
mockTimeframeInitialDate,
mockGroupId,
mockGroupMilestones,
} from 'ee_jest/roadmap/mock_data';
import { createMockDirective, getBinding } from 'helpers/vue_mock_directive'; import { createMockDirective, getBinding } from 'helpers/vue_mock_directive';
const initializeStore = (mockTimeframeMonths) => { const initializeStore = (mockTimeframeMonths) => {
...@@ -19,7 +23,7 @@ const initializeStore = (mockTimeframeMonths) => { ...@@ -19,7 +23,7 @@ const initializeStore = (mockTimeframeMonths) => {
presetType: PRESET_TYPES.MONTHS, presetType: PRESET_TYPES.MONTHS,
timeframe: mockTimeframeMonths, timeframe: mockTimeframeMonths,
}); });
store.dispatch('receiveMilestonesSuccess', { rawMilestones }); store.dispatch('receiveMilestonesSuccess', { rawMilestones: mockGroupMilestones });
return store; return store;
}; };
......
...@@ -13,7 +13,6 @@ import * as types from 'ee/roadmap/store/mutation_types'; ...@@ -13,7 +13,6 @@ import * as types from 'ee/roadmap/store/mutation_types';
import { getTimeframeForMonthsView } from 'ee/roadmap/utils/roadmap_utils'; import { getTimeframeForMonthsView } from 'ee/roadmap/utils/roadmap_utils';
import { import {
basePath, basePath,
epicsPath,
mockFormattedEpic, mockFormattedEpic,
mockFormattedChildEpic2, mockFormattedChildEpic2,
mockGroupId, mockGroupId,
...@@ -62,7 +61,6 @@ describe('RoadmapApp', () => { ...@@ -62,7 +61,6 @@ describe('RoadmapApp', () => {
timeframe, timeframe,
hasFiltersApplied, hasFiltersApplied,
filterQueryString: '', filterQueryString: '',
initialEpicsPath: epicsPath,
basePath, basePath,
}); });
}); });
......
...@@ -8,7 +8,23 @@ import { dateFromString } from 'helpers/datetime_helpers'; ...@@ -8,7 +8,23 @@ import { dateFromString } from 'helpers/datetime_helpers';
export const mockScrollBarSize = 15; export const mockScrollBarSize = 15;
export const mockGroupId = 2; export const mockGroupId = 1;
const mockGroup1 = {
id: `gid://gitlab/Group/${mockGroupId}`,
name: 'Gitlab Org',
fullName: 'Gitlab Org',
fullPath: '/groups/gitlab-org/',
__typename: 'Group',
};
const mockGroup2 = {
id: 'gid://gitlab/Group/2',
name: 'Marketing',
fullName: 'Gitlab Org / Marketing',
fullPath: '/groups/gitlab-org/marketing/',
__typename: 'Group',
};
export const mockShellWidth = 2000; export const mockShellWidth = 2000;
...@@ -18,8 +34,6 @@ export const mockSortedBy = 'start_date_asc'; ...@@ -18,8 +34,6 @@ export const mockSortedBy = 'start_date_asc';
export const basePath = '/groups/gitlab-org/-/epics.json'; export const basePath = '/groups/gitlab-org/-/epics.json';
export const epicsPath = '/groups/gitlab-org/-/epics.json?start_date=2017-11-1&end_date=2018-4-30';
export const mockNewEpicEndpoint = '/groups/gitlab-org/-/epics'; export const mockNewEpicEndpoint = '/groups/gitlab-org/-/epics';
export const mockSvgPath = '/foo/bar.svg'; export const mockSvgPath = '/foo/bar.svg';
...@@ -155,9 +169,7 @@ export const mockEpic = { ...@@ -155,9 +169,7 @@ export const mockEpic = {
'Explicabo et soluta minus praesentium minima ab et voluptatem. Quas architecto vero corrupti voluptatibus labore accusantium consectetur. Aliquam aut impedit voluptates illum molestias aut harum. Aut non odio praesentium aut.\n\nQuo asperiores aliquid sed nobis. Omnis sint iste provident numquam. Qui voluptatem tempore aut aut voluptas dolorem qui.\n\nEst est nemo quod est. Odit modi eos natus cum illo aut. Expedita nostrum ea est omnis magnam ut eveniet maxime. Itaque ipsam provident minima et occaecati ut. Dicta est perferendis sequi perspiciatis rerum voluptatum deserunt.', 'Explicabo et soluta minus praesentium minima ab et voluptatem. Quas architecto vero corrupti voluptatibus labore accusantium consectetur. Aliquam aut impedit voluptates illum molestias aut harum. Aut non odio praesentium aut.\n\nQuo asperiores aliquid sed nobis. Omnis sint iste provident numquam. Qui voluptatem tempore aut aut voluptas dolorem qui.\n\nEst est nemo quod est. Odit modi eos natus cum illo aut. Expedita nostrum ea est omnis magnam ut eveniet maxime. Itaque ipsam provident minima et occaecati ut. Dicta est perferendis sequi perspiciatis rerum voluptatum deserunt.',
title: title:
'Cupiditate exercitationem unde harum reprehenderit maxime eius velit recusandae incidunt quia.', 'Cupiditate exercitationem unde harum reprehenderit maxime eius velit recusandae incidunt quia.',
groupId: 2, group: mockGroup1,
groupName: 'Gitlab Org',
groupFullName: 'Gitlab Org',
startDate: new Date('2017-11-10'), startDate: new Date('2017-11-10'),
originalStartDate: new Date('2017-11-10'), originalStartDate: new Date('2017-11-10'),
endDate: new Date('2018-06-02'), endDate: new Date('2018-06-02'),
...@@ -169,27 +181,36 @@ export const mockEpic = { ...@@ -169,27 +181,36 @@ export const mockEpic = {
}; };
export const mockRawEpic = { export const mockRawEpic = {
id: 41, __typename: 'Epic',
iid: 2, parent: null,
description: null, id: 'gid://gitlab/Epic/41',
iid: '2',
title: 'Another marketing', title: 'Another marketing',
group_id: 56, description: '',
group_name: 'Marketing', state: 'opened',
group_full_name: 'Gitlab Org / Marketing', startDate: '2017-06-26',
start_date: '2017-6-26', dueDate: '2018-03-10',
end_date: '2018-03-10', webUrl: 'http://gdk.test:3000/groups/gitlab-org/marketing/-/epics/1',
web_url: '/groups/gitlab-org/marketing/-/epics/2', hasChildren: false,
created_at: '2021-01-22T13:51:19Z', hasParent: false,
updated_at: '2021-01-27T05:40:19Z',
user_discussions_count: 2,
confidential: false, confidential: false,
descendantWeightSum: {
closedIssues: 3,
openedIssues: 2,
__typename: 'EpicDescendantWeights',
},
descendantCounts: { descendantCounts: {
openedEpics: 3, openedEpics: 3,
closedEpics: 2, closedEpics: 2,
__typename: 'EpicDescendantCount',
}, },
group: { group: mockGroup1,
fullPath: '/groups/gitlab-org/marketing/', };
},
export const mockRawEpic2 = {
...mockRawEpic,
startDate: '2017-12-31',
dueDate: '2018-02-15',
}; };
export const mockFormattedChildEpic1 = { export const mockFormattedChildEpic1 = {
...@@ -197,9 +218,7 @@ export const mockFormattedChildEpic1 = { ...@@ -197,9 +218,7 @@ export const mockFormattedChildEpic1 = {
iid: 52, iid: 52,
description: null, description: null,
title: 'Marketing child epic 1', title: 'Marketing child epic 1',
groupId: 56, group: mockGroup1,
groupName: 'Marketing',
groupFullName: 'Gitlab Org / Marketing',
startDate: new Date(2017, 10, 1), startDate: new Date(2017, 10, 1),
originalStartDate: new Date(2017, 5, 26), originalStartDate: new Date(2017, 5, 26),
endDate: new Date(2018, 2, 10), endDate: new Date(2018, 2, 10),
...@@ -221,9 +240,7 @@ export const mockFormattedChildEpic2 = { ...@@ -221,9 +240,7 @@ export const mockFormattedChildEpic2 = {
iid: 53, iid: 53,
description: null, description: null,
title: 'Marketing child epic 2', title: 'Marketing child epic 2',
groupId: 56, group: mockGroup1,
groupName: 'Marketing',
groupFullName: 'Gitlab Org / Marketing',
startDate: new Date(2017, 10, 1), startDate: new Date(2017, 10, 1),
originalStartDate: new Date(2017, 5, 26), originalStartDate: new Date(2017, 5, 26),
endDate: new Date(2018, 2, 10), endDate: new Date(2018, 2, 10),
...@@ -240,37 +257,27 @@ export const mockFormattedChildEpic2 = { ...@@ -240,37 +257,27 @@ export const mockFormattedChildEpic2 = {
}; };
export const mockFormattedEpic = { export const mockFormattedEpic = {
id: 41, ...mockRawEpic,
iid: 2,
description: null,
title: 'Another marketing',
groupId: 56,
groupName: 'Marketing',
groupFullName: 'Gitlab Org / Marketing',
startDate: new Date(2017, 10, 1), startDate: new Date(2017, 10, 1),
originalStartDate: new Date(2017, 5, 26), originalStartDate: new Date(2017, 5, 26),
endDate: new Date(2018, 2, 10), endDate: new Date(2018, 2, 10),
originalEndDate: new Date(2018, 2, 10), originalEndDate: new Date(2018, 2, 10),
startDateOutOfRange: true, startDateOutOfRange: true,
endDateOutOfRange: false, endDateOutOfRange: false,
webUrl: '/groups/gitlab-org/marketing/-/epics/2',
newEpic: undefined,
createdAt: '2021-01-22T13:51:19Z',
updatedAt: '2021-01-27T05:40:19Z',
userDiscussionsCount: 2,
confidential: false, confidential: false,
descendantWeightSum: {
closedIssues: 3,
openedIssues: 2,
},
descendantCounts: {
openedEpics: 3,
closedEpics: 2,
},
isChildEpic: false, isChildEpic: false,
group: { };
fullPath: '/groups/gitlab-org/marketing/',
}, export const mockFormattedEpic2 = {
...mockRawEpic2,
isChildEpic: false,
newEpic: undefined,
startDateOutOfRange: false,
endDateOutOfRange: false,
startDate: new Date(2017, 11, 31),
originalStartDate: new Date(2017, 11, 31),
endDate: new Date(2018, 1, 15),
originalEndDate: new Date(2018, 1, 15),
}; };
export const rawEpics = [ export const rawEpics = [
...@@ -279,43 +286,37 @@ export const rawEpics = [ ...@@ -279,43 +286,37 @@ export const rawEpics = [
iid: 2, iid: 2,
description: null, description: null,
title: 'Another marketing', title: 'Another marketing',
group_id: 56, startDate: '2017-12-26',
group_name: 'Marketing', endDate: '2018-03-10',
group_full_name: 'Gitlab Org / Marketing', webUrl: '/groups/gitlab-org/marketing/-/epics/2',
start_date: '2017-12-26',
end_date: '2018-03-10',
web_url: '/groups/gitlab-org/marketing/-/epics/2',
descendantCounts: defaultDescendantCounts, descendantCounts: defaultDescendantCounts,
hasParent: true, hasParent: true,
parent: { parent: {
id: '40', id: '40',
}, },
group: mockGroup2,
}, },
{ {
id: 40, id: 40,
iid: 1, iid: 1,
description: null, description: null,
title: 'Marketing epic', title: 'Marketing epic',
group_id: 56, startDate: '2017-12-25',
group_name: 'Marketing', endDate: '2018-03-09',
group_full_name: 'Gitlab Org / Marketing', webUrl: '/groups/gitlab-org/marketing/-/epics/1',
start_date: '2017-12-25',
end_date: '2018-03-09',
web_url: '/groups/gitlab-org/marketing/-/epics/1',
descendantCounts: defaultDescendantCounts, descendantCounts: defaultDescendantCounts,
hasParent: false, hasParent: false,
group: mockGroup2,
}, },
{ {
id: 39, id: 39,
iid: 12, iid: 12,
description: null, description: null,
title: 'Epic with end in first timeframe month', title: 'Epic with end in first timeframe month',
group_id: 2, group: mockGroup1,
group_name: 'Gitlab Org', startDate: '2017-04-02',
group_full_name: 'Gitlab Org', endDate: '2017-11-30',
start_date: '2017-04-02', webUrl: '/groups/gitlab-org/-/epics/12',
end_date: '2017-11-30',
web_url: '/groups/gitlab-org/-/epics/12',
descendantCounts: defaultDescendantCounts, descendantCounts: defaultDescendantCounts,
hasParent: false, hasParent: false,
}, },
...@@ -324,12 +325,10 @@ export const rawEpics = [ ...@@ -324,12 +325,10 @@ export const rawEpics = [
iid: 11, iid: 11,
description: null, description: null,
title: 'Epic with end date out of range', title: 'Epic with end date out of range',
group_id: 2, group: mockGroup2,
group_name: 'Gitlab Org', startDate: '2018-01-15',
group_full_name: 'Gitlab Org', endDate: '2020-01-03',
start_date: '2018-01-15', webUrl: '/groups/gitlab-org/-/epics/11',
end_date: '2020-01-03',
web_url: '/groups/gitlab-org/-/epics/11',
descendantCounts: defaultDescendantCounts, descendantCounts: defaultDescendantCounts,
hasParent: false, hasParent: false,
}, },
...@@ -338,12 +337,10 @@ export const rawEpics = [ ...@@ -338,12 +337,10 @@ export const rawEpics = [
iid: 10, iid: 10,
description: null, description: null,
title: 'Epic with timeline in same month', title: 'Epic with timeline in same month',
group_id: 2, group: mockGroup2,
group_name: 'Gitlab Org', startDate: '2018-01-01',
group_full_name: 'Gitlab Org', endDate: '2018-01-31',
start_date: '2018-01-01', webUrl: '/groups/gitlab-org/-/epics/10',
end_date: '2018-01-31',
web_url: '/groups/gitlab-org/-/epics/10',
descendantCounts: defaultDescendantCounts, descendantCounts: defaultDescendantCounts,
hasParent: false, hasParent: false,
}, },
...@@ -352,12 +349,10 @@ export const rawEpics = [ ...@@ -352,12 +349,10 @@ export const rawEpics = [
iid: 8, iid: 8,
description: null, description: null,
title: 'Epic with out of range start & null end', title: 'Epic with out of range start & null end',
group_id: 2, group: mockGroup1,
group_name: 'Gitlab Org', startDate: '2017-09-04',
group_full_name: 'Gitlab Org', endDate: null,
start_date: '2017-09-04', webUrl: '/groups/gitlab-org/-/epics/8',
end_date: null,
web_url: '/groups/gitlab-org/-/epics/8',
descendantCounts: defaultDescendantCounts, descendantCounts: defaultDescendantCounts,
hasParent: false, hasParent: false,
}, },
...@@ -366,12 +361,10 @@ export const rawEpics = [ ...@@ -366,12 +361,10 @@ export const rawEpics = [
iid: 6, iid: 6,
description: null, description: null,
title: 'Epic with only start date', title: 'Epic with only start date',
group_id: 2, group: mockGroup1,
group_name: 'Gitlab Org', startDate: '2017-11-27',
group_full_name: 'Gitlab Org', endDate: null,
start_date: '2017-11-27', webUrl: '/groups/gitlab-org/-/epics/6',
end_date: null,
web_url: '/groups/gitlab-org/-/epics/6',
descendantCounts: defaultDescendantCounts, descendantCounts: defaultDescendantCounts,
hasParent: false, hasParent: false,
}, },
...@@ -381,12 +374,10 @@ export const rawEpics = [ ...@@ -381,12 +374,10 @@ export const rawEpics = [
description: description:
'Animi dolorem error ipsam assumenda. Dolor reprehenderit sit soluta molestias id. Explicabo vel dolores numquam earum ut aliquid. Quisquam aliquam a totam laborum quia.\n\nEt voluptatem reiciendis qui cum. Labore ratione delectus minus et voluptates. Dolor voluptatem nisi neque fugiat ut ullam dicta odit. Aut quaerat provident ducimus aut molestiae hic esse.\n\nSuscipit non repellat laudantium quaerat. Voluptatum dolor explicabo vel illo earum. Laborum vero occaecati qui autem cumque dolorem autem. Enim voluptatibus a dolorem et.', 'Animi dolorem error ipsam assumenda. Dolor reprehenderit sit soluta molestias id. Explicabo vel dolores numquam earum ut aliquid. Quisquam aliquam a totam laborum quia.\n\nEt voluptatem reiciendis qui cum. Labore ratione delectus minus et voluptates. Dolor voluptatem nisi neque fugiat ut ullam dicta odit. Aut quaerat provident ducimus aut molestiae hic esse.\n\nSuscipit non repellat laudantium quaerat. Voluptatum dolor explicabo vel illo earum. Laborum vero occaecati qui autem cumque dolorem autem. Enim voluptatibus a dolorem et.',
title: 'Et repellendus quo et laboriosam corrupti ex nisi qui.', title: 'Et repellendus quo et laboriosam corrupti ex nisi qui.',
group_id: 2, group: mockGroup1,
group_name: 'Gitlab Org', startDate: '2018-01-01',
group_full_name: 'Gitlab Org', endDate: '2018-02-02',
start_date: '2018-01-01', webUrl: '/groups/gitlab-org/-/epics/4',
end_date: '2018-02-02',
web_url: '/groups/gitlab-org/-/epics/4',
descendantCounts: defaultDescendantCounts, descendantCounts: defaultDescendantCounts,
hasParent: false, hasParent: false,
}, },
...@@ -396,12 +387,10 @@ export const rawEpics = [ ...@@ -396,12 +387,10 @@ export const rawEpics = [
description: description:
'Magnam placeat ut esse aut vel. Et sit ab soluta ut eos et et. Nesciunt expedita sit et optio maiores quas facilis. Provident ut aut et nihil. Nesciunt ipsum fuga labore dolor quia.\n\nSit suscipit impedit aut dolore non provident. Nesciunt nemo excepturi voluptatem natus veritatis. Vel ut possimus reiciendis dolorem et. Recusandae voluptatem voluptatum aut iure. Sapiente quia est iste similique quidem quia omnis et.\n\nId aut assumenda beatae iusto est dicta consequatur. Tempora voluptatem pariatur ab velit vero ut reprehenderit fuga. Dolor modi aspernatur eos atque eveniet harum sed voluptatem. Dolore iusto voluptas dolor enim labore dolorum consequatur dolores.', 'Magnam placeat ut esse aut vel. Et sit ab soluta ut eos et et. Nesciunt expedita sit et optio maiores quas facilis. Provident ut aut et nihil. Nesciunt ipsum fuga labore dolor quia.\n\nSit suscipit impedit aut dolore non provident. Nesciunt nemo excepturi voluptatem natus veritatis. Vel ut possimus reiciendis dolorem et. Recusandae voluptatem voluptatum aut iure. Sapiente quia est iste similique quidem quia omnis et.\n\nId aut assumenda beatae iusto est dicta consequatur. Tempora voluptatem pariatur ab velit vero ut reprehenderit fuga. Dolor modi aspernatur eos atque eveniet harum sed voluptatem. Dolore iusto voluptas dolor enim labore dolorum consequatur dolores.',
title: 'Nostrum ut nisi fugiat accusantium qui velit dignissimos.', title: 'Nostrum ut nisi fugiat accusantium qui velit dignissimos.',
group_id: 2, group: mockGroup1,
group_name: 'Gitlab Org', startDate: '2017-12-01',
group_full_name: 'Gitlab Org', endDate: '2018-03-26',
start_date: '2017-12-01', webUrl: '/groups/gitlab-org/-/epics/3',
end_date: '2018-03-26',
web_url: '/groups/gitlab-org/-/epics/3',
descendantCounts: defaultDescendantCounts, descendantCounts: defaultDescendantCounts,
hasParent: true, hasParent: true,
parent: { parent: {
...@@ -414,12 +403,10 @@ export const rawEpics = [ ...@@ -414,12 +403,10 @@ export const rawEpics = [
description: description:
'Deleniti id facere numquam cum consectetur sint ipsum consequatur. Odit nihil harum consequuntur est nemo adipisci. Incidunt suscipit voluptatem et culpa at voluptatem consequuntur. Rerum aliquam earum quia consequatur ipsam quae ut.\n\nQuod molestias ducimus quia ratione nostrum ut adipisci. Fugiat officiis reiciendis repellendus quia ut ipsa. Voluptatum ut dolor perferendis nostrum. Porro a ducimus sequi qui quos ea. Earum velit architecto necessitatibus at dicta.\n\nModi aut non fugiat autem doloribus nobis ea. Sit quam corrupti blanditiis nihil tempora ratione enim ex. Aliquam quia ut impedit ut velit reprehenderit quae amet. Unde quod at dolorum eligendi in ducimus perspiciatis accusamus.', 'Deleniti id facere numquam cum consectetur sint ipsum consequatur. Odit nihil harum consequuntur est nemo adipisci. Incidunt suscipit voluptatem et culpa at voluptatem consequuntur. Rerum aliquam earum quia consequatur ipsam quae ut.\n\nQuod molestias ducimus quia ratione nostrum ut adipisci. Fugiat officiis reiciendis repellendus quia ut ipsa. Voluptatum ut dolor perferendis nostrum. Porro a ducimus sequi qui quos ea. Earum velit architecto necessitatibus at dicta.\n\nModi aut non fugiat autem doloribus nobis ea. Sit quam corrupti blanditiis nihil tempora ratione enim ex. Aliquam quia ut impedit ut velit reprehenderit quae amet. Unde quod at dolorum eligendi in ducimus perspiciatis accusamus.',
title: 'Sit beatae amet quaerat consequatur non repudiandae qui.', title: 'Sit beatae amet quaerat consequatur non repudiandae qui.',
group_id: 2, group: mockGroup1,
group_name: 'Gitlab Org', startDate: '2017-11-26',
group_full_name: 'Gitlab Org', endDate: '2018-03-22',
start_date: '2017-11-26', webUrl: '/groups/gitlab-org/-/epics/2',
end_date: '2018-03-22',
web_url: '/groups/gitlab-org/-/epics/2',
descendantCounts: defaultDescendantCounts, descendantCounts: defaultDescendantCounts,
hasParent: false, hasParent: false,
}, },
...@@ -430,12 +417,10 @@ export const rawEpics = [ ...@@ -430,12 +417,10 @@ export const rawEpics = [
'Explicabo et soluta minus praesentium minima ab et voluptatem. Quas architecto vero corrupti voluptatibus labore accusantium consectetur. Aliquam aut impedit voluptates illum molestias aut harum. Aut non odio praesentium aut.\n\nQuo asperiores aliquid sed nobis. Omnis sint iste provident numquam. Qui voluptatem tempore aut aut voluptas dolorem qui.\n\nEst est nemo quod est. Odit modi eos natus cum illo aut. Expedita nostrum ea est omnis magnam ut eveniet maxime. Itaque ipsam provident minima et occaecati ut. Dicta est perferendis sequi perspiciatis rerum voluptatum deserunt.', 'Explicabo et soluta minus praesentium minima ab et voluptatem. Quas architecto vero corrupti voluptatibus labore accusantium consectetur. Aliquam aut impedit voluptates illum molestias aut harum. Aut non odio praesentium aut.\n\nQuo asperiores aliquid sed nobis. Omnis sint iste provident numquam. Qui voluptatem tempore aut aut voluptas dolorem qui.\n\nEst est nemo quod est. Odit modi eos natus cum illo aut. Expedita nostrum ea est omnis magnam ut eveniet maxime. Itaque ipsam provident minima et occaecati ut. Dicta est perferendis sequi perspiciatis rerum voluptatum deserunt.',
title: title:
'Cupiditate exercitationem unde harum reprehenderit maxime eius velit recusandae incidunt quia.', 'Cupiditate exercitationem unde harum reprehenderit maxime eius velit recusandae incidunt quia.',
group_id: 2, group: mockGroup1,
group_name: 'Gitlab Org', startDate: '2017-07-10',
group_full_name: 'Gitlab Org', endDate: '2018-06-02',
start_date: '2017-07-10', webUrl: '/groups/gitlab-org/-/epics/1',
end_date: '2018-06-02',
web_url: '/groups/gitlab-org/-/epics/1',
descendantCounts: defaultDescendantCounts, descendantCounts: defaultDescendantCounts,
hasParent: false, hasParent: false,
}, },
...@@ -444,12 +429,10 @@ export const rawEpics = [ ...@@ -444,12 +429,10 @@ export const rawEpics = [
iid: 2, iid: 2,
description: null, description: null,
title: 'Epic with invalid dates', title: 'Epic with invalid dates',
group_id: 56, group: mockGroup2,
group_name: 'Marketing', startDate: '2018-12-26',
group_full_name: 'Gitlab Org / Marketing', endDate: '2018-03-10',
start_date: '2018-12-26', webUrl: '/groups/gitlab-org/marketing/-/epics/22',
end_date: '2018-03-10',
web_url: '/groups/gitlab-org/marketing/-/epics/22',
descendantCounts: defaultDescendantCounts, descendantCounts: defaultDescendantCounts,
hasParent: false, hasParent: false,
}, },
...@@ -502,73 +485,115 @@ export const mockUnsortedEpics = [ ...@@ -502,73 +485,115 @@ export const mockUnsortedEpics = [
}, },
]; ];
export const mockEpicNode1 = {
__typename: 'Epic',
parent: null,
id: 'gid://gitlab/Epic/40',
iid: '2',
title: 'Marketing epic',
description: 'Mock epic description',
state: 'opened',
startDate: '2017-12-25',
dueDate: '2018-02-15',
webUrl: 'http://gdk.test:3000/groups/gitlab-org/marketing/-/epics/1',
hasChildren: false,
hasParent: false,
confidential: false,
descendantWeightSum: {
closedIssues: 3,
openedIssues: 2,
__typename: 'EpicDescendantWeights',
},
descendantCounts: {
openedEpics: 3,
closedEpics: 2,
__typename: 'EpicDescendantCount',
},
group: mockGroup1,
};
export const mockEpicNode2 = {
__typename: 'Epic',
parent: null,
id: 'gid://gitlab/Epic/41',
iid: '3',
title: 'Another marketing',
startDate: '2017-12-26',
dueDate: '2018-03-10',
state: 'opened',
webUrl: 'http://gdk.test:3000/groups/gitlab-org/marketing/-/epics/2',
descendantWeightSum: {
closedIssues: 0,
openedIssues: 1,
__typename: 'EpicDescendantWeights',
},
descendantCounts: {
openedEpics: 0,
closedEpics: 0,
__typename: 'EpicDescendantCount',
},
group: mockGroup1,
};
export const mockGroupEpics = [mockEpicNode1, mockEpicNode2];
export const mockGroupEpicsQueryResponse = { export const mockGroupEpicsQueryResponse = {
data: { data: {
group: { group: {
id: 'gid://gitlab/Group/2', id: 'gid://gitlab/Group/1',
name: 'Gitlab Org', name: 'Gitlab Org',
epics: { epics: {
edges: [ edges: [
{ {
node: { node: {
id: 'gid://gitlab/Epic/40', ...mockEpicNode1,
title: 'Marketing epic',
startDate: '2017-12-25',
dueDate: '2018-03-09',
webUrl: '/groups/gitlab-org/marketing/-/epics/1',
group: {
name: 'Gitlab Org',
fullName: 'Gitlab Org',
},
}, },
__typename: 'EpicEdge',
}, },
{ {
node: { node: {
id: 'gid://gitlab/Epic/41', ...mockEpicNode2,
title: 'Another marketing',
startDate: '2017-12-26',
dueDate: '2018-03-10',
webUrl: '/groups/gitlab-org/marketing/-/epics/2',
group: {
name: 'Gitlab Org',
fullName: 'Gitlab Org',
},
}, },
__typename: 'EpicEdge',
}, },
], ],
__typename: 'EpicConnection',
}, },
__typename: 'Group',
}, },
}, },
}; };
export const mockGroupEpicsQueryResponseFormatted = [ export const mockChildEpicNode1 = {
{ __typename: 'Epic',
id: 'gid://gitlab/Epic/40', id: 'gid://gitlab/Epic/70',
title: 'Marketing epic', iid: '10',
startDate: '2017-12-25', title: 'child epic title',
dueDate: '2018-03-09', description: null,
webUrl: '/groups/gitlab-org/marketing/-/epics/1', state: 'opened',
group: { webUrl: 'http://gdk.test:3000/groups/gitlab-org/-/epics/10',
name: 'Gitlab Org', startDate: null,
fullName: 'Gitlab Org', dueDate: null,
}, hasChildren: false,
groupName: 'Gitlab Org', hasParent: true,
groupFullName: 'Gitlab Org', confidential: false,
descendantWeightSum: {
closedIssues: 0,
openedIssues: 0,
__typename: 'EpicDescendantWeights',
}, },
{ descendantCounts: {
id: 'gid://gitlab/Epic/41', openedEpics: 0,
title: 'Another marketing', closedEpics: 0,
startDate: '2017-12-26', __typename: 'EpicDescendantCount',
dueDate: '2018-03-10',
webUrl: '/groups/gitlab-org/marketing/-/epics/2',
group: {
name: 'Gitlab Org',
fullName: 'Gitlab Org',
},
groupName: 'Gitlab Org',
groupFullName: 'Gitlab Org',
}, },
]; group: {
name: 'Gitlab Org',
fullName: 'Gitlab Org',
fullPath: 'gitlab-org',
__typename: 'Group',
},
};
export const mockEpicChildEpicsQueryResponse = { export const mockEpicChildEpicsQueryResponse = {
data: { data: {
...@@ -578,54 +603,27 @@ export const mockEpicChildEpicsQueryResponse = { ...@@ -578,54 +603,27 @@ export const mockEpicChildEpicsQueryResponse = {
epic: { epic: {
id: 'gid://gitlab/Epic/1', id: 'gid://gitlab/Epic/1',
title: 'Error omnis quos consequatur', title: 'Error omnis quos consequatur',
hasChildren: true,
children: { children: {
edges: mockGroupEpicsQueryResponse.data.group.epics.edges, edges: [
{
node: {
...mockChildEpicNode1,
},
__typename: 'EpicEdge',
},
],
__typename: 'EpicConnection',
}, },
__typename: 'Epic',
}, },
__typename: 'Group',
}, },
}, },
}; };
export const mockEpicChildEpicsQueryResponseFormatted = {
data: {
group: {
id: 'gid://gitlab/Group/2',
name: 'Gitlab Org',
epic: {
id: 'gid://gitlab/Epic/1',
title: 'Error omnis quos consequatur',
children: [mockFormattedChildEpic1, mockFormattedChildEpic2],
},
},
},
};
export const rawMilestones = [
{
id: 'gid://gitlab/Milestone/40',
iid: 1,
state: 'active',
description: null,
title: 'Milestone 1',
startDate: '2017-12-25',
dueDate: '2018-03-09',
webPath: '/groups/gitlab-org/-/milestones/1',
},
{
id: 'gid://gitlab/Milestone/41',
iid: 2,
state: 'active',
description: null,
title: 'Milestone 2',
startDate: '2017-12-26',
dueDate: '2018-03-10',
webPath: '/groups/gitlab-org/-/milestones/2',
},
];
export const mockMilestone = { export const mockMilestone = {
id: 1, id: 1,
iid: 1,
state: 'active', state: 'active',
description: description:
'Explicabo et soluta minus praesentium minima ab et voluptatem. Quas architecto vero corrupti voluptatibus labore accusantium consectetur. Aliquam aut impedit voluptates illum molestias aut harum. Aut non odio praesentium aut.\n\nQuo asperiores aliquid sed nobis. Omnis sint iste provident numquam. Qui voluptatem tempore aut aut voluptas dolorem qui.\n\nEst est nemo quod est. Odit modi eos natus cum illo aut. Expedita nostrum ea est omnis magnam ut eveniet maxime. Itaque ipsam provident minima et occaecati ut. Dicta est perferendis sequi perspiciatis rerum voluptatum deserunt.', 'Explicabo et soluta minus praesentium minima ab et voluptatem. Quas architecto vero corrupti voluptatibus labore accusantium consectetur. Aliquam aut impedit voluptates illum molestias aut harum. Aut non odio praesentium aut.\n\nQuo asperiores aliquid sed nobis. Omnis sint iste provident numquam. Qui voluptatem tempore aut aut voluptas dolorem qui.\n\nEst est nemo quod est. Odit modi eos natus cum illo aut. Expedita nostrum ea est omnis magnam ut eveniet maxime. Itaque ipsam provident minima et occaecati ut. Dicta est perferendis sequi perspiciatis rerum voluptatum deserunt.',
...@@ -641,7 +639,6 @@ export const mockMilestone = { ...@@ -641,7 +639,6 @@ export const mockMilestone = {
export const mockMilestone2 = { export const mockMilestone2 = {
id: 2, id: 2,
iid: 2,
state: 'active', state: 'active',
description: description:
'Explicabo et soluta minus praesentium minima ab et voluptatem. Quas architecto vero corrupti voluptatibus labore accusantium consectetur. Aliquam aut impedit voluptates illum molestias aut harum. Aut non odio praesentium aut.\n\nQuo asperiores aliquid sed nobis. Omnis sint iste provident numquam. Qui voluptatem tempore aut aut voluptas dolorem qui.\n\nEst est nemo quod est. Odit modi eos natus cum illo aut. Expedita nostrum ea est omnis magnam ut eveniet maxime. Itaque ipsam provident minima et occaecati ut. Dicta est perferendis sequi perspiciatis rerum voluptatum deserunt.', 'Explicabo et soluta minus praesentium minima ab et voluptatem. Quas architecto vero corrupti voluptatibus labore accusantium consectetur. Aliquam aut impedit voluptates illum molestias aut harum. Aut non odio praesentium aut.\n\nQuo asperiores aliquid sed nobis. Omnis sint iste provident numquam. Qui voluptatem tempore aut aut voluptas dolorem qui.\n\nEst est nemo quod est. Odit modi eos natus cum illo aut. Expedita nostrum ea est omnis magnam ut eveniet maxime. Itaque ipsam provident minima et occaecati ut. Dicta est perferendis sequi perspiciatis rerum voluptatum deserunt.',
...@@ -656,7 +653,6 @@ export const mockMilestone2 = { ...@@ -656,7 +653,6 @@ export const mockMilestone2 = {
export const mockFormattedMilestone = { export const mockFormattedMilestone = {
id: 1, id: 1,
iid: 1,
state: 'active', state: 'active',
title: title:
'Cupiditate exercitationem unde harum reprehenderit maxime eius velit recusandae incidunt quia.', 'Cupiditate exercitationem unde harum reprehenderit maxime eius velit recusandae incidunt quia.',
...@@ -675,6 +671,36 @@ export const mockFormattedMilestone = { ...@@ -675,6 +671,36 @@ export const mockFormattedMilestone = {
newMilestone: undefined, newMilestone: undefined,
}; };
export const mockGroupMilestoneNode1 = {
id: 'gid://gitlab/Milestone/40',
title: 'Sprint - Tempore voluptatibus et aut consequatur similique animi dolores veritatis.',
description: '',
state: 'active',
startDate: '2017-12-25',
dueDate: '2018-03-09',
webPath: '/gitlab-org/gitlab-org/-/milestones/1',
projectMilestone: false,
groupMilestone: true,
subgroupMilestone: false,
__typename: 'Milestone',
};
export const mockGroupMilestoneNode2 = {
id: 'gid://gitlab/Milestone/41',
description: 'Maiores dolor vel nihil non nam commodi.',
title: 'Milestone 2',
state: 'active',
startDate: '2017-12-26',
dueDate: '2018-03-10',
webPath: '/gitlab-org/gitlab-test/-/milestones/2',
projectMilestone: false,
groupMilestone: true,
subgroupMilestone: false,
__typename: 'Milestone',
};
export const mockGroupMilestones = [mockGroupMilestoneNode1, mockGroupMilestoneNode2];
export const mockGroupMilestonesQueryResponse = { export const mockGroupMilestonesQueryResponse = {
data: { data: {
group: { group: {
...@@ -684,30 +710,20 @@ export const mockGroupMilestonesQueryResponse = { ...@@ -684,30 +710,20 @@ export const mockGroupMilestonesQueryResponse = {
edges: [ edges: [
{ {
node: { node: {
iid: 1, ...mockGroupMilestoneNode1,
id: 'gid://gitlab/Milestone/40',
state: 'active',
description: null,
title: 'Milestone 1',
startDate: '2017-12-25',
dueDate: '2018-03-09',
webPath: '/groups/gitlab-org/-/milestones/1',
}, },
__typename: 'MilestoneEdge',
}, },
{ {
node: { node: {
iid: 2, ...mockGroupMilestoneNode2,
id: 'gid://gitlab/Milestone/41',
state: 'active',
description: null,
title: 'Milestone 2',
startDate: '2017-12-26',
dueDate: '2018-03-10',
webPath: '/groups/gitlab-org/-/milestones/2',
}, },
__typename: 'MilestoneEdge',
}, },
], ],
__typename: 'MilestoneConnection',
}, },
__typename: 'Group',
}, },
}, },
}; };
......
...@@ -13,19 +13,21 @@ import axios from '~/lib/utils/axios_utils'; ...@@ -13,19 +13,21 @@ import axios from '~/lib/utils/axios_utils';
import { import {
mockGroupId, mockGroupId,
basePath, basePath,
epicsPath,
mockTimeframeInitialDate, mockTimeframeInitialDate,
mockTimeframeMonthsPrepend, mockTimeframeMonthsPrepend,
mockTimeframeMonthsAppend, mockTimeframeMonthsAppend,
rawEpics, rawEpics,
mockRawEpic, mockRawEpic,
mockRawEpic2,
mockFormattedEpic, mockFormattedEpic,
mockFormattedEpic2,
mockSortedBy, mockSortedBy,
mockGroupEpicsQueryResponse, mockGroupEpicsQueryResponse,
mockGroupEpicsQueryResponseFormatted, mockGroupEpics,
mockGroupMilestonesQueryResponse,
mockEpicChildEpicsQueryResponse, mockEpicChildEpicsQueryResponse,
rawMilestones, mockChildEpicNode1,
mockGroupMilestonesQueryResponse,
mockGroupMilestones,
mockMilestone, mockMilestone,
mockFormattedMilestone, mockFormattedMilestone,
} from '../mock_data'; } from '../mock_data';
...@@ -46,7 +48,6 @@ describe('Roadmap Vuex Actions', () => { ...@@ -46,7 +48,6 @@ describe('Roadmap Vuex Actions', () => {
timeframe: mockTimeframeMonths, timeframe: mockTimeframeMonths,
presetType: PRESET_TYPES.MONTHS, presetType: PRESET_TYPES.MONTHS,
sortedBy: mockSortedBy, sortedBy: mockSortedBy,
initialEpicsPath: epicsPath,
filterQueryString: '', filterQueryString: '',
basePath, basePath,
timeframeStartDate, timeframeStartDate,
...@@ -76,55 +77,21 @@ describe('Roadmap Vuex Actions', () => { ...@@ -76,55 +77,21 @@ describe('Roadmap Vuex Actions', () => {
return testAction( return testAction(
actions.receiveEpicsSuccess, actions.receiveEpicsSuccess,
{ {
rawEpics: [ rawEpics: [mockRawEpic2],
{
...mockRawEpic,
start_date: '2017-12-31',
end_date: '2018-2-15',
descendantWeightSum: {
closedIssues: 3,
openedIssues: 2,
},
descendantCounts: {
openedEpics: 3,
closedEpics: 2,
},
},
],
}, },
state, state,
[ [
{ type: types.UPDATE_EPIC_IDS, payload: [mockRawEpic.id] }, { type: types.UPDATE_EPIC_IDS, payload: [mockRawEpic2.id] },
{ {
type: types.RECEIVE_EPICS_SUCCESS, type: types.RECEIVE_EPICS_SUCCESS,
payload: [ payload: [mockFormattedEpic2],
{
...mockFormattedEpic,
startDateOutOfRange: false,
endDateOutOfRange: false,
startDate: new Date(2017, 11, 31),
originalStartDate: new Date(2017, 11, 31),
endDate: new Date(2018, 1, 15),
originalEndDate: new Date(2018, 1, 15),
},
],
}, },
], ],
[ [
{ {
type: 'initItemChildrenFlags', type: 'initItemChildrenFlags',
payload: { payload: {
epics: [ epics: [mockFormattedEpic2],
{
...mockFormattedEpic,
startDateOutOfRange: false,
endDateOutOfRange: false,
startDate: new Date(2017, 11, 31),
originalStartDate: new Date(2017, 11, 31),
endDate: new Date(2018, 1, 15),
originalEndDate: new Date(2018, 1, 15),
},
],
}, },
}, },
], ],
...@@ -135,15 +102,7 @@ describe('Roadmap Vuex Actions', () => { ...@@ -135,15 +102,7 @@ describe('Roadmap Vuex Actions', () => {
return testAction( return testAction(
actions.receiveEpicsSuccess, actions.receiveEpicsSuccess,
{ {
rawEpics: [ rawEpics: [mockRawEpic],
{
...mockRawEpic,
descendantWeightSum: {
closedIssues: 3,
openedIssues: 2,
},
},
],
newEpic: true, newEpic: true,
timeframeExtended: true, timeframeExtended: true,
}, },
...@@ -162,9 +121,9 @@ describe('Roadmap Vuex Actions', () => { ...@@ -162,9 +121,9 @@ describe('Roadmap Vuex Actions', () => {
epics: [ epics: [
{ {
...mockFormattedEpic, ...mockFormattedEpic,
newEpic: true,
startDateOutOfRange: true, startDateOutOfRange: true,
endDateOutOfRange: false, endDateOutOfRange: false,
newEpic: true,
}, },
], ],
}, },
...@@ -223,7 +182,7 @@ describe('Roadmap Vuex Actions', () => { ...@@ -223,7 +182,7 @@ describe('Roadmap Vuex Actions', () => {
[ [
{ {
type: 'receiveEpicsSuccess', type: 'receiveEpicsSuccess',
payload: { rawEpics: mockGroupEpicsQueryResponseFormatted }, payload: { rawEpics: mockGroupEpics },
}, },
], ],
); );
...@@ -275,7 +234,7 @@ describe('Roadmap Vuex Actions', () => { ...@@ -275,7 +234,7 @@ describe('Roadmap Vuex Actions', () => {
{ {
type: 'receiveEpicsSuccess', type: 'receiveEpicsSuccess',
payload: { payload: {
rawEpics: mockGroupEpicsQueryResponseFormatted, rawEpics: mockGroupEpics,
newEpic: true, newEpic: true,
timeframeExtended: true, timeframeExtended: true,
}, },
...@@ -369,21 +328,7 @@ describe('Roadmap Vuex Actions', () => { ...@@ -369,21 +328,7 @@ describe('Roadmap Vuex Actions', () => {
actions.receiveChildrenSuccess, actions.receiveChildrenSuccess,
{ {
parentItemId: '41', parentItemId: '41',
rawChildren: [ rawChildren: [mockRawEpic2],
{
...mockRawEpic,
start_date: '2017-12-31',
end_date: '2018-2-15',
descendantWeightSum: {
closedIssues: 3,
openedIssues: 2,
},
descendantCounts: {
openedEpics: 3,
closedEpics: 2,
},
},
],
}, },
state, state,
[ [
...@@ -393,13 +338,7 @@ describe('Roadmap Vuex Actions', () => { ...@@ -393,13 +338,7 @@ describe('Roadmap Vuex Actions', () => {
parentItemId: '41', parentItemId: '41',
children: [ children: [
{ {
...mockFormattedEpic, ...mockFormattedEpic2,
startDateOutOfRange: false,
endDateOutOfRange: false,
startDate: new Date(2017, 11, 31),
originalStartDate: new Date(2017, 11, 31),
endDate: new Date(2018, 1, 15),
originalEndDate: new Date(2018, 1, 15),
isChildEpic: true, isChildEpic: true,
}, },
], ],
...@@ -416,13 +355,7 @@ describe('Roadmap Vuex Actions', () => { ...@@ -416,13 +355,7 @@ describe('Roadmap Vuex Actions', () => {
payload: { payload: {
epics: [ epics: [
{ {
...mockFormattedEpic, ...mockFormattedEpic2,
startDateOutOfRange: false,
endDateOutOfRange: false,
startDate: new Date(2017, 11, 31),
originalStartDate: new Date(2017, 11, 31),
endDate: new Date(2018, 1, 15),
originalEndDate: new Date(2018, 1, 15),
isChildEpic: true, isChildEpic: true,
}, },
], ],
...@@ -504,10 +437,6 @@ describe('Roadmap Vuex Actions', () => { ...@@ -504,10 +437,6 @@ describe('Roadmap Vuex Actions', () => {
itemExpanded: false, itemExpanded: false,
}; };
const children = epicUtils.extractGroupEpics(
mockEpicChildEpicsQueryResponse.data.group.epic.children.edges,
);
testAction( testAction(
actions.toggleEpic, actions.toggleEpic,
{ parentItem }, { parentItem },
...@@ -522,7 +451,7 @@ describe('Roadmap Vuex Actions', () => { ...@@ -522,7 +451,7 @@ describe('Roadmap Vuex Actions', () => {
type: 'receiveChildrenSuccess', type: 'receiveChildrenSuccess',
payload: { payload: {
parentItemId: parentItem.id, parentItemId: parentItem.id,
rawChildren: children, rawChildren: [mockChildEpicNode1],
}, },
}, },
], ],
...@@ -668,7 +597,7 @@ describe('Roadmap Vuex Actions', () => { ...@@ -668,7 +597,7 @@ describe('Roadmap Vuex Actions', () => {
}, },
{ {
type: 'receiveMilestonesSuccess', type: 'receiveMilestonesSuccess',
payload: { rawMilestones }, payload: { rawMilestones: mockGroupMilestones },
}, },
], ],
); );
...@@ -747,7 +676,7 @@ describe('Roadmap Vuex Actions', () => { ...@@ -747,7 +676,7 @@ describe('Roadmap Vuex Actions', () => {
describe('refreshMilestoneDates', () => { describe('refreshMilestoneDates', () => {
it('should update milestones after refreshing milestone dates to match with updated timeframe', () => { it('should update milestones after refreshing milestone dates to match with updated timeframe', () => {
const milestones = rawMilestones.map((milestone) => const milestones = mockGroupMilestones.map((milestone) =>
roadmapItemUtils.formatRoadmapItemDetails( roadmapItemUtils.formatRoadmapItemDetails(
milestone, milestone,
state.timeframeStartDate, state.timeframeStartDate,
......
...@@ -3,13 +3,7 @@ import mutations from 'ee/roadmap/store/mutations'; ...@@ -3,13 +3,7 @@ import mutations from 'ee/roadmap/store/mutations';
import defaultState from 'ee/roadmap/store/state'; import defaultState from 'ee/roadmap/store/state';
import { import { mockGroupId, basePath, mockSortedBy, mockEpic } from 'ee_jest/roadmap/mock_data';
mockGroupId,
basePath,
epicsPath,
mockSortedBy,
mockEpic,
} from 'ee_jest/roadmap/mock_data';
const setEpicMockData = (state) => { const setEpicMockData = (state) => {
state.epics = [mockEpic]; state.epics = [mockEpic];
...@@ -33,7 +27,6 @@ describe('Roadmap Store Mutations', () => { ...@@ -33,7 +27,6 @@ describe('Roadmap Store Mutations', () => {
epicsFetchResultEmpty: false, epicsFetchResultEmpty: false,
currentGroupId: mockGroupId, currentGroupId: mockGroupId,
sortedBy: mockSortedBy, sortedBy: mockSortedBy,
initialEpicsPath: epicsPath,
defaultInnerHeight: 600, defaultInnerHeight: 600,
extendedTimeframe: [], extendedTimeframe: [],
filterQueryString: '', filterQueryString: '',
......
import * as epicUtils from 'ee/roadmap/utils/epic_utils'; import * as epicUtils from 'ee/roadmap/utils/epic_utils';
import { mockGroupEpicsQueryResponse } from '../mock_data';
describe('extractGroupEpics', () => {
it('returns array of epics with `edges->nodes` nesting removed', () => {
const { edges } = mockGroupEpicsQueryResponse.data.group.epics;
const extractedEpics = epicUtils.extractGroupEpics(edges);
expect(extractedEpics).toHaveLength(edges.length);
expect(extractedEpics[0]).toEqual(
expect.objectContaining({
...edges[0].node,
groupName: edges[0].node.group.name,
groupFullName: edges[0].node.group.fullName,
}),
);
});
});
describe('addIsChildEpicTrueProperty', () => { describe('addIsChildEpicTrueProperty', () => {
const title = 'Lorem ipsum dolar sit'; const title = 'Lorem ipsum dolar sit';
const description = 'Beatae suscipit dolorum nihil quidem est accusamus'; const description = 'Beatae suscipit dolorum nihil quidem est accusamus';
......
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