Commit 2f08c27c authored by Florie Guibert's avatar Florie Guibert

Search epic by title in issues

Changelog: changed
parent bd7f09e2
...@@ -125,6 +125,7 @@ export default { ...@@ -125,6 +125,7 @@ export default {
return { return {
fullPath: this.attrWorkspacePath, fullPath: this.attrWorkspacePath,
title: this.searchTerm, title: this.searchTerm,
in: this.searchTerm && this.issuableAttribute === IssuableType.Epic ? 'TITLE' : undefined,
state: this.$options.IssuableAttributeState[this.issuableAttribute], state: this.$options.IssuableAttributeState[this.issuableAttribute],
sort: this.issuableAttribute === IssuableType.Epic ? defaultEpicSort : null, sort: this.issuableAttribute === IssuableType.Epic ? defaultEpicSort : null,
}; };
......
#import "./epic.fragment.graphql" #import "./epic.fragment.graphql"
query issueEpics($fullPath: ID!, $title: String, $state: EpicState) { query issueEpics(
$fullPath: ID!
$title: String
$state: EpicState
$in: [IssuableSearchableField!]
) {
workspace: group(fullPath: $fullPath) { workspace: group(fullPath: $fullPath) {
attributes: epics( attributes: epics(
search: $title search: $title
in: $in
state: $state state: $state
includeAncestorGroups: true includeAncestorGroups: true
includeDescendantGroups: false includeDescendantGroups: false
......
...@@ -456,7 +456,7 @@ describe('SidebarDropdownWidget', () => { ...@@ -456,7 +456,7 @@ describe('SidebarDropdownWidget', () => {
}); });
}); });
describe('when a user is searching', () => { describe('when a user is searching epics', () => {
const mockSearchTerm = 'foobar'; const mockSearchTerm = 'foobar';
beforeEach(async () => { beforeEach(async () => {
...@@ -466,7 +466,7 @@ describe('SidebarDropdownWidget', () => { ...@@ -466,7 +466,7 @@ describe('SidebarDropdownWidget', () => {
await clickEdit(); await clickEdit();
}); });
it('sends a groupEpics query with the entered search term "foo"', async () => { it('sends a groupEpics query with the entered search term "foo" and in TITLE param', async () => {
findSearchBox().vm.$emit('input', mockSearchTerm); findSearchBox().vm.$emit('input', mockSearchTerm);
await wrapper.vm.$nextTick(); await wrapper.vm.$nextTick();
...@@ -478,6 +478,31 @@ describe('SidebarDropdownWidget', () => { ...@@ -478,6 +478,31 @@ describe('SidebarDropdownWidget', () => {
sort: 'TITLE_ASC', sort: 'TITLE_ASC',
state: 'opened', state: 'opened',
title: mockSearchTerm, title: mockSearchTerm,
in: 'TITLE',
});
});
});
describe('when a user is not searching', () => {
beforeEach(async () => {
groupEpicsSpy = jest.fn().mockResolvedValueOnce(emptyGroupEpicsResponse);
await createComponentWithApollo({ groupEpicsSpy });
await clickEdit();
});
it('sends a groupEpics query with empty title and undefined in param', async () => {
await wrapper.vm.$nextTick();
// Account for debouncing
jest.runAllTimers();
expect(groupEpicsSpy).toHaveBeenNthCalledWith(1, {
fullPath: mockIssue.groupPath,
sort: 'TITLE_ASC',
state: 'opened',
title: '',
in: undefined,
}); });
}); });
}); });
......
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