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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe "Group Runners", feature_category: :runner_fleet do
include Spec::Support::Helpers::Features::RunnersHelpers
include Spec::Support::Helpers::ModalHelpers
let_it_be(:group_owner) { create(:user) }
let_it_be(:group) { create(:group) }
let_it_be(:project) { create(:project, group: group) }
before do
group.add_owner(group_owner)
sign_in(group_owner)
end
describe "Group runners page", :js do
let!(:group_registration_token) { group.runners_token }
describe "runners registration" do
before do
visit group_runners_path(group)
end
it_behaves_like "shows and resets runner registration token" do
let(:dropdown_text) { 'Register a group runner' }
let(:registration_token) { group_registration_token }
end
end
context "with no runners" do
before do
visit group_runners_path(group)
end
it_behaves_like 'shows no runners registered'
it 'shows tabs with total counts equal to 0' do
expect(page).to have_link('All 0')
expect(page).to have_link('Group 0')
expect(page).to have_link('Project 0')
end
end
context "with an online group runner" do
let!(:group_runner) do
create(:ci_runner, :group, groups: [group], description: 'runner-foo', contacted_at: Time.zone.now)
end
before do
visit group_runners_path(group)
end
it_behaves_like 'shows runner in list' do
let(:runner) { group_runner }
end
it_behaves_like 'pauses, resumes and deletes a runner' do
let(:runner) { group_runner }
end
it 'shows a group badge' do
within_runner_row(group_runner.id) do
expect(page).to have_selector '.badge', text: s_('Runners|Group')
end
end
it 'can edit runner information' do
within_runner_row(group_runner.id) do
expect(find_link('Edit')[:href]).to end_with(edit_group_runner_path(group, group_runner))
end
end
context 'when description does not match' do
before do
input_filtered_search_keys('runner-baz')
end
it_behaves_like 'shows no runners found'
it 'shows no runner' do
expect(page).not_to have_content 'runner-foo'
end
end
end
context "with an online project runner" do
let!(:project_runner) do
create(:ci_runner, :project, projects: [project], description: 'runner-bar', contacted_at: Time.zone.now)
end
before do
visit group_runners_path(group)
end
it_behaves_like 'shows runner in list' do
let(:runner) { project_runner }
end
it_behaves_like 'pauses, resumes and deletes a runner' do
let(:runner) { project_runner }
end
it 'shows a project badge' do
within_runner_row(project_runner.id) do
expect(page).to have_selector '.badge', text: s_('Runners|Project')
end
end
it 'can edit runner information' do
within_runner_row(project_runner.id) do
expect(find_link('Edit')[:href]).to end_with(edit_group_runner_path(group, project_runner))
end
end
end
context "with an online instance runner" do
let!(:instance_runner) do
create(:ci_runner, :instance, description: 'runner-baz', contacted_at: Time.zone.now)
end
before do
visit group_runners_path(group)
end
context "when selecting 'Show only inherited'" do
before do
find("[data-testid='runner-membership-toggle'] button").click
wait_for_requests
end
it_behaves_like 'shows runner in list' do
let(:runner) { instance_runner }
end
it 'shows runner details page' do
click_link("##{instance_runner.id} (#{instance_runner.short_sha})")
expect(current_url).to include(group_runner_path(group, instance_runner))
expect(page).to have_content "#{s_('Runners|Description')} runner-baz"
end
end
end
context 'with a multi-project runner' do
let(:project) { create(:project, group: group) }
let(:project_2) { create(:project, group: group) }
let!(:runner) { create(:ci_runner, :project, projects: [project, project_2], description: 'group-runner') }
it 'user cannot remove the project runner' do
visit group_runners_path(group)
within_runner_row(runner.id) do
expect(page).not_to have_button 'Delete runner'
end
end
end
context "with multiple runners" do
before do
create(:ci_runner, :group, groups: [group], description: 'runner-foo')
create(:ci_runner, :group, groups: [group], description: 'runner-bar')
visit group_runners_path(group)
end
it_behaves_like 'deletes runners in bulk' do
let(:runner_count) { '2' }
end
end
describe 'filtered search' do
before do
visit group_runners_path(group)
end
it 'allows user to search by paused and status', :js do
focus_filtered_search
page.within(search_bar_selector) do
expect(page).to have_link(s_('Runners|Paused'))
expect(page).to have_content('Status')
end
end
end
describe 'filter by tag' do
let!(:runner_1) { create(:ci_runner, :group, groups: [group], description: 'runner-blue', tag_list: ['blue']) }
let!(:runner_2) { create(:ci_runner, :group, groups: [group], description: 'runner-red', tag_list: ['red']) }
before do
visit group_runners_path(group)
end
it_behaves_like 'filters by tag' do
let(:tag) { 'blue' }
let(:found_runner) { runner_1.description }
let(:missing_runner) { runner_2.description }
end
end
end
describe "Group runner show page", :js do
let_it_be(:group_runner) do
create(:ci_runner, :group, groups: [group], description: 'runner-foo')
end
let_it_be(:group_runner_job) { create(:ci_build, runner: group_runner) }
before do
visit group_runner_path(group, group_runner)
end
it 'user views runner details' do
expect(page).to have_content "#{s_('Runners|Description')} runner-foo"
end
it_behaves_like 'shows runner jobs tab' do
let(:job_count) { '1' }
let(:job) { group_runner_job }
end
end
describe "Group runner edit page", :js do
context 'when updating a group runner' do
let_it_be(:group_runner) { create(:ci_runner, :group, groups: [group]) }
before do
visit edit_group_runner_path(group, group_runner)
wait_for_requests
end
it_behaves_like 'submits edit runner form' do
let(:runner) { group_runner }
let(:runner_page_path) { group_runner_path(group, group_runner) }
end
end
context 'when updating a project runner' do
let_it_be(:project_runner) { create(:ci_runner, :project, projects: [project]) }
before do
visit edit_group_runner_path(group, project_runner)
wait_for_requests
end
it_behaves_like 'submits edit runner form' do
let(:runner) { project_runner }
let(:runner_page_path) { group_runner_path(group, project_runner) }
end
end
end
end
|