Commit 7286c012 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch '48534-autocomplete-spec' into 'master'

Add specs for entities autocomplete

Closes #48534

See merge request gitlab-org/gitlab-ce!23250
parents ac973f18 9d602609
...@@ -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,14 +333,55 @@ describe 'GFM autocomplete', :js do ...@@ -334,14 +333,55 @@ describe 'GFM autocomplete', :js do
end end
end end
it 'shows project snippets' do shared_examples 'autocomplete suggestions' do
it 'suggests objects correctly' do
page.within '.timeline-content-form' do page.within '.timeline-content-form' do
find('#note-body').native.send_keys('$') find('#note-body').native.send_keys(object.class.reference_prefix)
end end
page.within '.atwho-container' do page.within '.atwho-container' do
expect(page).to have_content(project_snippet.title) expect(page).to have_content(object.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 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 end
private private
......
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