participants_autocomplete_spec.rb 1.95 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
require 'spec_helper'

feature 'Member autocomplete', feature: true do
  let(:project) { create(:project, :public) }
  let(:user) { create(:user) }
  let(:participant) { create(:user) }
  let(:author) { create(:user) }

  before do
    login_as user
  end

13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
  shared_examples "open suggestions" do
    it 'suggestions are displayed' do
      expect(page).to have_selector('.atwho-view', visible: true)
    end

    it 'author is suggested' do
      page.within('.atwho-view', visible: true) do
        expect(page).to have_content(author.username)
      end
    end

    it 'participant is suggested' do
      page.within('.atwho-view', visible: true) do
        expect(page).to have_content(participant.username)
      end
    end
  end

Alfredo Sumaran's avatar
Alfredo Sumaran committed
31
  context 'adding a new note on a Issue', js: true do
32
    before do
33 34
      issue = create(:issue, author: author, project: project)
      create(:note, note: 'Ultralight Beam', noteable: issue, author: participant)
35 36 37
      visit_issue(project, issue)
    end

38 39 40 41
    context 'when typing @' do
      include_examples "open suggestions"
      before do
        open_member_suggestions
42 43 44 45
      end
    end
  end

Alfredo Sumaran's avatar
Alfredo Sumaran committed
46
  context 'adding a new note on a Merge Request ', js: true do
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
    before do
      merge = create(:merge_request, source_project: project, target_project: project, author: author)
      create(:note, note: 'Ultralight Beam', noteable: merge, author: participant)
      visit_merge_request(project, merge)
    end

    context 'when typing @' do
      include_examples "open suggestions"
      before do
        open_member_suggestions
      end
    end
  end

  def open_member_suggestions
    sleep 1
    page.within('.new-note') do
      sleep 1
      find('#note_note').native.send_keys('@')
    end
  end

69 70 71
  def visit_issue(project, issue)
    visit namespace_project_issue_path(project.namespace, project, issue)
  end
72 73 74 75

  def visit_merge_request(project, merge)
    visit namespace_project_merge_request_path(project.namespace, project, merge)
  end
76
end