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
|
# frozen_string_literal: true
RSpec.shared_examples 'milestone sidebar widget' do
context 'editing milestone' do
let_it_be(:milestone_expired) { create(:milestone, project: project, title: 'Foo - expired', due_date: 5.days.ago) }
let_it_be(:milestone_no_duedate) { create(:milestone, project: project, title: 'Foo - No due date') }
let_it_be(:milestone1) { create(:milestone, project: project, title: 'Milestone-1', due_date: 20.days.from_now) }
let_it_be(:milestone2) { create(:milestone, project: project, title: 'Milestone-2', due_date: 15.days.from_now) }
let_it_be(:milestone3) { create(:milestone, project: project, title: 'Milestone-3', due_date: 10.days.from_now) }
let(:milestone_widget) { find('[data-testid="sidebar-milestones"]') }
before do
within(milestone_widget) do
click_button 'Edit'
end
wait_for_all_requests
end
it 'shows milestones list in the dropdown' do
# 5 milestones + "No milestone" = 6 items
expect(milestone_widget.find('.gl-new-dropdown-contents')).to have_selector('li.gl-new-dropdown-item', count: 6)
end
it 'shows expired milestone at the bottom of the list and milestone due earliest at the top of the list', :aggregate_failures do
within(milestone_widget, '.gl-new-dropdown-contents') do
expect(page.find('li:last-child')).to have_content milestone_expired.title
[milestone3, milestone2, milestone1, milestone_no_duedate].each_with_index do |m, i|
expect(page.all('li.gl-new-dropdown-item')[i + 1]).to have_content m.title
end
end
end
it 'adds a milestone' do
within(milestone_widget) do
click_button milestone1.title
wait_for_requests
page.within('[data-testid="select-milestone"]') do
expect(page).to have_content(milestone1.title)
end
end
end
it 'removes a milestone' do
within(milestone_widget) do
click_button "No milestone"
wait_for_requests
page.within('[data-testid="select-milestone"]') do
expect(page).not_to have_content(milestone1.title)
end
end
end
end
end
|