Commit 91e97c80 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch '54213-standardize-token-value-capitalization-in-filter-bar' into 'master'

Standardize token value capitalization in filter bar

Closes #54213

See merge request gitlab-org/gitlab-ce!23846
parents c2b3f64c 6e50b42e
...@@ -593,7 +593,7 @@ export default class FilteredSearchManager { ...@@ -593,7 +593,7 @@ export default class FilteredSearchManager {
tokens.forEach(token => { tokens.forEach(token => {
const condition = this.filteredSearchTokenKeys.searchByConditionKeyValue( const condition = this.filteredSearchTokenKeys.searchByConditionKeyValue(
token.key, token.key,
token.value.toLowerCase(), token.value,
); );
const tokenConfig = this.filteredSearchTokenKeys.searchByKey(token.key) || {}; const tokenConfig = this.filteredSearchTokenKeys.searchByKey(token.key) || {};
const { param } = tokenConfig; const { param } = tokenConfig;
......
...@@ -65,8 +65,10 @@ export default class FilteredSearchTokenKeys { ...@@ -65,8 +65,10 @@ export default class FilteredSearchTokenKeys {
searchByConditionKeyValue(key, value) { searchByConditionKeyValue(key, value) {
return ( return (
this.conditions.find(condition => condition.tokenKey === key && condition.value === value) || this.conditions.find(
null condition =>
condition.tokenKey === key && condition.value.toLowerCase() === value.toLowerCase(),
) || null
); );
} }
......
...@@ -60,52 +60,52 @@ export const conditions = [ ...@@ -60,52 +60,52 @@ export const conditions = [
{ {
url: 'assignee_id=None', url: 'assignee_id=None',
tokenKey: 'assignee', tokenKey: 'assignee',
value: 'none', value: 'None',
}, },
{ {
url: 'assignee_id=Any', url: 'assignee_id=Any',
tokenKey: 'assignee', tokenKey: 'assignee',
value: 'any', value: 'Any',
}, },
{ {
url: 'milestone_title=None', url: 'milestone_title=None',
tokenKey: 'milestone', tokenKey: 'milestone',
value: 'none', value: 'None',
}, },
{ {
url: 'milestone_title=Any', url: 'milestone_title=Any',
tokenKey: 'milestone', tokenKey: 'milestone',
value: 'any', value: 'Any',
}, },
{ {
url: 'milestone_title=%23upcoming', url: 'milestone_title=%23upcoming',
tokenKey: 'milestone', tokenKey: 'milestone',
value: 'upcoming', value: 'Upcoming',
}, },
{ {
url: 'milestone_title=%23started', url: 'milestone_title=%23started',
tokenKey: 'milestone', tokenKey: 'milestone',
value: 'started', value: 'Started',
}, },
{ {
url: 'label_name[]=None', url: 'label_name[]=None',
tokenKey: 'label', tokenKey: 'label',
value: 'none', value: 'None',
}, },
{ {
url: 'label_name[]=Any', url: 'label_name[]=Any',
tokenKey: 'any', tokenKey: 'label',
value: 'any', value: 'Any',
}, },
{ {
url: 'my_reaction_emoji=None', url: 'my_reaction_emoji=None',
tokenKey: 'my-reaction', tokenKey: 'my-reaction',
value: 'none', value: 'None',
}, },
{ {
url: 'my_reaction_emoji=Any', url: 'my_reaction_emoji=Any',
tokenKey: 'my-reaction', tokenKey: 'my-reaction',
value: 'any', value: 'Any',
}, },
]; ];
......
...@@ -57,10 +57,10 @@ ...@@ -57,10 +57,10 @@
avatar: { lazy: true, url: '{{avatar_url}}' } avatar: { lazy: true, url: '{{avatar_url}}' }
#js-dropdown-assignee.filtered-search-input-dropdown-menu.dropdown-menu #js-dropdown-assignee.filtered-search-input-dropdown-menu.dropdown-menu
%ul{ data: { dropdown: true } } %ul{ data: { dropdown: true } }
%li.filter-dropdown-item{ data: { value: 'none' } } %li.filter-dropdown-item{ data: { value: 'None' } }
%button.btn.btn-link{ type: 'button' } %button.btn.btn-link{ type: 'button' }
= _('None') = _('None')
%li.filter-dropdown-item{ data: { value: 'any' } } %li.filter-dropdown-item{ data: { value: 'Any' } }
%button.btn.btn-link{ type: 'button' } %button.btn.btn-link{ type: 'button' }
= _('Any') = _('Any')
%li.divider.droplab-item-ignore %li.divider.droplab-item-ignore
...@@ -73,16 +73,16 @@ ...@@ -73,16 +73,16 @@
avatar: { lazy: true, url: '{{avatar_url}}' } avatar: { lazy: true, url: '{{avatar_url}}' }
#js-dropdown-milestone.filtered-search-input-dropdown-menu.dropdown-menu #js-dropdown-milestone.filtered-search-input-dropdown-menu.dropdown-menu
%ul{ data: { dropdown: true } } %ul{ data: { dropdown: true } }
%li.filter-dropdown-item{ data: { value: 'none' } } %li.filter-dropdown-item{ data: { value: 'None' } }
%button.btn.btn-link{ type: 'button' } %button.btn.btn-link{ type: 'button' }
= _('None') = _('None')
%li.filter-dropdown-item{ data: { value: 'any' } } %li.filter-dropdown-item{ data: { value: 'Any' } }
%button.btn.btn-link{ type: 'button' } %button.btn.btn-link{ type: 'button' }
= _('Any') = _('Any')
%li.filter-dropdown-item{ data: { value: 'upcoming' } } %li.filter-dropdown-item{ data: { value: 'Upcoming' } }
%button.btn.btn-link{ type: 'button' } %button.btn.btn-link{ type: 'button' }
= _('Upcoming') = _('Upcoming')
%li.filter-dropdown-item{ data: { value: 'started' } } %li.filter-dropdown-item{ data: { value: 'Started' } }
%button.btn.btn-link{ type: 'button' } %button.btn.btn-link{ type: 'button' }
= _('Started') = _('Started')
%li.divider.droplab-item-ignore %li.divider.droplab-item-ignore
...@@ -92,10 +92,10 @@ ...@@ -92,10 +92,10 @@
{{title}} {{title}}
#js-dropdown-label.filtered-search-input-dropdown-menu.dropdown-menu #js-dropdown-label.filtered-search-input-dropdown-menu.dropdown-menu
%ul{ data: { dropdown: true } } %ul{ data: { dropdown: true } }
%li.filter-dropdown-item{ data: { value: 'none' } } %li.filter-dropdown-item{ data: { value: 'None' } }
%button.btn.btn-link{ type: 'button' } %button.btn.btn-link{ type: 'button' }
= _('None') = _('None')
%li.filter-dropdown-item{ data: { value: 'any' } } %li.filter-dropdown-item{ data: { value: 'Any' } }
%button.btn.btn-link{ type: 'button' } %button.btn.btn-link{ type: 'button' }
= _('Any') = _('Any')
%li.divider.droplab-item-ignore %li.divider.droplab-item-ignore
...@@ -107,10 +107,10 @@ ...@@ -107,10 +107,10 @@
{{title}} {{title}}
#js-dropdown-my-reaction.filtered-search-input-dropdown-menu.dropdown-menu #js-dropdown-my-reaction.filtered-search-input-dropdown-menu.dropdown-menu
%ul{ data: { dropdown: true } } %ul{ data: { dropdown: true } }
%li.filter-dropdown-item{ data: { value: 'none' } } %li.filter-dropdown-item{ data: { value: 'None' } }
%button.btn.btn-link{ type: 'button' } %button.btn.btn-link{ type: 'button' }
= _('None') = _('None')
%li.filter-dropdown-item{ data: { value: 'any' } } %li.filter-dropdown-item{ data: { value: 'Any' } }
%button.btn.btn-link{ type: 'button' } %button.btn.btn-link{ type: 'button' }
= _('Any') = _('Any')
%li.divider.droplab-item-ignore %li.divider.droplab-item-ignore
......
---
title: Standardize filter value capitlization in filter bar in both issues and boards pages
merge_request: 23846
author: obahareth
type: changed
...@@ -112,7 +112,7 @@ describe 'Issue Boards add issue modal filtering', :js do ...@@ -112,7 +112,7 @@ describe 'Issue Boards add issue modal filtering', :js do
page.within('.add-issues-modal') do page.within('.add-issues-modal') do
wait_for_requests wait_for_requests
expect(page).to have_selector('.js-visual-token', text: 'none') expect(page).to have_selector('.js-visual-token', text: 'None')
expect(page).to have_selector('.board-card', count: 1) expect(page).to have_selector('.board-card', count: 1)
end end
end end
...@@ -147,7 +147,7 @@ describe 'Issue Boards add issue modal filtering', :js do ...@@ -147,7 +147,7 @@ describe 'Issue Boards add issue modal filtering', :js do
page.within('.add-issues-modal') do page.within('.add-issues-modal') do
wait_for_requests wait_for_requests
expect(page).to have_selector('.js-visual-token', text: 'upcoming') expect(page).to have_selector('.js-visual-token', text: 'Upcoming')
expect(page).to have_selector('.board-card', count: 0) expect(page).to have_selector('.board-card', count: 0)
end end
end end
...@@ -182,7 +182,7 @@ describe 'Issue Boards add issue modal filtering', :js do ...@@ -182,7 +182,7 @@ describe 'Issue Boards add issue modal filtering', :js do
page.within('.add-issues-modal') do page.within('.add-issues-modal') do
wait_for_requests wait_for_requests
expect(page).to have_selector('.js-visual-token', text: 'none') expect(page).to have_selector('.js-visual-token', text: 'None')
expect(page).to have_selector('.board-card', count: 1) expect(page).to have_selector('.board-card', count: 1)
end end
end end
......
...@@ -160,7 +160,7 @@ describe 'Dropdown assignee', :js do ...@@ -160,7 +160,7 @@ describe 'Dropdown assignee', :js do
find('#js-dropdown-assignee .filter-dropdown-item', text: 'None').click find('#js-dropdown-assignee .filter-dropdown-item', text: 'None').click
expect(page).to have_css(js_dropdown_assignee, visible: false) expect(page).to have_css(js_dropdown_assignee, visible: false)
expect_tokens([assignee_token('none')]) expect_tokens([assignee_token('None')])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -168,7 +168,7 @@ describe 'Dropdown assignee', :js do ...@@ -168,7 +168,7 @@ describe 'Dropdown assignee', :js do
find('#js-dropdown-assignee .filter-dropdown-item', text: 'Any').click find('#js-dropdown-assignee .filter-dropdown-item', text: 'Any').click
expect(page).to have_css(js_dropdown_assignee, visible: false) expect(page).to have_css(js_dropdown_assignee, visible: false)
expect_tokens([assignee_token('any')]) expect_tokens([assignee_token('Any')])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
end end
......
...@@ -125,7 +125,7 @@ describe 'Dropdown emoji', :js do ...@@ -125,7 +125,7 @@ describe 'Dropdown emoji', :js do
find('#js-dropdown-my-reaction .filter-dropdown-item', text: 'None').click find('#js-dropdown-my-reaction .filter-dropdown-item', text: 'None').click
expect(page).to have_css(js_dropdown_emoji, visible: false) expect(page).to have_css(js_dropdown_emoji, visible: false)
expect_tokens([reaction_token('none', false)]) expect_tokens([reaction_token('None', false)])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -133,7 +133,7 @@ describe 'Dropdown emoji', :js do ...@@ -133,7 +133,7 @@ describe 'Dropdown emoji', :js do
find('#js-dropdown-my-reaction .filter-dropdown-item', text: 'Any').click find('#js-dropdown-my-reaction .filter-dropdown-item', text: 'Any').click
expect(page).to have_css(js_dropdown_emoji, visible: false) expect(page).to have_css(js_dropdown_emoji, visible: false)
expect_tokens([reaction_token('any', false)]) expect_tokens([reaction_token('Any', false)])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
......
...@@ -238,7 +238,7 @@ describe 'Dropdown label', :js do ...@@ -238,7 +238,7 @@ describe 'Dropdown label', :js do
find("#{js_dropdown_label} .filter-dropdown-item", text: 'None').click find("#{js_dropdown_label} .filter-dropdown-item", text: 'None').click
expect(page).not_to have_css(js_dropdown_label) expect(page).not_to have_css(js_dropdown_label)
expect_tokens([label_token('none', false)]) expect_tokens([label_token('None', false)])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -246,7 +246,7 @@ describe 'Dropdown label', :js do ...@@ -246,7 +246,7 @@ describe 'Dropdown label', :js do
find("#{js_dropdown_label} .filter-dropdown-item", text: 'Any').click find("#{js_dropdown_label} .filter-dropdown-item", text: 'Any').click
expect(page).not_to have_css(js_dropdown_label) expect(page).not_to have_css(js_dropdown_label)
expect_tokens([label_token('any', false)]) expect_tokens([label_token('Any', false)])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
end end
......
...@@ -192,7 +192,7 @@ describe 'Dropdown milestone', :js do ...@@ -192,7 +192,7 @@ describe 'Dropdown milestone', :js do
click_static_milestone('None') click_static_milestone('None')
expect(page).to have_css(js_dropdown_milestone, visible: false) expect(page).to have_css(js_dropdown_milestone, visible: false)
expect_tokens([milestone_token('none', false)]) expect_tokens([milestone_token('None', false)])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -200,7 +200,7 @@ describe 'Dropdown milestone', :js do ...@@ -200,7 +200,7 @@ describe 'Dropdown milestone', :js do
click_static_milestone('Any') click_static_milestone('Any')
expect(page).to have_css(js_dropdown_milestone, visible: false) expect(page).to have_css(js_dropdown_milestone, visible: false)
expect_tokens([milestone_token('any', false)]) expect_tokens([milestone_token('Any', false)])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -208,7 +208,7 @@ describe 'Dropdown milestone', :js do ...@@ -208,7 +208,7 @@ describe 'Dropdown milestone', :js do
click_static_milestone('Upcoming') click_static_milestone('Upcoming')
expect(page).to have_css(js_dropdown_milestone, visible: false) expect(page).to have_css(js_dropdown_milestone, visible: false)
expect_tokens([milestone_token('upcoming', false)]) expect_tokens([milestone_token('Upcoming', false)])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -216,7 +216,7 @@ describe 'Dropdown milestone', :js do ...@@ -216,7 +216,7 @@ describe 'Dropdown milestone', :js do
click_static_milestone('Started') click_static_milestone('Started')
expect(page).to have_css(js_dropdown_milestone, visible: false) expect(page).to have_css(js_dropdown_milestone, visible: false)
expect_tokens([milestone_token('started', false)]) expect_tokens([milestone_token('Started', false)])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
end end
......
...@@ -108,7 +108,7 @@ describe 'Filter issues', :js do ...@@ -108,7 +108,7 @@ describe 'Filter issues', :js do
it 'filters issues by no assignee' do it 'filters issues by no assignee' do
input_filtered_search('assignee:none') input_filtered_search('assignee:none')
expect_tokens([assignee_token('none')]) expect_tokens([assignee_token('None')])
expect_issues_list_count(3) expect_issues_list_count(3)
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -146,7 +146,7 @@ describe 'Filter issues', :js do ...@@ -146,7 +146,7 @@ describe 'Filter issues', :js do
it 'filters issues by no label' do it 'filters issues by no label' do
input_filtered_search('label:none') input_filtered_search('label:none')
expect_tokens([label_token('none', false)]) expect_tokens([label_token('None', false)])
expect_issues_list_count(4) expect_issues_list_count(4)
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -287,7 +287,7 @@ describe 'Filter issues', :js do ...@@ -287,7 +287,7 @@ describe 'Filter issues', :js do
it 'filters issues by no milestone' do it 'filters issues by no milestone' do
input_filtered_search("milestone:none") input_filtered_search("milestone:none")
expect_tokens([milestone_token('none', false)]) expect_tokens([milestone_token('None', false)])
expect_issues_list_count(3) expect_issues_list_count(3)
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -299,7 +299,7 @@ describe 'Filter issues', :js do ...@@ -299,7 +299,7 @@ describe 'Filter issues', :js do
input_filtered_search("milestone:upcoming") input_filtered_search("milestone:upcoming")
expect_tokens([milestone_token('upcoming', false)]) expect_tokens([milestone_token('Upcoming', false)])
expect_issues_list_count(1) expect_issues_list_count(1)
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -307,7 +307,7 @@ describe 'Filter issues', :js do ...@@ -307,7 +307,7 @@ describe 'Filter issues', :js do
it 'filters issues by started milestones' do it 'filters issues by started milestones' do
input_filtered_search("milestone:started") input_filtered_search("milestone:started")
expect_tokens([milestone_token('started', false)]) expect_tokens([milestone_token('Started', false)])
expect_issues_list_count(5) expect_issues_list_count(5)
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
......
...@@ -122,7 +122,7 @@ describe 'Visual tokens', :js do ...@@ -122,7 +122,7 @@ describe 'Visual tokens', :js do
end end
it 'changes value in visual token' do it 'changes value in visual token' do
expect(first('.tokens-container .filtered-search-token .value').text).to eq('none') expect(first('.tokens-container .filtered-search-token .value').text).to eq('None')
end end
it 'moves input to the right' do it 'moves input to the right' do
...@@ -147,7 +147,7 @@ describe 'Visual tokens', :js do ...@@ -147,7 +147,7 @@ describe 'Visual tokens', :js do
it 'selects static option from dropdown' do it 'selects static option from dropdown' do
find("#js-dropdown-milestone").find('.filter-dropdown-item', text: 'Upcoming').click find("#js-dropdown-milestone").find('.filter-dropdown-item', text: 'Upcoming').click
expect(first('.tokens-container .filtered-search-token .value').text).to eq('upcoming') expect(first('.tokens-container .filtered-search-token .value').text).to eq('Upcoming')
expect(is_input_focused).to eq(true) expect(is_input_focused).to eq(true)
end end
...@@ -348,7 +348,7 @@ describe 'Visual tokens', :js do ...@@ -348,7 +348,7 @@ describe 'Visual tokens', :js do
it 'tokenizes the search term to complete visual token' do it 'tokenizes the search term to complete visual token' do
expect_tokens([ expect_tokens([
author_token(user.name), author_token(user.name),
assignee_token('none') assignee_token('None')
]) ])
end end
end end
......
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