boards_spec.rb 19.3 KB
Newer Older
P
Phil Hughes 已提交
1 2
require 'rails_helper'

3
describe 'Issue Boards', :js do
P
Phil Hughes 已提交
4
  include DragTo
M
Mike Greiling 已提交
5
  include MobileHelpers
6

7
  let(:group) { create(:group, :nested) }
8
  let(:project) { create(:project, :public, namespace: group) }
9
  let(:board)   { create(:board, project: project) }
10 11
  let(:user)    { create(:user) }
  let!(:user2)  { create(:user) }
P
Phil Hughes 已提交
12 13

  before do
14 15
    project.add_master(user)
    project.add_master(user2)
16

M
Mike Greiling 已提交
17
    set_cookie('sidebar_collapsed', 'true')
P
Phil Hughes 已提交
18

19
    sign_in(user)
P
Phil Hughes 已提交
20 21
  end

P
Phil Hughes 已提交
22 23
  context 'no lists' do
    before do
24
      visit project_board_path(project, board)
25
      wait_for_requests
P
Phil Hughes 已提交
26
      expect(page).to have_selector('.board', count: 3)
P
Phil Hughes 已提交
27
    end
P
Phil Hughes 已提交
28

P
Phil Hughes 已提交
29 30
    it 'shows blank state' do
      expect(page).to have_content('Welcome to your Issue Board!')
P
Phil Hughes 已提交
31 32
    end

P
Phil Hughes 已提交
33
    it 'shows tooltip on add issues button' do
34
      button = page.find('.filter-dropdown-container button', text: 'Add issues')
P
Phil Hughes 已提交
35

P
Phil Hughes 已提交
36
      expect(button[:"data-original-title"]).to eq("Please add a list to your board first")
P
Phil Hughes 已提交
37 38
    end

39
    it 'hides the blank state when clicking nevermind button' do
P
Phil Hughes 已提交
40
      page.within(find('.board-blank-state')) do
P
Phil Hughes 已提交
41
        click_button("Nevermind, I'll use my own")
P
Phil Hughes 已提交
42
      end
P
Phil Hughes 已提交
43
      expect(page).to have_selector('.board', count: 2)
P
Phil Hughes 已提交
44 45
    end

P
Phil Hughes 已提交
46
    it 'creates default lists' do
P
Phil Hughes 已提交
47
      lists = ['Backlog', 'To Do', 'Doing', 'Closed']
P
Phil Hughes 已提交
48

P
Phil Hughes 已提交
49
      page.within(find('.board-blank-state')) do
P
Phil Hughes 已提交
50 51
        click_button('Add default lists')
      end
52
      wait_for_requests
P
Phil Hughes 已提交
53

P
Phil Hughes 已提交
54
      expect(page).to have_selector('.board', count: 4)
P
Phil Hughes 已提交
55 56 57 58 59

      page.all('.board').each_with_index do |list, i|
        expect(list.find('.board-title')).to have_content(lists[i])
      end
    end
P
Phil Hughes 已提交
60 61
  end

P
Phil Hughes 已提交
62
  context 'with lists' do
63
    let(:milestone) { create(:milestone, project: project) }
P
Phil Hughes 已提交
64

65
    let(:planning)    { create(:label, project: project, name: 'Planning', description: 'Test') }
P
Phil Hughes 已提交
66 67
    let(:development) { create(:label, project: project, name: 'Development') }
    let(:testing)     { create(:label, project: project, name: 'Testing') }
P
Phil Hughes 已提交
68
    let(:bug)         { create(:label, project: project, name: 'Bug') }
69
    let!(:backlog)    { create(:label, project: project, name: 'Backlog') }
70
    let!(:closed)       { create(:label, project: project, name: 'Closed') }
71
    let!(:accepting)  { create(:label, project: project, name: 'Accepting Merge Requests') }
S
Simon Knox 已提交
72
    let!(:a_plus) { create(:label, project: project, name: 'A+') }
P
Phil Hughes 已提交
73

