diff options
author | Jarka Košanová <jarka@gitlab.com> | 2018-11-19 15:46:34 +0100 |
---|---|---|
committer | Jarka Košanová <jarka@gitlab.com> | 2018-11-22 15:59:17 +0100 |
commit | 9d60260926c879db0770346f067b763084c703ac (patch) | |
tree | 4b0cbdabac08e6b436004f242ecffa0b8899f61d /spec/features/issues | |
parent | d179ffc25ceb7ffd9bf241494c03a8d90a0aab58 (diff) | |
download | gitlab-ce-9d60260926c879db0770346f067b763084c703ac.tar.gz |
Add specs for entities autocomplete
Diffstat (limited to 'spec/features/issues')
-rw-r--r-- | spec/features/issues/gfm_autocomplete_spec.rb | 54 |
1 files changed, 47 insertions, 7 deletions
diff --git a/spec/features/issues/gfm_autocomplete_spec.rb b/spec/features/issues/gfm_autocomplete_spec.rb index 7c591dacce5..d7531d5fcd9 100644 --- a/spec/features/issues/gfm_autocomplete_spec.rb +++ b/spec/features/issues/gfm_autocomplete_spec.rb @@ -9,7 +9,6 @@ describe 'GFM autocomplete', :js do let(:project) { create(:project) } let(:label) { create(:label, project: project, title: 'special+') } let(:issue) { create(:issue, project: project) } - let!(:project_snippet) { create(:project_snippet, project: project, title: 'code snippet') } before do project.add_maintainer(user) @@ -334,16 +333,57 @@ describe 'GFM autocomplete', :js do end end - it 'shows project snippets' do - page.within '.timeline-content-form' do - find('#note-body').native.send_keys('$') - end + shared_examples 'autocomplete suggestions' do + it 'suggests objects correctly' do + page.within '.timeline-content-form' do + find('#note-body').native.send_keys(object.class.reference_prefix) + end + + page.within '.atwho-container' do + expect(page).to have_content(object.title) - page.within '.atwho-container' do - expect(page).to have_content(project_snippet.title) + find('ul li').click + end + + expect(find('.new-note #note-body').value).to include(expected_body) end end + context 'issues' do + let(:object) { issue } + let(:expected_body) { object.to_reference } + + it_behaves_like 'autocomplete suggestions' + end + + context 'merge requests' do + let(:object) { create(:merge_request, source_project: project) } + let(:expected_body) { object.to_reference } + + it_behaves_like 'autocomplete suggestions' + end + + context 'project snippets' do + let!(:object) { create(:project_snippet, project: project, title: 'code snippet') } + let(:expected_body) { object.to_reference } + + it_behaves_like 'autocomplete suggestions' + end + + context 'label' do + let!(:object) { label } + let(:expected_body) { object.title } + + it_behaves_like 'autocomplete suggestions' + end + + context 'milestone' do + let!(:object) { create(:milestone, project: project) } + let(:expected_body) { object.to_reference } + + it_behaves_like 'autocomplete suggestions' + end + private def expect_to_wrap(should_wrap, item, note, value) |