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 54 55 56
|
# frozen_string_literal: true
RSpec.shared_examples 'autocompletes items' do
before do
if defined?(project)
create(:issue, project: project, title: 'My Cool Linked Issue')
create(:merge_request, source_project: project, title: 'My Cool Merge Request')
create(:label, project: project, title: 'My Cool Label')
create(:milestone, project: project, title: 'My Cool Milestone')
create(:wiki_page, wiki: project.wiki, title: 'My Cool Wiki Page', content: 'Example')
project.add_maintainer(create(:user, name: 'JohnDoe123'))
project.add_maintainer(create(:user, name: 'ReallyLongUsername1234567890'))
else # group wikis
project = create(:project, group: group)
create(:issue, project: project, title: 'My Cool Linked Issue')
create(:merge_request, source_project: project, title: 'My Cool Merge Request')
create(:group_label, group: group, title: 'My Cool Label')
create(:milestone, group: group, title: 'My Cool Milestone')
create(:wiki_page, wiki: group.wiki, title: 'My Cool Wiki Page', content: 'Example')
project.add_maintainer(create(:user, name: 'JohnDoe123'))
project.add_maintainer(create(:user, name: 'ReallyLongUsername1234567890'))
end
end
it 'works well for issues, labels, MRs, members, etc' do
fill_in :wiki_content, with: "#"
expect(page).to have_text 'My Cool Linked Issue'
fill_in :wiki_content, with: "~"
expect(page).to have_text 'My Cool Label'
fill_in :wiki_content, with: "!"
expect(page).to have_text 'My Cool Merge Request'
fill_in :wiki_content, with: "%"
expect(page).to have_text 'My Cool Milestone'
fill_in :wiki_content, with: "@"
expect(page).to have_text 'JohnDoe123'
fill_in :wiki_content, with: ':smil'
expect(page).to have_text 'smile_cat'
fill_in :wiki_content, with: '[[My'
expect(page).to have_text 'My Cool Wiki Page'
end
it 'autocompletes items with long names' do
fill_in :wiki_content, with: "@ReallyLongUsername1234567"
expect(page).to have_text 'ReallyLongUsername1234567890'
end
end
|