Commit 0e07d9ea authored by Coung Ngo's avatar Coung Ngo

Combine tests in gfm_autocomplete_spec.rb for performance

Combine some related tests so we don't have to re-visit
pages which is expensive
parent e8d2c7d2
...@@ -30,7 +30,8 @@ RSpec.describe 'GFM autocomplete', :js do ...@@ -30,7 +30,8 @@ RSpec.describe 'GFM autocomplete', :js do
wait_for_requests wait_for_requests
end end
it 'updates issue description with GFM reference' do describe 'issue description' do
it 'updates with GFM reference' do
click_button 'Edit title and description' click_button 'Edit title and description'
wait_for_requests wait_for_requests
...@@ -48,13 +49,42 @@ RSpec.describe 'GFM autocomplete', :js do ...@@ -48,13 +49,42 @@ RSpec.describe 'GFM autocomplete', :js do
expect(find('.description')).to have_text(user.to_reference) expect(find('.description')).to have_text(user.to_reference)
end end
it 'opens quick action autocomplete when updating description' do it 'allows quick actions' do
click_button 'Edit title and description' click_button 'Edit title and description'
fill_in 'Description', with: '/' fill_in 'Description', with: '/'
expect(find_autocomplete_menu).to be_visible expect(find_autocomplete_menu).to be_visible
end end
end
describe 'triggering autocomplete' do
it 'only opens autocomplete menu when trigger character is after whitespace', :aggregate_failures do
fill_in 'Comment', with: 'testing@'
expect(page).not_to have_css('.atwho-view')
fill_in 'Comment', with: '@@'
expect(page).not_to have_css('.atwho-view')
fill_in 'Comment', with: "@#{user.username[0..2]}!"
expect(page).not_to have_css('.atwho-view')
fill_in 'Comment', with: "hello:#{user.username[0..2]}"
expect(page).not_to have_css('.atwho-view')
fill_in 'Comment', with: '7:'
expect(page).not_to have_css('.atwho-view')
fill_in 'Comment', with: 'w:'
expect(page).not_to have_css('.atwho-view')
fill_in 'Comment', with: 'Ё:'
expect(page).not_to have_css('.atwho-view')
fill_in 'Comment', with: "test\n\n@"
expect(find_autocomplete_menu).to be_visible
end
end
it 'opens autocomplete menu when field starts with text' do it 'opens autocomplete menu when field starts with text' do
fill_in 'Comment', with: '@' fill_in 'Comment', with: '@'
...@@ -92,12 +122,6 @@ RSpec.describe 'GFM autocomplete', :js do ...@@ -92,12 +122,6 @@ RSpec.describe 'GFM autocomplete', :js do
expect(find_autocomplete_menu).to have_text('alert milestone') expect(find_autocomplete_menu).to have_text('alert milestone')
end end
it 'doesnt open autocomplete menu character is prefixed with text' do
fill_in 'Comment', with: 'testing@'
expect(page).not_to have_css('.atwho-view')
end
it 'doesnt select the first item for non-assignee dropdowns' do it 'doesnt select the first item for non-assignee dropdowns' do
fill_in 'Comment', with: ':' fill_in 'Comment', with: ':'
...@@ -106,20 +130,6 @@ RSpec.describe 'GFM autocomplete', :js do ...@@ -106,20 +130,6 @@ RSpec.describe 'GFM autocomplete', :js do
expect(find_autocomplete_menu).not_to have_css('.cur') expect(find_autocomplete_menu).not_to have_css('.cur')
end end
it 'does not open autocomplete menu when ":" is prefixed by a number and letters' do
# Number.
fill_in 'Comment', with: '7:'
expect(page).not_to have_css('.atwho-view')
# ASCII letter.
fill_in 'Comment', with: 'w:'
expect(page).not_to have_css('.atwho-view')
# Non-ASCII letter.
fill_in 'Comment', with: 'Ё:'
expect(page).not_to have_css('.atwho-view')
end
it 'selects the first item for assignee dropdowns' do it 'selects the first item for assignee dropdowns' do
fill_in 'Comment', with: '@' fill_in 'Comment', with: '@'
...@@ -191,18 +201,6 @@ RSpec.describe 'GFM autocomplete', :js do ...@@ -191,18 +201,6 @@ RSpec.describe 'GFM autocomplete', :js do
expect(find_field('Comment').value).to have_text("~\"#{label.title}\"") expect(find_field('Comment').value).to have_text("~\"#{label.title}\"")
end end
it "shows dropdown after a new line" do
fill_in 'Comment', with: "test\n\n@"
expect(find_autocomplete_menu).to be_visible
end
it "does not show dropdown when preceded with a special character" do
fill_in 'Comment', with: '@@'
expect(page).not_to have_css('.atwho-view')
end
it 'doesn\'t wrap for assignee values' do it 'doesn\'t wrap for assignee values' do
fill_in 'Comment', with: "@#{user.username[0]}" fill_in 'Comment', with: "@#{user.username[0]}"
...@@ -219,18 +217,6 @@ RSpec.describe 'GFM autocomplete', :js do ...@@ -219,18 +217,6 @@ RSpec.describe 'GFM autocomplete', :js do
expect(find_field('Comment').value).to have_text('cartwheel_tone1') expect(find_field('Comment').value).to have_text('cartwheel_tone1')
end end
it 'doesn\'t open autocomplete after non-word character' do
fill_in 'Comment', with: "@#{user.username[0..2]}!"
expect(page).not_to have_css('.atwho-view')
end
it 'doesn\'t open autocomplete if there is no space before' do
fill_in 'Comment', with: "hello:#{user.username[0..2]}"
expect(page).not_to have_css('.atwho-view')
end
it 'triggers autocomplete after selecting a quick action' do it 'triggers autocomplete after selecting a quick action' do
fill_in 'Comment', with: '/as' fill_in 'Comment', with: '/as'
...@@ -449,7 +435,8 @@ RSpec.describe 'GFM autocomplete', :js do ...@@ -449,7 +435,8 @@ RSpec.describe 'GFM autocomplete', :js do
wait_for_requests wait_for_requests
end end
it 'updates issue description with GFM reference' do describe 'issue description' do
it 'updates with GFM reference' do
click_button 'Edit title and description' click_button 'Edit title and description'
wait_for_requests wait_for_requests
...@@ -466,6 +453,29 @@ RSpec.describe 'GFM autocomplete', :js do ...@@ -466,6 +453,29 @@ RSpec.describe 'GFM autocomplete', :js do
expect(find('.description')).to have_text(user.to_reference) expect(find('.description')).to have_text(user.to_reference)
end end
end
describe 'triggering autocomplete' do
it 'only opens autocomplete menu when trigger character is after whitespace', :aggregate_failures do
fill_in 'Comment', with: 'testing@'
expect(page).not_to have_css('.tribute-container')
fill_in 'Comment', with: "hello:#{user.username[0..2]}"
expect(page).not_to have_css('.tribute-container')
fill_in 'Comment', with: '7:'
expect(page).not_to have_css('.tribute-container')
fill_in 'Comment', with: 'w:'
expect(page).not_to have_css('.tribute-container')
fill_in 'Comment', with: 'Ё:'
expect(page).not_to have_css('.tribute-container')
fill_in 'Comment', with: "test\n\n@"
expect(find_tribute_autocomplete_menu).to be_visible
end
end
it 'opens autocomplete menu when field starts with text' do it 'opens autocomplete menu when field starts with text' do
fill_in 'Comment', with: '@' fill_in 'Comment', with: '@'
...@@ -503,26 +513,6 @@ RSpec.describe 'GFM autocomplete', :js do ...@@ -503,26 +513,6 @@ RSpec.describe 'GFM autocomplete', :js do
expect(find_tribute_autocomplete_menu).to have_text('alert milestone') expect(find_tribute_autocomplete_menu).to have_text('alert milestone')
end end
it 'does not open autocomplete menu when trigger character is prefixed with text' do
fill_in 'Comment', with: 'testing@'
expect(page).not_to have_css('.tribute-container')
end
it 'does not open autocomplete menu when ":" is prefixed by a number and letters' do
# Number.
fill_in 'Comment', with: '7:'
expect(page).not_to have_css('.tribute-container')
# ASCII letter.
fill_in 'Comment', with: 'w:'
expect(page).not_to have_css('.tribute-container')
# Non-ASCII letter.
fill_in 'Comment', with: 'Ё:'
expect(page).not_to have_css('.tribute-container')
end
it 'selects the first item for assignee dropdowns' do it 'selects the first item for assignee dropdowns' do
fill_in 'Comment', with: '@' fill_in 'Comment', with: '@'
...@@ -570,12 +560,6 @@ RSpec.describe 'GFM autocomplete', :js do ...@@ -570,12 +560,6 @@ RSpec.describe 'GFM autocomplete', :js do
expect(find_field('Comment').value).to have_text("~\"#{label.title}\"") expect(find_field('Comment').value).to have_text("~\"#{label.title}\"")
end end
it "shows dropdown after a new line" do
fill_in 'Comment', with: "test\n\n@"
expect(find_tribute_autocomplete_menu).to be_visible
end
it 'doesn\'t wrap for assignee values' do it 'doesn\'t wrap for assignee values' do
fill_in 'Comment', with: "@#{user.username[0..2]}" fill_in 'Comment', with: "@#{user.username[0..2]}"
...@@ -592,12 +576,6 @@ RSpec.describe 'GFM autocomplete', :js do ...@@ -592,12 +576,6 @@ RSpec.describe 'GFM autocomplete', :js do
expect(find_field('Comment').value).to have_text('cartwheel_tone1') expect(find_field('Comment').value).to have_text('cartwheel_tone1')
end end
it 'does not open autocomplete if there is no space before' do
fill_in 'Comment', with: "hello:#{user.username[0..2]}"
expect(page).not_to have_css('.tribute-container')
end
it 'autocompletes for quick actions' do it 'autocompletes for quick actions' do
fill_in 'Comment', with: '/as' fill_in 'Comment', with: '/as'
......
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