participants_autocomplete_spec.rb 1.35 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 47 48 49 50 51 52 53
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) }
  let(:issue) { create(:issue, author: author, project: project) }

  before do
    login_as user
  end

  describe 'On a Issue', js: true do
    before do
      create(:note, note: 'ultralight beam', noteable: issue, author: participant)
      visit_issue(project, issue)
    end

    describe 'adding a new note' do
      describe 'when typing @' do

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

        it 'suggestions are displayed' do
          expect(page).to have_selector('.atwho-view', visible: true)
        end

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

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

  def visit_issue(project, issue)
    visit namespace_project_issue_path(project.namespace, project, issue)
  end
end