Commit 09601bb5 authored by Dylan Griffith's avatar Dylan Griffith

Merge branch 'cngo-combine-tests-for-performance' into 'master'

Combine tests in `gfm_autocomplete_spec.rb` for performance

See merge request gitlab-org/gitlab!56369
parents b8edfed6 0e07d9ea
...@@ -30,30 +30,60 @@ RSpec.describe 'GFM autocomplete', :js do ...@@ -30,30 +30,60 @@ 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
click_button 'Edit title and description' it 'updates with GFM reference' do
click_button 'Edit title and description'
wait_for_requests wait_for_requests
fill_in 'Description', with: "@#{user.name[0...3]}" fill_in 'Description', with: "@#{user.name[0...3]}"
wait_for_requests wait_for_requests
find_highlighted_autocomplete_item.click find_highlighted_autocomplete_item.click
click_button 'Save changes' click_button 'Save changes'
wait_for_requests wait_for_requests
expect(find('.description')).to have_text(user.to_reference) expect(find('.description')).to have_text(user.to_reference)
end
it 'allows quick actions' do
click_button 'Edit title and description'
fill_in 'Description', with: '/'
expect(find_autocomplete_menu).to be_visible
end
end end
it 'opens quick action autocomplete when updating description' do describe 'triggering autocomplete' do
click_button 'Edit title and description' 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 'Description', with: '/' fill_in 'Comment', with: '@@'
expect(page).not_to have_css('.atwho-view')
expect(find_autocomplete_menu).to be_visible 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 end
it 'opens autocomplete menu when field starts with text' do it 'opens autocomplete menu when field starts with text' do
...@@ -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('thumbsdown') expect(find_field('Comment').value).to have_text('thumbsdown')
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,22 +435,46 @@ RSpec.describe 'GFM autocomplete', :js do ...@@ -449,22 +435,46 @@ 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
click_button 'Edit title and description' it 'updates with GFM reference' do
click_button 'Edit title and description'
wait_for_requests wait_for_requests
fill_in 'Description', with: "@#{user.name[0...3]}" fill_in 'Description', with: "@#{user.name[0...3]}"
wait_for_requests wait_for_requests
find_highlighted_tribute_autocomplete_menu.click find_highlighted_tribute_autocomplete_menu.click
click_button 'Save changes' click_button 'Save changes'
wait_for_requests wait_for_requests
expect(find('.description')).to have_text(user.to_reference)
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')
expect(find('.description')).to have_text(user.to_reference) 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 end
it 'opens autocomplete menu when field starts with text' do it 'opens autocomplete menu when field starts with text' do
...@@ -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