74 75
    let!(:list1) { create(:list, board: board, label: planning, position: 0) }
    let!(:list2) { create(:list, board: board, label: development, position: 1) }
P
Phil Hughes 已提交
76

P
Phil Hughes 已提交
77
    let!(:confidential_issue) { create(:labeled_issue, :confidential, project: project, author: user, labels: [planning], relative_position: 9) }
H
Hiroyuki Sato 已提交
78 79 80 81 82 83 84 85 86
    let!(:issue1) { create(:labeled_issue, project: project, title: 'aaa', description: '111', assignees: [user], labels: [planning], relative_position: 8) }
    let!(:issue2) { create(:labeled_issue, project: project, title: 'bbb', description: '222', author: user2, labels: [planning], relative_position: 7) }
    let!(:issue3) { create(:labeled_issue, project: project, title: 'ccc', description: '333', labels: [planning], relative_position: 6) }
    let!(:issue4) { create(:labeled_issue, project: project, title: 'ddd', description: '444', labels: [planning], relative_position: 5) }
    let!(:issue5) { create(:labeled_issue, project: project, title: 'eee', description: '555', labels: [planning], milestone: milestone, relative_position: 4) }
    let!(:issue6) { create(:labeled_issue, project: project, title: 'fff', description: '666', labels: [planning, development], relative_position: 3) }
    let!(:issue7) { create(:labeled_issue, project: project, title: 'ggg', description: '777', labels: [development], relative_position: 2) }
    let!(:issue8) { create(:closed_issue, project: project, title: 'hhh', description: '888') }
    let!(:issue9) { create(:labeled_issue, project: project, title: 'iii', description: '999', labels: [planning, testing, bug, accepting], relative_position: 1) }
S
Simon Knox 已提交
87
    let!(:issue10) { create(:labeled_issue, project: project, title: 'issue +', description: 'A+ great issue', labels: [a_plus]) }
P
Phil Hughes 已提交
88 89

    before do
90
      visit project_board_path(project, board)
P
Phil Hughes 已提交
91

92
      wait_for_requests
P
Phil Hughes 已提交
93

P
Phil Hughes 已提交
94
      expect(page).to have_selector('.board', count: 4)
95 96 97
      expect(find('.board:nth-child(2)')).to have_selector('.board-card')
      expect(find('.board:nth-child(3)')).to have_selector('.board-card')
      expect(find('.board:nth-child(4)')).to have_selector('.board-card')
P
Phil Hughes 已提交
98 99
    end

100
    it 'shows description tooltip on list title' do
P
Phil Hughes 已提交
101
      page.within('.board:nth-child(2)') do
102 103 104 105
        expect(find('.board-title span.has-tooltip')[:title]).to eq('Test')
      end
    end

P
Phil Hughes 已提交
106
    it 'shows issues in lists' do
P
Phil Hughes 已提交
107 108
      wait_for_board_cards(2, 8)
      wait_for_board_cards(3, 2)
P
Phil Hughes 已提交
109
    end
P
Phil Hughes 已提交
110

P
Phil Hughes 已提交
111
    it 'shows confidential issues with icon' do
P
Phil Hughes 已提交
112
      page.within(find('.board:nth-child(2)')) do
P
Phil Hughes 已提交
113 114 115 116
        expect(page).to have_selector('.confidential-icon', count: 1)
      end
    end

117
    it 'search closed list' do
118 119
      find('.filtered-search').set(issue8.title)
      find('.filtered-search').native.send_keys(:enter)
120

121
      wait_for_requests
122

123 124 125
      expect(find('.board:nth-child(2)')).to have_selector('.board-card', count: 0)
      expect(find('.board:nth-child(3)')).to have_selector('.board-card', count: 0)
      expect(find('.board:nth-child(4)')).to have_selector('.board-card', count: 1)
126 127 128
    end

    it 'search list' do
129 130
      find('.filtered-search').set(issue5.title)
      find('.filtered-search').native.send_keys(:enter)
131

132
      wait_for_requests
133

