Fix specs
This commit is contained in:
parent
e197f27f19
commit
f72c1bf1c9
6 changed files with 30 additions and 16 deletions
|
@ -42,12 +42,17 @@
|
|||
|
||||
static filterHint(item, query) {
|
||||
const updatedItem = item;
|
||||
const { lastToken } = gl.FilteredSearchTokenizer.processTokens(query);
|
||||
let { lastToken } = gl.FilteredSearchTokenizer.processTokens(query);
|
||||
lastToken = lastToken || '';
|
||||
|
||||
if (!lastToken) {
|
||||
if (!lastToken || query.split('').last() === ' ') {
|
||||
updatedItem.droplab_hidden = false;
|
||||
} else {
|
||||
updatedItem.droplab_hidden = updatedItem.hint.indexOf(lastToken.toLowerCase()) === -1;
|
||||
} else if (lastToken) {
|
||||
const split = lastToken.split(':');
|
||||
const tokenName = split[0].split(' ').last();
|
||||
|
||||
const match = updatedItem.hint.indexOf(tokenName.toLowerCase()) === -1;
|
||||
updatedItem.droplab_hidden = tokenName ? match : false;
|
||||
}
|
||||
|
||||
return updatedItem;
|
||||
|
|
|
@ -62,6 +62,7 @@
|
|||
const value = input.value;
|
||||
const hasExistingValue = value.length !== 0;
|
||||
const { lastToken, searchToken } = gl.FilteredSearchTokenizer.processTokens(value);
|
||||
const lastSearchToken = searchToken.split(' ').last();
|
||||
|
||||
// Find out what part of the token value the user has typed
|
||||
// and remove it from input before appending the selected token value
|
||||
|
@ -74,8 +75,8 @@
|
|||
// Add 2 length to account for the length of the front and back quotes
|
||||
const lengthToRemove = hasQuotes ? lastTokenString.length + 2 : lastTokenString.length;
|
||||
input.value = value.slice(0, -1 * (lengthToRemove));
|
||||
} else if (searchToken !== '' && word.indexOf(searchToken) !== -1) {
|
||||
input.value = value.slice(0, -1 * searchToken.length);
|
||||
} else if (searchToken !== '' && word.indexOf(lastSearchToken) !== -1) {
|
||||
input.value = value.slice(0, -1 * lastSearchToken.length);
|
||||
}
|
||||
|
||||
input.value += hasExistingValue && addSpace ? ` ${word}` : word;
|
||||
|
@ -150,11 +151,17 @@
|
|||
const { lastToken, searchToken } = this.tokenizer
|
||||
.processTokens(this.filteredSearchInput.value);
|
||||
|
||||
if (lastToken === searchToken) {
|
||||
if (this.filteredSearchInput.value.split('').last() === ' ') {
|
||||
this.updateCurrentDropdownOffset();
|
||||
}
|
||||
|
||||
if (lastToken === searchToken && lastToken !== null) {
|
||||
// Token is not fully initialized yet because it has no value
|
||||
// Eg. token = 'label:'
|
||||
|
||||
const split = lastToken.split(':');
|
||||
this.loadDropdown(split.length > 1 ? split[0] : '');
|
||||
const dropdownName = split[0].split(' ').last();
|
||||
this.loadDropdown(split.length > 1 ? dropdownName : '');
|
||||
} else if (lastToken) {
|
||||
// Token has been initialized into an object because it has a value
|
||||
this.loadDropdown(lastToken.key);
|
||||
|
|
|
@ -13,7 +13,7 @@ describe 'Dropdown assignee', js: true, feature: true do
|
|||
def send_keys_to_filtered_search(input)
|
||||
input.split("").each do |i|
|
||||
filtered_search.send_keys(i)
|
||||
sleep 3
|
||||
sleep 5
|
||||
wait_for_ajax
|
||||
end
|
||||
end
|
||||
|
@ -65,7 +65,7 @@ describe 'Dropdown assignee', js: true, feature: true do
|
|||
|
||||
describe 'filtering' do
|
||||
before do
|
||||
filtered_search.set('assignee:')
|
||||
send_keys_to_filtered_search('assignee:')
|
||||
end
|
||||
|
||||
it 'filters by name' do
|
||||
|
@ -118,7 +118,7 @@ describe 'Dropdown assignee', js: true, feature: true do
|
|||
end
|
||||
|
||||
it 'selects `no assignee`' do
|
||||
click_assignee('No Assignee')
|
||||
find('#js-dropdown-assignee .filter-dropdown-item', text: 'No Assignee').click
|
||||
expect(page).to have_css(js_dropdown_assignee, visible: false)
|
||||
expect(filtered_search.value).to eq("assignee:none")
|
||||
end
|
||||
|
|
|
@ -13,7 +13,7 @@ describe 'Dropdown author', js: true, feature: true do
|
|||
def send_keys_to_filtered_search(input)
|
||||
input.split("").each do |i|
|
||||
filtered_search.send_keys(i)
|
||||
sleep 3
|
||||
sleep 5
|
||||
wait_for_ajax
|
||||
end
|
||||
end
|
||||
|
@ -65,7 +65,8 @@ describe 'Dropdown author', js: true, feature: true do
|
|||
|
||||
describe 'filtering' do
|
||||
before do
|
||||
filtered_search.set('author:')
|
||||
filtered_search.set('author')
|
||||
send_keys_to_filtered_search(':')
|
||||
end
|
||||
|
||||
it 'filters by name' do
|
||||
|
@ -101,7 +102,8 @@ describe 'Dropdown author', js: true, feature: true do
|
|||
|
||||
describe 'selecting from dropdown' do
|
||||
before do
|
||||
filtered_search.set('author:')
|
||||
filtered_search.set('author')
|
||||
send_keys_to_filtered_search(':')
|
||||
end
|
||||
|
||||
it 'fills in the author username when the author has not been filtered' do
|
||||
|
|
|
@ -176,7 +176,7 @@ describe 'Dropdown label', js: true, feature: true do
|
|||
end
|
||||
|
||||
it 'selects `no label`' do
|
||||
click_label('No Label')
|
||||
find('#js-dropdown-label .filter-dropdown-item', text: 'No Label').click
|
||||
expect(page).to have_css(js_dropdown_label, visible: false)
|
||||
expect(filtered_search.value).to eq("label:none")
|
||||
end
|
||||
|
|
|
@ -17,9 +17,9 @@ describe 'Filter issues', js: true, feature: true do
|
|||
let!(:multiple_words_label) { create(:label, project: project, title: "Two words") }
|
||||
|
||||
let!(:closed_issue) { create(:issue, title: 'bug that is closed', project: project, state: :closed) }
|
||||
let(:filtered_search) { find('.filtered-search') }
|
||||
|
||||
def input_filtered_search(search_term)
|
||||
filtered_search = find('.filtered-search')
|
||||
filtered_search.set(search_term)
|
||||
filtered_search.send_keys(:enter)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue