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

Merge branch 'rj/epic-weight' into 'master'

Prevent weightSum to be updated on child epic fetch

See merge request gitlab-org/gitlab!67116
parents 3e767274 9b6b548b
......@@ -124,9 +124,8 @@ export const fetchItems = ({ dispatch }, { parentItem, isSubItem = false }) => {
pageInfo: data.group.epic.issues.pageInfo,
});
dispatch('setWeightSum', data.group.epic.descendantWeightSum);
if (!isSubItem) {
dispatch('setWeightSum', data.group.epic.descendantWeightSum);
dispatch('setChildrenCount', data.group.epic.descendantCounts);
dispatch('setHealthStatus', data.group.epic.healthStatus);
}
......
......@@ -448,6 +448,71 @@ describe('RelatedItemTree', () => {
);
});
it('should not dispatch `setWeightSum`, `setChildrenCount`, `setHealthStatus` when isSubItem is true', () => {
jest.spyOn(epicUtils.gqClient, 'query').mockReturnValue(
Promise.resolve({
data: mockQueryResponse.data,
}),
);
const children = epicUtils.processQueryResponse(mockQueryResponse.data.group);
const {
children: { pageInfo: epicPageInfo },
issues: { pageInfo: issuesPageInfo },
} = mockQueryResponse.data.group.epic;
testAction(
actions.fetchItems,
{ parentItem: mockParentItem, isSubItem: true },
{},
[],
[
{
type: 'requestItems',
payload: { parentItem: mockParentItem, isSubItem: true },
},
{
type: 'receiveItemsSuccess',
payload: {
parentItem: mockParentItem,
isSubItem: true,
children,
},
},
{
type: 'setItemChildren',
payload: {
parentItem: mockParentItem,
isSubItem: true,
children,
},
},
{
type: 'setItemChildrenFlags',
payload: {
isSubItem: true,
children,
},
},
{
type: 'setEpicPageInfo',
payload: {
parentItem: mockParentItem,
pageInfo: epicPageInfo,
},
},
{
type: 'setIssuePageInfo',
payload: {
parentItem: mockParentItem,
pageInfo: issuesPageInfo,
},
},
],
);
});
it('should dispatch `receiveItemsFailure` on request failure', () => {
jest.spyOn(epicUtils.gqClient, 'query').mockReturnValue(Promise.reject());
......
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