2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-04-08 20:35:43 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-16 14:09:01 -04:00
|
|
|
RSpec.describe 'Member autocomplete', :js do
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:project) { create(:project, :public) }
|
2016-04-08 20:35:43 -04:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:author) { create(:user) }
|
2017-03-22 14:04:29 -04:00
|
|
|
let(:note) { create(:note, noteable: noteable, project: noteable.project) }
|
2016-04-08 20:35:43 -04:00
|
|
|
|
|
|
|
before do
|
2017-03-22 14:04:29 -04:00
|
|
|
note # actually create the note
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in(user)
|
2016-04-08 20:35:43 -04:00
|
|
|
end
|
|
|
|
|
2017-08-14 06:35:58 -04:00
|
|
|
shared_examples "open suggestions when typing @" do |resource_name|
|
2017-03-22 14:04:29 -04:00
|
|
|
before do
|
|
|
|
page.within('.new-note') do
|
2018-06-21 08:22:40 -04:00
|
|
|
if resource_name == 'commit'
|
2017-08-14 06:35:58 -04:00
|
|
|
find('#note_note').send_keys('@')
|
2018-06-21 08:22:40 -04:00
|
|
|
else
|
|
|
|
find('#note-body').send_keys('@')
|
2017-08-14 06:35:58 -04:00
|
|
|
end
|
2016-04-09 02:34:07 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-03-22 14:04:29 -04:00
|
|
|
it 'suggests noteable author and note author' do
|
2016-04-09 02:34:07 -04:00
|
|
|
page.within('.atwho-view', visible: true) do
|
2017-03-22 14:04:29 -04:00
|
|
|
expect(page).to have_content(author.username)
|
|
|
|
expect(page).to have_content(note.author.username)
|
2016-04-09 02:34:07 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-03-22 14:04:29 -04:00
|
|
|
context 'adding a new note on a Issue' do
|
|
|
|
let(:noteable) { create(:issue, author: author, project: project) }
|
2019-12-17 13:07:48 -05:00
|
|
|
|
2016-04-08 20:35:43 -04:00
|
|
|
before do
|
2020-06-19 08:09:07 -04:00
|
|
|
stub_feature_flags(tribute_autocomplete: false)
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_issue_path(project, noteable)
|
2016-04-08 20:35:43 -04:00
|
|
|
end
|
|
|
|
|
2017-08-14 06:35:58 -04:00
|
|
|
include_examples "open suggestions when typing @", 'issue'
|
2016-04-08 20:35:43 -04:00
|
|
|
end
|
|
|
|
|
2020-06-19 08:09:07 -04:00
|
|
|
describe 'when tribute_autocomplete feature flag is on' do
|
|
|
|
context 'adding a new note on a Issue' do
|
|
|
|
let(:noteable) { create(:issue, author: author, project: project) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
stub_feature_flags(tribute_autocomplete: true)
|
|
|
|
visit project_issue_path(project, noteable)
|
|
|
|
|
|
|
|
page.within('.new-note') do
|
|
|
|
find('#note-body').send_keys('@')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'suggests noteable author and note author' do
|
|
|
|
page.within('.tribute-container', visible: true) do
|
|
|
|
expect(page).to have_content(author.username)
|
|
|
|
expect(page).to have_content(note.author.username)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-03-22 14:04:29 -04:00
|
|
|
context 'adding a new note on a Merge Request' do
|
2017-03-28 17:13:16 -04:00
|
|
|
let(:project) { create(:project, :public, :repository) }
|
2017-03-22 14:04:29 -04:00
|
|
|
let(:noteable) do
|
|
|
|
create(:merge_request, source_project: project,
|
|
|
|
target_project: project, author: author)
|
|
|
|
end
|
2019-12-17 13:07:48 -05:00
|
|
|
|
2016-04-09 02:34:07 -04:00
|
|
|
before do
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_merge_request_path(project, noteable)
|
2016-04-09 02:34:07 -04:00
|
|
|
end
|
|
|
|
|
2017-08-14 06:35:58 -04:00
|
|
|
include_examples "open suggestions when typing @", 'merge_request'
|
2016-04-09 02:34:07 -04:00
|
|
|
end
|
|
|
|
|
2017-03-22 14:04:29 -04:00
|
|
|
context 'adding a new note on a Commit' do
|
2017-03-28 17:13:16 -04:00
|
|
|
let(:project) { create(:project, :public, :repository) }
|
2017-03-22 14:04:29 -04:00
|
|
|
let(:noteable) { project.commit }
|
|
|
|
let(:note) { create(:note_on_commit, project: project, commit_id: project.commit.id) }
|
2016-04-13 14:50:17 -04:00
|
|
|
|
|
|
|
before do
|
2017-07-17 15:26:41 -04:00
|
|
|
allow(User).to receive(:find_by_any_email)
|
2019-12-06 19:07:51 -05:00
|
|
|
.with(noteable.author_email.downcase, confirmed: true).and_return(author)
|
2016-04-13 14:50:17 -04:00
|
|
|
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_commit_path(project, noteable)
|
2016-04-09 02:34:07 -04:00
|
|
|
end
|
2016-04-13 14:50:17 -04:00
|
|
|
|
2017-08-14 06:35:58 -04:00
|
|
|
include_examples "open suggestions when typing @", 'commit'
|
2016-04-13 14:50:17 -04:00
|
|
|
end
|
2016-04-08 20:35:43 -04:00
|
|
|
end
|