Commit 9a5e78c4 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'ph/filteredSearchReplacementUrl' into 'master'

Allow conditions to have a replacement URL in filtered search

See merge request gitlab-org/gitlab!38075
parents 5f6eecbe 499b571c
......@@ -743,7 +743,7 @@ export default class FilteredSearchManager {
let tokenPath = '';
if (condition) {
tokenPath = condition.url;
tokenPath = condition.replacementUrl || condition.url;
} else {
let tokenValue = token.value;
......
......@@ -225,6 +225,26 @@ describe('Filtered Search Manager', () => {
manager.search();
});
it('should use replacement URL for condition', done => {
tokensContainer.innerHTML = FilteredSearchSpecHelper.createTokensContainerHTML(
FilteredSearchSpecHelper.createFilterVisualTokenHTML('milestone', '=', '13', true),
);
visitUrl.mockImplementation(url => {
expect(url).toEqual(`${defaultParams}&milestone_title=replaced`);
done();
});
manager.filteredSearchTokenKeys.conditions.push({
url: 'milestone_title=13',
replacementUrl: 'milestone_title=replaced',
tokenKey: 'milestone',
value: '13',
operator: '=',
});
manager.search();
});
it('removes duplicated tokens', done => {
tokensContainer.innerHTML = FilteredSearchSpecHelper.createTokensContainerHTML(`
${FilteredSearchSpecHelper.createFilterVisualTokenHTML('label', '=', '~bug')}
......
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