Commit 709a5667 authored by Rémy Coutable's avatar Rémy Coutable

Fix spec/features/participants_autocomplete_spec.rb

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent f879e40d
require 'spec_helper' require 'spec_helper'
feature 'Member autocomplete', feature: true do feature 'Member autocomplete', :js do
include WaitForAjax
let(:project) { create(:project, :public) } let(:project) { create(:project, :public) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:participant) { create(:user) }
let(:author) { create(:user) } let(:author) { create(:user) }
let(:note) { create(:note, noteable: noteable, project: noteable.project) }
before do before do
allow_any_instance_of(Commit).to receive(:author).and_return(author) note # actually create the note
login_as user login_as(user)
end
shared_examples "open suggestions" do
it 'displays suggestions' do
expect(page).to have_selector('.atwho-view', visible: true)
end end
it 'suggests author' do shared_examples "open suggestions when typing @" do
page.within('.atwho-view', visible: true) do before do
expect(page).to have_content(author.username) page.within('.new-note') do
find('#note_note').send_keys('@')
end end
end end
it 'suggests participant' do it 'suggests noteable author and note author' do
page.within('.atwho-view', visible: true) do page.within('.atwho-view', visible: true) do
expect(page).to have_content(participant.username) expect(page).to have_content(author.username)
expect(page).to have_content(note.author.username)
end end
end end
end end
context 'adding a new note on a Issue', js: true do context 'adding a new note on a Issue' do
let(:noteable) { create(:issue, author: author, project: project) }
before do before do
issue = create(:issue, author: author, project: project) visit namespace_project_issue_path(project.namespace, project, noteable)
create(:note, note: 'Ultralight Beam', noteable: issue,
project: project, author: participant)
visit_issue(project, issue)
end end
context 'when typing @' do include_examples "open suggestions when typing @"
include_examples "open suggestions"
before do
open_member_suggestions
end
end
end end
context 'adding a new note on a Merge Request ', js: true do context 'adding a new note on a Merge Request' do
before do let(:noteable) do
merge = create(:merge_request, source_project: project, target_project: project, author: author) create(:merge_request, source_project: project,
create(:note, note: 'Ultralight Beam', noteable: merge, target_project: project, author: author)
project: project, author: participant)
visit_merge_request(project, merge)
end end
context 'when typing @' do
include_examples "open suggestions"
before do before do
open_member_suggestions visit namespace_project_merge_request_path(project.namespace, project, noteable)
end
end end
end
context 'adding a new note on a Commit ', js: true do
let(:commit) { project.commit }
before do include_examples "open suggestions when typing @"
allow(commit).to receive(:author).and_return(author)
create(:note_on_commit, author: participant, project: project, commit_id: project.repository.commit.id, note: 'No More Parties in LA')
visit_commit(project, commit)
end end
context 'when typing @' do context 'adding a new note on a Commit' do
include_examples "open suggestions" let(:noteable) { project.commit }
before do let(:note) { create(:note_on_commit, project: project, commit_id: project.commit.id) }
open_member_suggestions
end
end
end
def open_member_suggestions before do
page.within('.new-note') do allow_any_instance_of(Commit).to receive(:author).and_return(author)
find('#note_note').send_keys('@')
end
wait_for_ajax
end
def visit_issue(project, issue)
visit namespace_project_issue_path(project.namespace, project, issue)
end
def visit_merge_request(project, merge) visit namespace_project_commit_path(project.namespace, project, noteable)
visit namespace_project_merge_request_path(project.namespace, project, merge)
end end
def visit_commit(project, commit) include_examples "open suggestions when typing @"
visit namespace_project_commit_path(project.namespace, project, commit)
end end
end end
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