BigW Consortium Gitlab

shortcuts_issuable_spec.rb 1.29 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
require 'spec_helper'

feature 'Blob shortcuts', :js do
  let(:user) { create(:user) }
  let(:project) { create(:project, :public, :repository) }
  let(:issue) { create(:issue, project: project, author: user) }
  let(:merge_request) { create(:merge_request, source_project: project) }
  let(:note_text) { 'I got this!' }

  before do
    project.add_developer(user)
    sign_in(user)
  end

  describe 'pressing "r"' do
    describe 'On an Issue' do
      before do
        create(:note, noteable: issue, project: project, note: note_text)
        visit project_issue_path(project, issue)
        wait_for_requests
      end

      it 'quotes the selected text' do
        select_element('.note-text')
        find('body').native.send_key('r')

        expect(find('.js-main-target-form .js-vue-comment-form').value).to include(note_text)
      end
    end

    describe 'On a Merge Request' do
      before do
        create(:note, noteable: merge_request, project: project, note: note_text)
        visit project_merge_request_path(project, merge_request)
        wait_for_requests
      end

      it 'quotes the selected text' do
        select_element('.note-text')
        find('body').native.send_key('r')

        expect(find('.js-main-target-form #note_note').value).to include(note_text)
      end
    end
  end
end