134 135 136
      expect(find('.board:nth-child(2)')).to have_selector('.board-card', count: 1)
      expect(find('.board:nth-child(3)')).to have_selector('.board-card', count: 0)
      expect(find('.board:nth-child(4)')).to have_selector('.board-card', count: 0)
137 138
    end

P
Phil Hughes 已提交
139
    it 'allows user to delete board' do
P
Phil Hughes 已提交
140
      page.within(find('.board:nth-child(2)')) do
141
        accept_confirm { find('.board-delete').click }
P
Phil Hughes 已提交
142
      end
P
Phil Hughes 已提交
143

144
      wait_for_requests
P
Phil Hughes 已提交
145

P
Phil Hughes 已提交
146
      expect(page).to have_selector('.board', count: 3)
P
Phil Hughes 已提交
147 148
    end

149
    it 'removes checkmark in new list dropdown after deleting' do
150
      click_button 'Add list'
151
      wait_for_requests
152

P
Phil Hughes 已提交
153 154
      find('.dropdown-menu-close').click

P
Phil Hughes 已提交
155
      page.within(find('.board:nth-child(2)')) do
156
        accept_confirm { find('.board-delete').click }
157
      end
158

159
      wait_for_requests
160

P
Phil Hughes 已提交
161
      expect(page).to have_selector('.board', count: 3)
162 163
    end

164 165
    it 'infinite scrolls list' do
      50.times do
166
        create(:labeled_issue, project: project, labels: [planning])
167 168
      end

169
      visit project_board_path(project, board)
170
      wait_for_requests
171

P
Phil Hughes 已提交
172
      page.within(find('.board:nth-child(2)')) do
173
        expect(page.find('.board-header')).to have_content('58')
174
        expect(page).to have_selector('.board-card', count: 20)
175
        expect(page).to have_content('Showing 20 of 58 issues')
176

177
        find('.board .board-list')
P
Phil Hughes 已提交
178
        evaluate_script("document.querySelectorAll('.board .board-list')[1].scrollTop = document.querySelectorAll('.board .board-list')[1].scrollHeight")
179
        wait_for_requests
180

181
        expect(page).to have_selector('.board-card', count: 40)
182
        expect(page).to have_content('Showing 40 of 58 issues')
P
Phil Hughes 已提交
183

184
        find('.board .board-list')
P
Phil Hughes 已提交
185
        evaluate_script("document.querySelectorAll('.board .board-list')[1].scrollTop = document.querySelectorAll('.board .board-list')[1].scrollHeight")
186
        wait_for_requests
P
Phil Hughes 已提交
187

188
        expect(page).to have_selector('.board-card', count: 58)
P
Phil Hughes 已提交
189
        expect(page).to have_content('Showing all issues')
190 191 192
      end
    end

193 194
    context 'closed' do
      it 'shows list of closed issues' do
P
Phil Hughes 已提交
195
        wait_for_board_cards(4, 1)
196
        wait_for_requests
P
Phil Hughes 已提交
197 198
      end

199
      it 'moves issue to closed' do
P
Phil Hughes 已提交
200
        drag(list_from_index: 1, list_to_index: 3)
P
Phil Hughes 已提交
201

P
Phil Hughes 已提交
202
        wait_for_board_cards(2, 7)
203
        wait_for_board_cards(3, 2)
P
Phil Hughes 已提交
204
        wait_for_board_cards(4, 2)
205

P
Phil Hughes 已提交
206
        expect(find('.board:nth-child(2)')).not_to have_content(issue9.title)
207
        expect(find('.board:nth-child(4)')).to have_selector('.board-card', count: 2)
P
Phil Hughes 已提交
208 209
        expect(find('.board:nth-child(4)')).to have_content(issue9.title)
        expect(find('.board:nth-child(4)')).not_to have_content(planning.title)
P
Phil Hughes 已提交
210 211
      end

212
      it 'removes all of the same issue to closed' do
P
Phil Hughes 已提交
213
        drag(list_from_index: 1, list_to_index: 3)
P
Phil Hughes 已提交
214

P
Phil Hughes 已提交
215
        wait_for_board_cards(2, 7)
