require 'spec_helper' describe 'Create notes on issues', :js do let(:user) { create(:user) } shared_examples 'notes with reference' do let(:issue) { create(:issue, project: project) } let(:note_text) { "Check #{mention.to_reference}" } before do project.team << [user, :developer] sign_in(user) visit project_issue_path(project, issue) fill_in 'note[note]', with: note_text click_button 'Comment' wait_for_requests end it 'creates a note with reference and cross references the issue' do page.within('div#notes li.note div.note-text') do expect(page).to have_content(note_text) expect(page.find('a')).to have_content(mention.to_reference) end find('div#notes li.note div.note-text a').click page.within('div#notes li.note .system-note-message') do expect(page).to have_content('mentioned in issue') expect(page.find('a')).to have_content(issue.to_reference) end end end context 'mentioning issue on a private project' do it_behaves_like 'notes with reference' do let(:project) { create(:project, :private) } let(:mention) { create(:issue, project: project) } end end context 'mentioning issue on an internal project' do it_behaves_like 'notes with reference' do let(:project) { create(:project, :internal) } let(:mention) { create(:issue, project: project) } end end context 'mentioning issue on a public project' do it_behaves_like 'notes with reference' do let(:project) { create(:project, :public) } let(:mention) { create(:issue, project: project) } end end context 'mentioning merge request on a private project' do it_behaves_like 'notes with reference' do let(:project) { create(:project, :private, :repository) } let(:mention) { create(:merge_request, source_project: project) } end end context 'mentioning merge request on an internal project' do it_behaves_like 'notes with reference' do let(:project) { create(:project, :internal, :repository) } let(:mention) { create(:merge_request, source_project: project) } end end context 'mentioning merge request on a public project' do it_behaves_like 'notes with reference' do let(:project) { create(:project, :public, :repository) } let(:mention) { create(:merge_request, source_project: project) } end end describe 'copy GFM note and paste into new comment textarea' do let(:project) { create(:project, :public) } let(:note_text) { 'I **got** this!' } let(:issue) { create(:issue, project: project) } before do project.team << [user, :developer] sign_in(user) create(:note, noteable: issue, project: project, note: note_text) visit project_issue_path(project, issue) wait_for_requests end it 'can submit comment' do select_element('.note-text') # Copy, [:control, 'c'] and [:command, 'c'] don't work find('body').native.send_keys [:control, :insert] find('.js-main-target-form .js-vue-comment-form').click # Paste, [:control, 'v'] and [:command, 'v'] don't work find('body').native.send_keys [:shift, :insert] expect(find('.js-main-target-form .js-vue-comment-form').value).to include(note_text) expect(page).to have_css('.js-comment-button') expect(page).not_to have_css('.js-comment-button[disabled]') end end end