Commit 049a9dcd authored by Scott Stern's avatar Scott Stern Committed by Kushal Pandya

Add active state to milestones fetch in filtered search

parent 232c173b
......@@ -50,6 +50,8 @@ export const toggleFormEventPrefix = {
issue: 'toggle-issue-form-',
};
export const active = 'active';
export const inactiveId = 0;
export const ISSUABLE = 'issuable';
......
query GroupBoardMilestones($fullPath: ID!, $searchTerm: String) {
query GroupBoardMilestones($fullPath: ID!, $searchTerm: String, $state: MilestoneStateEnum) {
group(fullPath: $fullPath) {
id
milestones(includeAncestors: true, searchTitle: $searchTerm) {
milestones(includeAncestors: true, searchTitle: $searchTerm, state: $state) {
nodes {
id
title
......
query ProjectBoardMilestones($fullPath: ID!, $searchTerm: String) {
query ProjectBoardMilestones($fullPath: ID!, $searchTerm: String, $state: MilestoneStateEnum) {
project(fullPath: $fullPath) {
id
milestones(searchTitle: $searchTerm, includeAncestors: true) {
milestones(searchTitle: $searchTerm, includeAncestors: true, state: $state) {
nodes {
id
title
......
......@@ -15,6 +15,7 @@ import {
FilterFields,
ListTypeTitles,
DraggableItemTypes,
active,
} from 'ee_else_ce/boards/constants';
import {
formatIssueInput,
......@@ -209,6 +210,7 @@ export default {
const variables = {
fullPath,
searchTerm,
state: active,
};
let query;
......
......@@ -29,6 +29,8 @@ import * as types from '~/boards/stores/mutation_types';
import mutations from '~/boards/stores/mutations';
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 {
mockLists,
mockListsById,
......@@ -308,6 +310,36 @@ describe('fetchMilestones', () => {
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 () => {
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