216
        wait_for_board_cards(3, 2)
P
Phil Hughes 已提交
217
        wait_for_board_cards(4, 2)
218

P
Phil Hughes 已提交
219 220 221
        expect(find('.board:nth-child(2)')).not_to have_content(issue9.title)
        expect(find('.board:nth-child(4)')).to have_content(issue9.title)
        expect(find('.board:nth-child(4)')).not_to have_content(planning.title)
P
Phil Hughes 已提交
222 223 224 225
      end
    end

    context 'lists' do
P
Phil Hughes 已提交
226
      it 'changes position of list' do
P
Phil Hughes 已提交
227
        drag(list_from_index: 2, list_to_index: 1, selector: '.board-header')
P
Phil Hughes 已提交
228

P
Phil Hughes 已提交
229 230 231
        wait_for_board_cards(2, 2)
        wait_for_board_cards(3, 8)
        wait_for_board_cards(4, 1)
232

P
Phil Hughes 已提交
233 234
        expect(find('.board:nth-child(2)')).to have_content(development.title)
        expect(find('.board:nth-child(2)')).to have_content(planning.title)
P
Phil Hughes 已提交
235 236
      end

P
Phil Hughes 已提交
237
      it 'issue moves between lists' do
P
Phil Hughes 已提交
238
        drag(list_from_index: 1, from_index: 1, list_to_index: 2)
P
Phil Hughes 已提交
239

P
Phil Hughes 已提交
240 241 242
        wait_for_board_cards(2, 7)
        wait_for_board_cards(3, 2)
        wait_for_board_cards(4, 1)
243

P
Phil Hughes 已提交
244
        expect(find('.board:nth-child(3)')).to have_content(issue6.title)
245
        expect(find('.board:nth-child(3)').all('.board-card').last).to have_content(development.title)
P
Phil Hughes 已提交
246 247
      end

P
Phil Hughes 已提交
248
      it 'issue moves between lists' do
P
Phil Hughes 已提交
249
        drag(list_from_index: 2, list_to_index: 1)
P
Phil Hughes 已提交
250

P
Phil Hughes 已提交
251
        wait_for_board_cards(2, 9)
252
        wait_for_board_cards(3, 1)
P
Phil Hughes 已提交
253
        wait_for_board_cards(4, 1)
254

P
Phil Hughes 已提交
255
        expect(find('.board:nth-child(2)')).to have_content(issue7.title)
256
        expect(find('.board:nth-child(2)').all('.board-card').first).to have_content(planning.title)
P
Phil Hughes 已提交
257 258
      end

259
      it 'issue moves from closed' do
P
Phil Hughes 已提交
260
        drag(list_from_index: 2, list_to_index: 3)
P
Phil Hughes 已提交
261

P
Phil Hughes 已提交
262
        wait_for_board_cards(2, 8)
P
Phil Hughes 已提交
263 264
        wait_for_board_cards(3, 1)
        wait_for_board_cards(4, 2)
265

P
Phil Hughes 已提交
266
        expect(find('.board:nth-child(4)')).to have_content(issue8.title)
P
Phil Hughes 已提交
267 268 269 270
      end

      context 'issue card' do
        it 'shows assignee' do
P
Phil Hughes 已提交
271
          page.within(find('.board:nth-child(2)')) do
P
Phil Hughes 已提交
272
            expect(page).to have_selector('.avatar', count: 1)
P
Phil Hughes 已提交
273 274 275 276 277 278
          end
        end
      end

      context 'new list' do
        it 'shows all labels in new list dropdown' do
279
          click_button 'Add list'
280
          wait_for_requests
P
Phil Hughes 已提交
281 282 283 284 285 286 287 288 289

          page.within('.dropdown-menu-issues-board-new') do
            expect(page).to have_content(planning.title)
            expect(page).to have_content(development.title)
            expect(page).to have_content(testing.title)
          end
        end

        it 'creates new list for label' do
290
          click_button 'Add list'
291
          wait_for_requests
