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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'GFM autocomplete', :js, feature_category: :team_planning do
include Features::AutocompleteHelpers
let_it_be(:user) { create(:user, name: '💃speciąl someone💃', username: 'someone.special') }
let_it_be(:group) { create(:group, name: 'Ancestor') }
let_it_be(:project) { create(:project, :repository, group: group) }
let_it_be(:issue) { create(:issue, project: project, assignees: [user], title: 'My special issue') }
let_it_be(:label) { create(:label, project: project, title: 'special+') }
let_it_be(:milestone) { create(:milestone, resource_parent: project, title: "project milestone") }
let_it_be(:merge_request) { create(:merge_request, source_project: project) }
shared_examples 'displays autocomplete menu for all entities' do
it 'autocompletes all available entities' do
fill_in 'Description', with: User.reference_prefix
wait_for_requests
expect(find_autocomplete_menu).to be_visible
expect_autocomplete_entry(user.name)
fill_in 'Description', with: Label.reference_prefix
wait_for_requests
expect(find_autocomplete_menu).to be_visible
expect_autocomplete_entry(label.title)
fill_in 'Description', with: Milestone.reference_prefix
wait_for_requests
expect(find_autocomplete_menu).to be_visible
expect_autocomplete_entry(milestone.title)
fill_in 'Description', with: Issue.reference_prefix
wait_for_requests
expect(find_autocomplete_menu).to be_visible
expect_autocomplete_entry(issue.title)
fill_in 'Description', with: MergeRequest.reference_prefix
wait_for_requests
expect(find_autocomplete_menu).to be_visible
expect_autocomplete_entry(merge_request.title)
end
end
before_all do
group.add_maintainer(user)
end
describe 'new milestone page' do
before do
sign_in(user)
visit new_project_milestone_path(project)
wait_for_requests
end
it_behaves_like 'displays autocomplete menu for all entities'
end
describe 'update milestone page' do
before do
sign_in(user)
visit edit_project_milestone_path(project, milestone)
wait_for_requests
end
it_behaves_like 'displays autocomplete menu for all entities'
end
private
def expect_autocomplete_entry(entry)
page.within('.atwho-container') do
expect(page).to have_content(entry)
end
end
end
|