blob: 429efbe6ba03025545368eecaeb292e2dbfc28c4 (
plain)
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
# frozen_string_literal: true
RSpec.shared_examples 'issue boards sidebar' do
include MobileHelpers
before do
first_card.click
end
it 'shows sidebar when clicking issue' do
expect(page).to have_selector('[data-testid="issue-boards-sidebar"]')
end
it 'closes sidebar when clicking issue' do
expect(page).to have_selector('[data-testid="issue-boards-sidebar"]')
first_card.click
expect(page).not_to have_selector('[data-testid="issue-boards-sidebar"]')
end
it 'shows issue details when sidebar is open', :aggregate_failures do
page.within('[data-testid="issue-boards-sidebar"]') do
expect(page).to have_content(issue.title)
expect(page).to have_content(issue.to_reference)
end
end
context 'when clicking close button' do
before do
find('[data-testid="issue-boards-sidebar"] .gl-drawer-close-button').click
end
it 'unhighlights the active issue card' do
expect(first_card[:class]).not_to include('is-active')
expect(first_card[:class]).not_to include('multi-select')
end
it 'closes sidebar when clicking close button' do
expect(page).not_to have_selector('[data-testid="issue-boards-sidebar"]')
end
end
context 'in notifications subscription' do
it 'displays notifications toggle', :aggregate_failures do
page.within('[data-testid="sidebar-notifications"]') do
expect(page).to have_selector('[data-testid="notification-subscribe-toggle"]')
expect(page).to have_content('Notifications')
expect(page).not_to have_content('Notifications have been disabled by the project or group owner')
end
end
it 'shows toggle as on then as off as user toggles to subscribe and unsubscribe', :aggregate_failures do
toggle = find('[data-testid="notification-subscribe-toggle"]')
toggle.click
expect(toggle).to have_css("button.is-checked")
toggle.click
expect(toggle).not_to have_css("button.is-checked")
end
context 'when notifications have been disabled' do
before do
project.update_attribute(:emails_disabled, true)
refresh_and_click_first_card
end
it 'displays a message that notifications have been disabled' do
page.within('[data-testid="sidebar-notifications"]') do
expect(page).not_to have_selector('[data-testid="notification-subscribe-toggle"]')
expect(page).to have_content('Notifications have been disabled by the project or group owner')
end
end
end
end
context 'in time tracking' do
it 'displays time tracking feature with default message' do
page.within('[data-testid="time-tracker"]') do
expect(page).to have_content('Time tracking')
expect(page).to have_content('No estimate or time spent')
end
end
context 'when only spent time is recorded' do
before do
issue.timelogs.create!(time_spent: 3600, user: user)
refresh_and_click_first_card
end
it 'shows the total time spent only' do
page.within('[data-testid="time-tracker"]') do
expect(page).to have_content('Spent: 1h')
expect(page).not_to have_content('Estimated')
end
end
end
context 'when only estimated time is recorded' do
before do
issue.update!(time_estimate: 3600)
refresh_and_click_first_card
end
it 'shows the estimated time only', :aggregate_failures do
page.within('[data-testid="time-tracker"]') do
expect(page).to have_content('Estimated: 1h')
expect(page).not_to have_content('Spent')
end
end
end
context 'when estimated and spent times are available' do
before do
issue.timelogs.create!(time_spent: 1800, user: user)
issue.update!(time_estimate: 3600)
refresh_and_click_first_card
end
it 'shows time tracking progress bar' do
page.within('[data-testid="time-tracker"]') do
expect(page).to have_selector('[data-testid="timeTrackingComparisonPane"]')
end
end
it 'shows both estimated and spent time text', :aggregate_failures do
page.within('[data-testid="time-tracker"]') do
expect(page).to have_content('Spent 30m')
expect(page).to have_content('Est 1h')
end
end
end
context 'when limitedToHours instance option is turned on' do
before do
# 3600+3600*24 = 1d 1h or 25h
issue.timelogs.create!(time_spent: 3600 + 3600 * 24, user: user)
stub_application_setting(time_tracking_limit_to_hours: true)
refresh_and_click_first_card
end
it 'shows the total time spent only' do
page.within('[data-testid="time-tracker"]') do
expect(page).to have_content('Spent: 25h')
end
end
end
end
def refresh_and_click_first_card
page.refresh
wait_for_requests
first_card.click
end
end
|