P
Phil Hughes 已提交
292 293 294 295 296

          page.within('.dropdown-menu-issues-board-new') do
            click_link testing.title
          end

297
          wait_for_requests
298

P
Phil Hughes 已提交
299
          expect(page).to have_selector('.board', count: 5)
P
Phil Hughes 已提交
300 301
        end

302
        it 'creates new list for Backlog label' do
303
          click_button 'Add list'
304
          wait_for_requests
305 306 307 308 309

          page.within('.dropdown-menu-issues-board-new') do
            click_link backlog.title
          end

310
          wait_for_requests
311

P
Phil Hughes 已提交
312
          expect(page).to have_selector('.board', count: 5)
313 314
        end

315
        it 'creates new list for Closed label' do
316
          click_button 'Add list'
317
          wait_for_requests
318 319

          page.within('.dropdown-menu-issues-board-new') do
320
            click_link closed.title
321 322
          end

323
          wait_for_requests
324

P
Phil Hughes 已提交
325
          expect(page).to have_selector('.board', count: 5)
326 327
        end

328
        it 'keeps dropdown open after adding new list' do
329
          click_button 'Add list'
330
          wait_for_requests
331 332

          page.within('.dropdown-menu-issues-board-new') do
333
            click_link closed.title
334 335
          end

336
          wait_for_requests
337

338
          expect(page).to have_css('#js-add-list.open')
339 340
        end

P
Phil Hughes 已提交
341
        it 'creates new list from a new label' do
342
          click_button 'Add list'
P
Phil Hughes 已提交
343

344
          wait_for_requests
P
Phil Hughes 已提交
345

346
          click_link 'Create project label'
P
Phil Hughes 已提交
347 348 349 350 351 352 353

          fill_in('new_label_name', with: 'Testing New Label')

          first('.suggest-colors a').click

          click_button 'Create'

354 355
          wait_for_requests
          wait_for_requests
P
Phil Hughes 已提交
356

P
Phil Hughes 已提交
357
          expect(page).to have_selector('.board', count: 5)
P
Phil Hughes 已提交
358
        end
P
Phil Hughes 已提交
359 360 361 362
      end
    end

    context 'filtering' do
P
Phil Hughes 已提交
363
      it 'filters by author' do
P
Phil Hughes 已提交
364 365 366
        set_filter("author", user2.username)
        click_filter_link(user2.username)
        submit_filter
P
Phil Hughes 已提交
367

368
        wait_for_requests
P
Phil Hughes 已提交
369 370
        wait_for_board_cards(2, 1)
        wait_for_empty_boards((3..4))
P
Phil Hughes 已提交
371 372 373
      end

      it 'filters by assignee' do
P
Phil Hughes 已提交
374 375 376
        set_filter("assignee", user.username)
        click_filter_link(user.username)
        submit_filter
P
Phil Hughes 已提交
377

378
        wait_for_requests
P
Phil Hughes 已提交
379

P
Phil Hughes 已提交
380 381
        wait_for_board_cards(2, 1)
        wait_for_empty_boards((3..4))
P
Phil Hughes 已提交
382 383 384
      end

      it 'filters by milestone' do
385
        set_filter("milestone", "\"#{milestone.title}")
P
Phil Hughes 已提交
386 387
        click_filter_link(milestone.title)
        submit_filter
P
Phil Hughes 已提交
388

389
        wait_for_requests
P
Phil Hughes 已提交
390
        wait_for_board_cards(2, 1)
391
        wait_for_board_cards(3, 0)
P
Phil Hughes 已提交
392
        wait_for_board_cards(4, 0)
P
Phil Hughes 已提交
393 394 395
      end

      it 'filters by label' do
P
Phil Hughes 已提交
396 397 398
        set_filter("label", testing.title)
        click_filter_link(testing.title)
        submit_filter
P
Phil Hughes 已提交
399

400
        wait_for_requests
P
Phil Hughes 已提交
401 402
        wait_for_board_cards(2, 1)
        wait_for_empty_boards((3..4))
P
Phil Hughes 已提交
403 404
      end

