summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2018-11-22 15:57:15 +0000
committerKamil Trzciński <ayufan@ayufan.eu>2018-11-22 15:57:15 +0000
commit7286c012d5c4d8fb8178ca31ae0768e92e51ab75 (patch)
tree1f8ae74ed541c1f0073f95456680ba3fd7256324
parentac973f1895ca57122ba7793e0b15237cf678d3de (diff)
parent9d60260926c879db0770346f067b763084c703ac (diff)
downloadgitlab-ce-7286c012d5c4d8fb8178ca31ae0768e92e51ab75.tar.gz
Merge branch '48534-autocomplete-spec' into 'master'
Add specs for entities autocomplete Closes #48534 See merge request gitlab-org/gitlab-ce!23250
-rw-r--r--spec/features/issues/gfm_autocomplete_spec.rb54
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)