Commit 217d8f93 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch '321040-jira-list-search-not-working' into 'master'

Fix search functionality in Jira issues list

See merge request gitlab-org/gitlab!54312
parents 44cd01c7 4dddf170
...@@ -333,15 +333,19 @@ export default { ...@@ -333,15 +333,19 @@ export default {
this.fetchIssuables(); this.fetchIssuables();
}, },
handleFilter(filters) { handleFilter(filters) {
let search = null; const searchTokens = [];
filters.forEach((filter) => { filters.forEach((filter) => {
if (typeof filter === 'string') { if (filter.type === 'filtered-search-term') {
search = filter; if (filter.value.data) {
searchTokens.push(filter.value.data);
}
} }
}); });
this.filters.search = search; if (searchTokens.length) {
this.filters.search = searchTokens.join(' ');
}
this.page = 1; this.page = 1;
this.refetchIssuables(); this.refetchIssuables();
......
---
title: Fix search functionality in Jira issues list
merge_request: 54312
author:
type: fixed
...@@ -591,5 +591,75 @@ describe('Issuables list component', () => { ...@@ -591,5 +591,75 @@ describe('Issuables list component', () => {
expect(findFilteredSearchBar().props('initialFilterValue')).toEqual(['free text']); expect(findFilteredSearchBar().props('initialFilterValue')).toEqual(['free text']);
}); });
}); });
describe('on filter search', () => {
beforeEach(() => {
factory({ type: 'jira' });
window.history.pushState = jest.fn();
});
afterEach(() => {
window.history.pushState.mockRestore();
});
const emitOnFilter = (filter) => findFilteredSearchBar().vm.$emit('onFilter', filter);
describe('empty filter', () => {
const mockFilter = [];
it('updates URL with correct params', () => {
emitOnFilter(mockFilter);
expect(window.history.pushState).toHaveBeenCalledWith(
{},
'',
`${TEST_LOCATION}?state=opened`,
);
});
});
describe('filter with search term', () => {
const mockFilter = [
{
type: 'filtered-search-term',
value: { data: 'free' },
},
];
it('updates URL with correct params', () => {
emitOnFilter(mockFilter);
expect(window.history.pushState).toHaveBeenCalledWith(
{},
'',
`${TEST_LOCATION}?state=opened&search=free`,
);
});
});
describe('filter with multiple search terms', () => {
const mockFilter = [
{
type: 'filtered-search-term',
value: { data: 'free' },
},
{
type: 'filtered-search-term',
value: { data: 'text' },
},
];
it('updates URL with correct params', () => {
emitOnFilter(mockFilter);
expect(window.history.pushState).toHaveBeenCalledWith(
{},
'',
`${TEST_LOCATION}?state=opened&search=free+text`,
);
});
});
});
}); });
}); });
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