debian-mirror-gitlab/spec/features/participants_autocomplete_spec.rb

76 lines
2 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2016-06-02 11:05:42 +05:30
require 'spec_helper'
2020-06-23 00:09:42 +05:30
RSpec.describe 'Member autocomplete', :js do
2021-04-29 21:17:54 +05:30
let_it_be(:project) { create(:project, :public, :repository) }
let_it_be(:user) { create(:user) }
let_it_be(:author) { create(:user) }
2021-09-30 23:02:18 +05:30
2017-08-17 22:00:37 +05:30
let(:note) { create(:note, noteable: noteable, project: noteable.project) }
2016-06-02 11:05:42 +05:30
before do
2017-08-17 22:00:37 +05:30
note # actually create the note
2017-09-10 17:25:29 +05:30
sign_in(user)
2016-06-02 11:05:42 +05:30
end
2018-03-17 18:26:18 +05:30
shared_examples "open suggestions when typing @" do |resource_name|
2017-08-17 22:00:37 +05:30
before do
2021-04-29 21:17:54 +05:30
if resource_name == 'commit'
fill_in 'note[note]', with: '@'
else
fill_in 'Comment', with: '@'
2016-06-02 11:05:42 +05:30
end
end
2017-08-17 22:00:37 +05:30
it 'suggests noteable author and note author' do
2021-04-29 21:17:54 +05:30
expect(find_autocomplete_menu).to have_text(author.username)
expect(find_autocomplete_menu).to have_text(note.author.username)
2016-06-02 11:05:42 +05:30
end
end
2017-08-17 22:00:37 +05:30
context 'adding a new note on a Issue' do
let(:noteable) { create(:issue, author: author, project: project) }
2020-01-01 13:55:28 +05:30
2016-06-02 11:05:42 +05:30
before do
2017-09-10 17:25:29 +05:30
visit project_issue_path(project, noteable)
2016-06-02 11:05:42 +05:30
end
2018-03-17 18:26:18 +05:30
include_examples "open suggestions when typing @", 'issue'
2016-06-02 11:05:42 +05:30
end
2017-08-17 22:00:37 +05:30
context 'adding a new note on a Merge Request' do
let(:noteable) do
create(:merge_request, source_project: project,
target_project: project, author: author)
end
2020-01-01 13:55:28 +05:30
2016-06-02 11:05:42 +05:30
before do
2017-09-10 17:25:29 +05:30
visit project_merge_request_path(project, noteable)
2016-06-02 11:05:42 +05:30
end
2018-03-17 18:26:18 +05:30
include_examples "open suggestions when typing @", 'merge_request'
2016-06-02 11:05:42 +05:30
end
2017-08-17 22:00:37 +05:30
context 'adding a new note on a Commit' do
let(:noteable) { project.commit }
let(:note) { create(:note_on_commit, project: project, commit_id: project.commit.id) }
2016-06-02 11:05:42 +05:30
before do
2021-04-17 20:07:23 +05:30
allow(User).to receive(:find_by_any_email).and_call_original
2017-09-10 17:25:29 +05:30
allow(User).to receive(:find_by_any_email)
2020-01-01 13:55:28 +05:30
.with(noteable.author_email.downcase, confirmed: true).and_return(author)
2016-06-02 11:05:42 +05:30
2017-09-10 17:25:29 +05:30
visit project_commit_path(project, noteable)
2016-06-02 11:05:42 +05:30
end
2018-03-17 18:26:18 +05:30
include_examples "open suggestions when typing @", 'commit'
2016-06-02 11:05:42 +05:30
end
2021-04-29 21:17:54 +05:30
private
def find_autocomplete_menu
find('.atwho-view ul', visible: true)
end
2016-06-02 11:05:42 +05:30
end