From 94e0ca004959196d0c8481f8f8eb28084ae021ae Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Thu, 21 Jul 2016 12:42:37 +0100 Subject: Allow GFM autocomplete to be trigger without the preceding space Closes #19975 --- spec/features/issues/gfm_autocomplete_spec.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 spec/features/issues/gfm_autocomplete_spec.rb (limited to 'spec/features/issues/gfm_autocomplete_spec.rb') diff --git a/spec/features/issues/gfm_autocomplete_spec.rb b/spec/features/issues/gfm_autocomplete_spec.rb new file mode 100644 index 00000000000..000b190de77 --- /dev/null +++ b/spec/features/issues/gfm_autocomplete_spec.rb @@ -0,0 +1,24 @@ +require 'rails_helper' + +feature 'GFM autocomplete', feature: true, js: true do + let(:user) { create(:user) } + let(:project) { create(:project) } + let(:issue) { create(:issue, project: project) } + + before do + project.team << [user, :master] + login_as(user) + visit namespace_project_issue_path(project.namespace, project, issue) + end + + it 'opens autocomplete menu when doesnt starts with space' do + sleep 2 + + page.within '.timeline-content-form' do + find('#note_note').native.send_keys('testing') + find('#note_note').native.send_keys('@') + end + + expect(page).to have_selector('.atwho-view') + end +end -- cgit v1.2.1 From 45fa7fd4ddf35314602168cd869ee4a67c44250b Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Thu, 21 Jul 2016 14:41:27 +0100 Subject: Correctly checks for character before GFM input char It must not be letter or number to work --- spec/features/issues/gfm_autocomplete_spec.rb | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'spec/features/issues/gfm_autocomplete_spec.rb') diff --git a/spec/features/issues/gfm_autocomplete_spec.rb b/spec/features/issues/gfm_autocomplete_spec.rb index 000b190de77..7e602672d30 100644 --- a/spec/features/issues/gfm_autocomplete_spec.rb +++ b/spec/features/issues/gfm_autocomplete_spec.rb @@ -9,16 +9,34 @@ feature 'GFM autocomplete', feature: true, js: true do project.team << [user, :master] login_as(user) visit namespace_project_issue_path(project.namespace, project, issue) - end - it 'opens autocomplete menu when doesnt starts with space' do sleep 2 + end + it 'opens autocomplete menu when field starts with text' do page.within '.timeline-content-form' do - find('#note_note').native.send_keys('testing') + find('#note_note').native.send_keys('') find('#note_note').native.send_keys('@') end expect(page).to have_selector('.atwho-view') end + + it 'opens autocomplete menu when field is prefixed with non-text character' do + page.within '.timeline-content-form' do + find('#note_note').native.send_keys('') + find('#note_note').native.send_keys('@') + end + + expect(page).to have_selector('.atwho-view') + end + + it 'doesnt open autocomplete menu character is prefixed with text' do + page.within '.timeline-content-form' do + find('#note_note').native.send_keys('testing') + find('#note_note').native.send_keys('@') + end + + expect(page).not_to have_selector('.atwho-view') + end end -- cgit v1.2.1 From 03a235783f697572fe201332cb82746401a01daf Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Mon, 14 Nov 2016 10:34:10 +0000 Subject: Tests fix --- spec/features/issues/gfm_autocomplete_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'spec/features/issues/gfm_autocomplete_spec.rb') diff --git a/spec/features/issues/gfm_autocomplete_spec.rb b/spec/features/issues/gfm_autocomplete_spec.rb index c0d093fb155..c421da97d76 100644 --- a/spec/features/issues/gfm_autocomplete_spec.rb +++ b/spec/features/issues/gfm_autocomplete_spec.rb @@ -20,7 +20,7 @@ feature 'GFM autocomplete', feature: true, js: true do find('#note_note').native.send_keys('@') end - expect(page).to have_selector('.atwho-view') + expect(page).to have_selector('.atwho-container') end it 'opens autocomplete menu when field is prefixed with non-text character' do @@ -29,7 +29,7 @@ feature 'GFM autocomplete', feature: true, js: true do find('#note_note').native.send_keys('@') end - expect(page).to have_selector('.atwho-view') + expect(page).to have_selector('.atwho-container') end it 'doesnt open autocomplete menu character is prefixed with text' do -- cgit v1.2.1 From a8cfb85a1ad5c835abe4b7cceefb9d8304717553 Mon Sep 17 00:00:00 2001 From: "Luke \"Jared\" Bennett" Date: Sat, 3 Dec 2016 10:44:18 +0000 Subject: Added special char test to the default beforeInsert callback. I removed the quotes from the milestone displayTpl and added a skip setting for emoji instance Review changes --- spec/features/issues/gfm_autocomplete_spec.rb | 67 +++++++++++++++++++++++---- 1 file changed, 58 insertions(+), 9 deletions(-) (limited to 'spec/features/issues/gfm_autocomplete_spec.rb') diff --git a/spec/features/issues/gfm_autocomplete_spec.rb b/spec/features/issues/gfm_autocomplete_spec.rb index c421da97d76..cd0512a37e6 100644 --- a/spec/features/issues/gfm_autocomplete_spec.rb +++ b/spec/features/issues/gfm_autocomplete_spec.rb @@ -2,8 +2,9 @@ require 'rails_helper' feature 'GFM autocomplete', feature: true, js: true do include WaitForAjax - let(:user) { create(:user) } + let(:user) { create(:user, username: 'someone.special') } let(:project) { create(:project) } + let(:label) { create(:label, project: project, title: 'special+') } let(:issue) { create(:issue, project: project) } before do @@ -23,21 +24,69 @@ feature 'GFM autocomplete', feature: true, js: true do expect(page).to have_selector('.atwho-container') end - it 'opens autocomplete menu when field is prefixed with non-text character' do + it 'doesnt open autocomplete menu character is prefixed with text' do page.within '.timeline-content-form' do - find('#note_note').native.send_keys('') + find('#note_note').native.send_keys('testing') find('#note_note').native.send_keys('@') end - expect(page).to have_selector('.atwho-container') + expect(page).not_to have_selector('.atwho-view') end - it 'doesnt open autocomplete menu character is prefixed with text' do - page.within '.timeline-content-form' do - find('#note_note').native.send_keys('testing') - find('#note_note').native.send_keys('@') + context 'if a selected value has special characters' do + it 'wraps the result in double quotes' do + note = find('#note_note') + page.within '.timeline-content-form' do + note.native.send_keys('') + note.native.send_keys("~#{label.title[0]}") + sleep 1 + note.click + end + + label_item = find('.atwho-view li', text: label.title) + + expect_to_wrap(true, label_item, note, label.title) end - expect(page).not_to have_selector('.atwho-view') + it 'doesn\'t wrap for assignee values' do + note = find('#note_note') + page.within '.timeline-content-form' do + note.native.send_keys('') + note.native.send_keys("@#{user.username[0]}") + sleep 1 + note.click + end + + user_item = find('.atwho-view li', text: user.username) + + expect_to_wrap(false, user_item, note, user.username) + end + + it 'doesn\'t wrap for emoji values' do + note = find('#note_note') + page.within '.timeline-content-form' do + note.native.send_keys('') + note.native.send_keys(":cartwheel") + sleep 1 + note.click + end + + emoji_item = find('.atwho-view li', text: 'cartwheel_tone1') + + expect_to_wrap(false, emoji_item, note, 'cartwheel_tone1') + end + + def expect_to_wrap(should_wrap, item, note, value) + expect(item).to have_content(value) + expect(item).not_to have_content("\"#{value}\"") + + item.click + + if should_wrap + expect(note.value).to include("\"#{value}\"") + else + expect(note.value).not_to include("\"#{value}\"") + end + end end end -- cgit v1.2.1 From 48f24735a8190f72e9bfdeeccf982a38233efcd7 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Mon, 12 Dec 2016 14:32:03 +0000 Subject: Added GFM tests --- spec/features/issues/gfm_autocomplete_spec.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'spec/features/issues/gfm_autocomplete_spec.rb') diff --git a/spec/features/issues/gfm_autocomplete_spec.rb b/spec/features/issues/gfm_autocomplete_spec.rb index c421da97d76..6034ca48db2 100644 --- a/spec/features/issues/gfm_autocomplete_spec.rb +++ b/spec/features/issues/gfm_autocomplete_spec.rb @@ -40,4 +40,12 @@ feature 'GFM autocomplete', feature: true, js: true do expect(page).not_to have_selector('.atwho-view') end + + it 'doesnt open autocomplete after non-word character' do + page.within '.timeline-content-form' do + find('#note_note').native.send_keys("@#{user.username[0..2]}!") + end + + expect(page).not_to have_selector('.atwho-view') + end end -- cgit v1.2.1