S
Simon Knox 已提交
405 406 407 408 409 410 411 412 413
      it 'filters by label with encoded character' do
        set_filter("label", a_plus.title)
        click_filter_link(a_plus.title)
        submit_filter

        wait_for_board_cards(1, 1)
        wait_for_empty_boards((2..4))
      end

414
      it 'filters by label with space after reload' do
415
        set_filter("label", "\"#{accepting.title}")
P
Phil Hughes 已提交
416 417
        click_filter_link(accepting.title)
        submit_filter
418 419 420

        # Test after reload
        page.evaluate_script 'window.location.reload()'
P
Phil Hughes 已提交
421 422
        wait_for_board_cards(2, 1)
        wait_for_empty_boards((3..4))
423

424
        wait_for_requests
425

P
Phil Hughes 已提交
426
        page.within(find('.board:nth-child(2)')) do
427
          expect(page.find('.board-header')).to have_content('1')
428
          expect(page).to have_selector('.board-card', count: 1)
429 430
        end

P
Phil Hughes 已提交
431
        page.within(find('.board:nth-child(3)')) do
432
          expect(page.find('.board-header')).to have_content('0')
433
          expect(page).to have_selector('.board-card', count: 0)
434 435 436
        end
      end

437
      it 'removes filtered labels' do
P
Phil Hughes 已提交
438 439 440
        set_filter("label", testing.title)
        click_filter_link(testing.title)
        submit_filter
441

P
Phil Hughes 已提交
442
        wait_for_board_cards(2, 1)
443

P
Phil Hughes 已提交
444 445
        find('.clear-search').click
        submit_filter
446

P
Phil Hughes 已提交
447
        wait_for_board_cards(2, 8)
448 449
      end

450 451
      it 'infinite scrolls list with label filter' do
        50.times do
452
          create(:labeled_issue, project: project, labels: [planning, testing])
453 454
        end

P
Phil Hughes 已提交
455 456 457
        set_filter("label", testing.title)
        click_filter_link(testing.title)
        submit_filter
458

459
        wait_for_requests
P
Phil Hughes 已提交
460

P
Phil Hughes 已提交
461
        page.within(find('.board:nth-child(2)')) do
462
          expect(page.find('.board-header')).to have_content('51')
463
          expect(page).to have_selector('.board-card', count: 20)
P
Phil Hughes 已提交
464
          expect(page).to have_content('Showing 20 of 51 issues')
465

466
          find('.board .board-list')
P
Phil Hughes 已提交
467
          evaluate_script("document.querySelectorAll('.board .board-list')[1].scrollTop = document.querySelectorAll('.board .board-list')[1].scrollHeight")
468

469
          expect(page).to have_selector('.board-card', count: 40)
P
Phil Hughes 已提交
470 471
          expect(page).to have_content('Showing 40 of 51 issues')

472
          find('.board .board-list')
P
Phil Hughes 已提交
473
          evaluate_script("document.querySelectorAll('.board .board-list')[1].scrollTop = document.querySelectorAll('.board .board-list')[1].scrollHeight")
P
Phil Hughes 已提交
474

475
          expect(page).to have_selector('.board-card', count: 51)
P
Phil Hughes 已提交
476
          expect(page).to have_content('Showing all issues')
477 478 479
        end
      end

P
Phil Hughes 已提交
480
      it 'filters by multiple labels' do
P
Phil Hughes 已提交
481 482
        set_filter("label", testing.title)
        click_filter_link(testing.title)
P
Phil Hughes 已提交
483

P
Phil Hughes 已提交
484 485 486 487
        set_filter("label", bug.title)
        click_filter_link(bug.title)

        submit_filter
P
Phil Hughes 已提交
488

489
        wait_for_requests
P
Phil Hughes 已提交
490

P
Phil Hughes 已提交
491 492
        wait_for_board_cards(2, 1)
        wait_for_empty_boards((3..4))
P
Phil Hughes 已提交
493
      end
494 495

      it 'filters by clicking label button on issue' do
P
Phil Hughes 已提交
496
        page.within(find('.board:nth-child(2)')) do
