Commit 9d602609 authored by Jarka Košanová's avatar Jarka Košanová

Add specs for entities autocomplete

parent d179ffc2
...@@ -9,7 +9,6 @@ describe 'GFM autocomplete', :js do ...@@ -9,7 +9,6 @@ describe 'GFM autocomplete', :js do
let(:project) { create(:project) } let(:project) { create(:project) }
let(:label) { create(:label, project: project, title: 'special+') } let(:label) { create(:label, project: project, title: 'special+') }
let(:issue) { create(:issue, project: project) } let(:issue) { create(:issue, project: project) }
let!(:project_snippet) { create(:project_snippet, project: project, title: 'code snippet') }
before do before do
project.add_maintainer(user) project.add_maintainer(user)
...@@ -334,16 +333,57 @@ describe 'GFM autocomplete', :js do ...@@ -334,16 +333,57 @@ describe 'GFM autocomplete', :js do
end end
end end
it 'shows project snippets' do shared_examples 'autocomplete suggestions' do
page.within '.timeline-content-form' do it 'suggests objects correctly' do
find('#note-body').native.send_keys('$') page.within '.timeline-content-form' do
end 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 find('ul li').click
expect(page).to have_content(project_snippet.title) end
expect(find('.new-note #note-body').value).to include(expected_body)
end end
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 private
def expect_to_wrap(should_wrap, item, note, value) def expect_to_wrap(should_wrap, item, note, value)
......
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