Commit f8dd8187 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'ss/add-state-to-milestones' into 'master'

Add active state to milestones fetch in filtered search

See merge request gitlab-org/gitlab!78153
parents 93dedb31 049a9dcd
...@@ -50,6 +50,8 @@ export const toggleFormEventPrefix = { ...@@ -50,6 +50,8 @@ export const toggleFormEventPrefix = {
issue: 'toggle-issue-form-', issue: 'toggle-issue-form-',
}; };
export const active = 'active';
export const inactiveId = 0; export const inactiveId = 0;
export const ISSUABLE = 'issuable'; export const ISSUABLE = 'issuable';
......
query GroupBoardMilestones($fullPath: ID!, $searchTerm: String) { query GroupBoardMilestones($fullPath: ID!, $searchTerm: String, $state: MilestoneStateEnum) {
group(fullPath: $fullPath) { group(fullPath: $fullPath) {
id id
milestones(includeAncestors: true, searchTitle: $searchTerm) { milestones(includeAncestors: true, searchTitle: $searchTerm, state: $state) {
nodes { nodes {
id id
title title
......
query ProjectBoardMilestones($fullPath: ID!, $searchTerm: String) { query ProjectBoardMilestones($fullPath: ID!, $searchTerm: String, $state: MilestoneStateEnum) {
project(fullPath: $fullPath) { project(fullPath: $fullPath) {
id id
milestones(searchTitle: $searchTerm, includeAncestors: true) { milestones(searchTitle: $searchTerm, includeAncestors: true, state: $state) {
nodes { nodes {
id id
title title
......
...@@ -15,6 +15,7 @@ import { ...@@ -15,6 +15,7 @@ import {
FilterFields, FilterFields,
ListTypeTitles, ListTypeTitles,
DraggableItemTypes, DraggableItemTypes,
active,
} from 'ee_else_ce/boards/constants'; } from 'ee_else_ce/boards/constants';
import { import {
formatIssueInput, formatIssueInput,
...@@ -209,6 +210,7 @@ export default { ...@@ -209,6 +210,7 @@ export default {
const variables = { const variables = {
fullPath, fullPath,
searchTerm, searchTerm,
state: active,
}; };
let query; let query;
......
...@@ -29,6 +29,8 @@ import * as types from '~/boards/stores/mutation_types'; ...@@ -29,6 +29,8 @@ import * as types from '~/boards/stores/mutation_types';
import mutations from '~/boards/stores/mutations'; import mutations from '~/boards/stores/mutations';
import { getIdFromGraphQLId } from '~/graphql_shared/utils'; import { getIdFromGraphQLId } from '~/graphql_shared/utils';
import projectBoardMilestones from '~/boards/graphql/project_board_milestones.query.graphql';
import groupBoardMilestones from '~/boards/graphql/group_board_milestones.query.graphql';
import { import {
mockLists, mockLists,
mockListsById, mockListsById,
...@@ -308,6 +310,36 @@ describe('fetchMilestones', () => { ...@@ -308,6 +310,36 @@ describe('fetchMilestones', () => {
expect(() => actions.fetchMilestones(store)).toThrow(new Error('Unknown board type')); expect(() => actions.fetchMilestones(store)).toThrow(new Error('Unknown board type'));
}); });
it.each([
[
'project',
{
query: projectBoardMilestones,
variables: { fullPath: 'gitlab-org/gitlab', state: 'active' },
},
],
[
'group',
{
query: groupBoardMilestones,
variables: { fullPath: 'gitlab-org/gitlab', state: 'active' },
},
],
])(
'when boardType is %s it calls fetchMilestones with the correct query and variables',
(boardType, variables) => {
jest.spyOn(gqlClient, 'query').mockResolvedValue(queryResponse);
const store = createStore();
store.state.boardType = boardType;
actions.fetchMilestones(store);
expect(gqlClient.query).toHaveBeenCalledWith(variables);
},
);
it('sets milestonesLoading to true', async () => { it('sets milestonesLoading to true', async () => {
jest.spyOn(gqlClient, 'query').mockResolvedValue(queryResponse); jest.spyOn(gqlClient, 'query').mockResolvedValue(queryResponse);
......
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