497 498
          expect(page).to have_selector('.board-card', count: 8)
          expect(find('.board-card', match: :first)).to have_content(bug.title)
P
Phil Hughes 已提交
499
          click_button(bug.title)
500
          wait_for_requests
501 502
        end

P
Phil Hughes 已提交
503 504 505 506
        page.within('.tokens-container') do
          expect(page).to have_content(bug.title)
        end

507
        wait_for_requests
508

P
Phil Hughes 已提交
509 510
        wait_for_board_cards(2, 1)
        wait_for_empty_boards((3..4))
511 512 513
      end

      it 'removes label filter by clicking label button on issue' do
P
Phil Hughes 已提交
514
        page.within(find('.board:nth-child(2)')) do
515
          page.within(find('.board-card', match: :first)) do
516 517
            click_button(bug.title)
          end
P
Phil Hughes 已提交
518

519
          wait_for_requests
520

521
          expect(page).to have_selector('.board-card', count: 1)
522 523
        end

524
        wait_for_requests
525
      end
P
Phil Hughes 已提交
526 527 528
    end
  end

529 530
  context 'keyboard shortcuts' do
    before do
531
      visit project_board_path(project, board)
532
      wait_for_requests
533 534 535
    end

    it 'allows user to use keyboard shortcuts' do
536
      find('body').native.send_keys('i')
537 538 539 540
      expect(page).to have_content('New Issue')
    end
  end

541 542
  context 'signed out user' do
    before do
543
      sign_out(:user)
544
      visit project_board_path(project, board)
545
      wait_for_requests
546 547
    end

548 549 550 551
    it 'displays lists' do
      expect(page).to have_selector('.board')
    end

552
    it 'does not show create new list' do
E
Eric Eastwood 已提交
553
      expect(page).not_to have_button('.js-new-board-list')
554
    end
555 556 557 558

    it 'does not allow dragging' do
      expect(page).not_to have_selector('.user-can-drag')
    end
559 560 561 562 563 564
  end

  context 'as guest user' do
    let(:user_guest) { create(:user) }

    before do
565
      project.add_guest(user_guest)
566 567
      sign_out(:user)
      sign_in(user_guest)
568
      visit project_board_path(project, board)
569
      wait_for_requests
570 571 572 573 574 575 576
    end

    it 'does not show create new list' do
      expect(page).not_to have_selector('.js-new-board-list')
    end
  end

P
Phil Hughes 已提交
577
  def drag(selector: '.board-list', list_from_index: 0, from_index: 0, to_index: 0, list_to_index: 0)
578
    # ensure there is enough horizontal space for four boards
M
Mike Greiling 已提交
579
    resize_window(2000, 800)
580

P
Phil Hughes 已提交
581 582 583 584 585 586
    drag_to(selector: selector,
            scrollable: '#board-app',
            list_from_index: list_from_index,
            from_index: from_index,
            to_index: to_index,
            list_to_index: list_to_index)
P
Phil Hughes 已提交
587
  end
588 589 590 591

  def wait_for_board_cards(board_number, expected_cards)
    page.within(find(".board:nth-child(#{board_number})")) do
      expect(page.find('.board-header')).to have_content(expected_cards.to_s)
592
      expect(page).to have_selector('.board-card', count: expected_cards)
593 594 595 596 597 598 599 600
    end
  end

  def wait_for_empty_boards(board_numbers)
    board_numbers.each do |board|
      wait_for_board_cards(board, 0)
    end
  end
P
Phil Hughes 已提交
601 602 603 604 605 606 607 608 609 610

  def set_filter(type, text)
    find('.filtered-search').native.send_keys("#{type}:#{text}")
  end

  def submit_filter
    find('.filtered-search').native.send_keys(:enter)
  end

  def click_filter_link(link_text)
E
Eric Eastwood 已提交
611
    page.within('.filtered-search-box') do
P
Phil Hughes 已提交
612 613 614 615 616
      expect(page).to have_button(link_text)

      click_button(link_text)
    end
  end
P
Phil Hughes 已提交
617
end