Commit 364d948b authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Fix false positives in filtered search specs

Assertions were made based on elements found so the specs
still pass even if the elements don't exist
parent 7be2796e
...@@ -80,7 +80,7 @@ describe 'Dropdown hint', :js do ...@@ -80,7 +80,7 @@ describe 'Dropdown hint', :js do
expect(page).to have_css(js_dropdown_hint, visible: false) expect(page).to have_css(js_dropdown_hint, visible: false)
expect(page).to have_css('#js-dropdown-author', visible: true) expect(page).to have_css('#js-dropdown-author', visible: true)
expect_tokens([{ name: 'author' }]) expect_tokens([{ name: 'Author' }])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -89,7 +89,7 @@ describe 'Dropdown hint', :js do ...@@ -89,7 +89,7 @@ describe 'Dropdown hint', :js do
expect(page).to have_css(js_dropdown_hint, visible: false) expect(page).to have_css(js_dropdown_hint, visible: false)
expect(page).to have_css('#js-dropdown-assignee', visible: true) expect(page).to have_css('#js-dropdown-assignee', visible: true)
expect_tokens([{ name: 'assignee' }]) expect_tokens([{ name: 'Assignee' }])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -98,7 +98,7 @@ describe 'Dropdown hint', :js do ...@@ -98,7 +98,7 @@ describe 'Dropdown hint', :js do
expect(page).to have_css(js_dropdown_hint, visible: false) expect(page).to have_css(js_dropdown_hint, visible: false)
expect(page).to have_css('#js-dropdown-milestone', visible: true) expect(page).to have_css('#js-dropdown-milestone', visible: true)
expect_tokens([{ name: 'milestone' }]) expect_tokens([{ name: 'Milestone' }])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -107,7 +107,7 @@ describe 'Dropdown hint', :js do ...@@ -107,7 +107,7 @@ describe 'Dropdown hint', :js do
expect(page).to have_css(js_dropdown_hint, visible: false) expect(page).to have_css(js_dropdown_hint, visible: false)
expect(page).to have_css('#js-dropdown-label', visible: true) expect(page).to have_css('#js-dropdown-label', visible: true)
expect_tokens([{ name: 'label' }]) expect_tokens([{ name: 'Label' }])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -116,7 +116,7 @@ describe 'Dropdown hint', :js do ...@@ -116,7 +116,7 @@ describe 'Dropdown hint', :js do
expect(page).to have_css(js_dropdown_hint, visible: false) expect(page).to have_css(js_dropdown_hint, visible: false)
expect(page).to have_css('#js-dropdown-my-reaction', visible: true) expect(page).to have_css('#js-dropdown-my-reaction', visible: true)
expect_tokens([{ name: 'my-reaction' }]) expect_tokens([{ name: 'My-reaction' }])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -125,7 +125,7 @@ describe 'Dropdown hint', :js do ...@@ -125,7 +125,7 @@ describe 'Dropdown hint', :js do
expect(page).to have_css(js_dropdown_hint, visible: false) expect(page).to have_css(js_dropdown_hint, visible: false)
expect(page).to have_css('#js-dropdown-confidential', visible: true) expect(page).to have_css('#js-dropdown-confidential', visible: true)
expect_tokens([{ name: 'confidential' }]) expect_tokens([{ name: 'Confidential' }])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
end end
...@@ -137,7 +137,7 @@ describe 'Dropdown hint', :js do ...@@ -137,7 +137,7 @@ describe 'Dropdown hint', :js do
expect(page).to have_css(js_dropdown_hint, visible: false) expect(page).to have_css(js_dropdown_hint, visible: false)
expect(page).to have_css('#js-dropdown-author', visible: true) expect(page).to have_css('#js-dropdown-author', visible: true)
expect_tokens([{ name: 'author' }]) expect_tokens([{ name: 'Author' }])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -147,7 +147,7 @@ describe 'Dropdown hint', :js do ...@@ -147,7 +147,7 @@ describe 'Dropdown hint', :js do
expect(page).to have_css(js_dropdown_hint, visible: false) expect(page).to have_css(js_dropdown_hint, visible: false)
expect(page).to have_css('#js-dropdown-assignee', visible: true) expect(page).to have_css('#js-dropdown-assignee', visible: true)
expect_tokens([{ name: 'assignee' }]) expect_tokens([{ name: 'Assignee' }])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -157,7 +157,7 @@ describe 'Dropdown hint', :js do ...@@ -157,7 +157,7 @@ describe 'Dropdown hint', :js do
expect(page).to have_css(js_dropdown_hint, visible: false) expect(page).to have_css(js_dropdown_hint, visible: false)
expect(page).to have_css('#js-dropdown-milestone', visible: true) expect(page).to have_css('#js-dropdown-milestone', visible: true)
expect_tokens([{ name: 'milestone' }]) expect_tokens([{ name: 'Milestone' }])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -167,7 +167,7 @@ describe 'Dropdown hint', :js do ...@@ -167,7 +167,7 @@ describe 'Dropdown hint', :js do
expect(page).to have_css(js_dropdown_hint, visible: false) expect(page).to have_css(js_dropdown_hint, visible: false)
expect(page).to have_css('#js-dropdown-label', visible: true) expect(page).to have_css('#js-dropdown-label', visible: true)
expect_tokens([{ name: 'label' }]) expect_tokens([{ name: 'Label' }])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -177,7 +177,7 @@ describe 'Dropdown hint', :js do ...@@ -177,7 +177,7 @@ describe 'Dropdown hint', :js do
expect(page).to have_css(js_dropdown_hint, visible: false) expect(page).to have_css(js_dropdown_hint, visible: false)
expect(page).to have_css('#js-dropdown-my-reaction', visible: true) expect(page).to have_css('#js-dropdown-my-reaction', visible: true)
expect_tokens([{ name: 'my-reaction' }]) expect_tokens([{ name: 'My-reaction' }])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
end end
...@@ -189,7 +189,7 @@ describe 'Dropdown hint', :js do ...@@ -189,7 +189,7 @@ describe 'Dropdown hint', :js do
filtered_search.send_keys(:backspace) filtered_search.send_keys(:backspace)
click_hint('author') click_hint('author')
expect_tokens([{ name: 'author' }]) expect_tokens([{ name: 'Author' }])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -199,7 +199,7 @@ describe 'Dropdown hint', :js do ...@@ -199,7 +199,7 @@ describe 'Dropdown hint', :js do
filtered_search.send_keys(:backspace) filtered_search.send_keys(:backspace)
click_hint('assignee') click_hint('assignee')
expect_tokens([{ name: 'assignee' }]) expect_tokens([{ name: 'Assignee' }])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -209,7 +209,7 @@ describe 'Dropdown hint', :js do ...@@ -209,7 +209,7 @@ describe 'Dropdown hint', :js do
filtered_search.send_keys(:backspace) filtered_search.send_keys(:backspace)
click_hint('milestone') click_hint('milestone')
expect_tokens([{ name: 'milestone' }]) expect_tokens([{ name: 'Milestone' }])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -219,7 +219,7 @@ describe 'Dropdown hint', :js do ...@@ -219,7 +219,7 @@ describe 'Dropdown hint', :js do
filtered_search.send_keys(:backspace) filtered_search.send_keys(:backspace)
click_hint('label') click_hint('label')
expect_tokens([{ name: 'label' }]) expect_tokens([{ name: 'Label' }])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
...@@ -229,7 +229,7 @@ describe 'Dropdown hint', :js do ...@@ -229,7 +229,7 @@ describe 'Dropdown hint', :js do
filtered_search.send_keys(:backspace) filtered_search.send_keys(:backspace)
click_hint('my-reaction') click_hint('my-reaction')
expect_tokens([{ name: 'my-reaction' }]) expect_tokens([{ name: 'My-reaction' }])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
end end
...@@ -247,7 +247,7 @@ describe 'Dropdown hint', :js do ...@@ -247,7 +247,7 @@ describe 'Dropdown hint', :js do
expect(page).to have_css(js_dropdown_hint, visible: false) expect(page).to have_css(js_dropdown_hint, visible: false)
expect(page).to have_css('#js-dropdown-wip', visible: true) expect(page).to have_css('#js-dropdown-wip', visible: true)
expect_tokens([{ name: 'wip' }]) expect_tokens([{ name: 'WIP' }])
expect_filtered_search_input_empty expect_filtered_search_input_empty
end end
end end
......
...@@ -78,20 +78,17 @@ module FilteredSearchHelpers ...@@ -78,20 +78,17 @@ module FilteredSearchHelpers
# .tokens-container to make sure the correct names and values are rendered # .tokens-container to make sure the correct names and values are rendered
def expect_tokens(tokens) def expect_tokens(tokens)
page.within '.filtered-search-box .tokens-container' do page.within '.filtered-search-box .tokens-container' do
page.all(:css, '.tokens-container li .selectable').each_with_index do |el, index| token_elements = page.all(:css, 'li.filtered-search-token')
token_name = tokens[index][:name]
token_value = tokens[index][:value]
token_emoji = tokens[index][:emoji_name]
expect(el.find('.name')).to have_content(token_name) tokens.each_with_index do |token, index|
el = token_elements[index]
if token_value expect(el.find('.name')).to have_content(token[:name])
expect(el.find('.value')).to have_content(token_value) expect(el.find('.value')).to have_content(token[:value]) if token[:value].present?
end
# gl-emoji content is blank when the emoji unicode is not supported # gl-emoji content is blank when the emoji unicode is not supported
if token_emoji if token[:emoji_name].present?
selector = %(gl-emoji[data-name="#{token_emoji}"]) selector = %(gl-emoji[data-name="#{token[:emoji_name]}"])
expect(el.find('.value')).to have_css(selector) expect(el.find('.value')).to have_css(selector)
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