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

3
describe 'Issue Boards', :js do
P
Phil Hughes 已提交
4
  include DragTo
5

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

  before do
    project.team << [user, :master]
P
Phil Hughes 已提交
14
    project.team << [user2, :master]
15

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

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

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

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

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

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

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

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

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

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

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

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

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

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

P
Phil Hughes 已提交
75
    let!(:confidential_issue) { create(:labeled_issue, :confidential, project: project, author: user, labels: [planning], relative_position: 9) }
H
Hiroyuki Sato 已提交
76 77 78 79 80 81 82 83 84
    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) }
P
Phil Hughes 已提交
85 86

    before do
87
      visit project_board_path(project, board)
P
Phil Hughes 已提交
88

89
      wait_for_requests
P
Phil Hughes 已提交
90

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

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

P
Phil Hughes 已提交
103
    it 'shows issues in lists' do
P
Phil Hughes 已提交
104 105
      wait_for_board_cards(2, 8)
      wait_for_board_cards(3, 2)
P
Phil Hughes 已提交
106
    end
P
Phil Hughes 已提交
107

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

114
    it 'search closed list' do
115 116
      find('.filtered-search').set(issue8.title)
      find('.filtered-search').native.send_keys(:enter)
117

118
      wait_for_requests
119 120

      expect(find('.board:nth-child(2)')).to have_selector('.card', count: 0)
P
Phil Hughes 已提交
121 122
      expect(find('.board:nth-child(3)')).to have_selector('.card', count: 0)
      expect(find('.board:nth-child(4)')).to have_selector('.card', count: 1)
123 124 125
    end

    it 'search list' do
126 127
      find('.filtered-search').set(issue5.title)
      find('.filtered-search').native.send_keys(:enter)
128

129
      wait_for_requests
130

P
Phil Hughes 已提交
131
      expect(find('.board:nth-child(2)')).to have_selector('.card', count: 1)
132
      expect(find('.board:nth-child(3)')).to have_selector('.card', count: 0)
P
Phil Hughes 已提交
133
      expect(find('.board:nth-child(4)')).to have_selector('.card', count: 0)
134 135
    end

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

141
      wait_for_requests
P
Phil Hughes 已提交
142

P
Phil Hughes 已提交
143
      expect(page).to have_selector('.board', count: 3)
P
Phil Hughes 已提交
144 145
    end

146
    it 'removes checkmark in new list dropdown after deleting' do
147
      click_button 'Add list'
148
      wait_for_requests
149

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

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

156
      wait_for_requests
157

P
Phil Hughes 已提交
158
      expect(page).to have_selector('.board', count: 3)
159 160
    end

161 162
    it 'infinite scrolls list' do
      50.times do
163
        create(:labeled_issue, project: project, labels: [planning])
164 165
      end

166
      visit project_board_path(project, board)
167
      wait_for_requests
168

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

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

        expect(page).to have_selector('.card', count: 40)
179
        expect(page).to have_content('Showing 40 of 58 issues')
P
Phil Hughes 已提交
180

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

185
        expect(page).to have_selector('.card', count: 58)
P
Phil Hughes 已提交
186
        expect(page).to have_content('Showing all issues')
187 188 189
      end
    end

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

196
      it 'moves issue to closed' do
P
Phil Hughes 已提交
197
        drag(list_from_index: 1, list_to_index: 3)
P
Phil Hughes 已提交
198

P
Phil Hughes 已提交
199
        wait_for_board_cards(2, 7)
200
        wait_for_board_cards(3, 2)
P
Phil Hughes 已提交
201
        wait_for_board_cards(4, 2)
202

P
Phil Hughes 已提交
203 204 205 206
        expect(find('.board:nth-child(2)')).not_to have_content(issue9.title)
        expect(find('.board:nth-child(4)')).to have_selector('.card', count: 2)
        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 已提交
207 208
      end

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

P
Phil Hughes 已提交
212
        wait_for_board_cards(2, 7)
213
        wait_for_board_cards(3, 2)
P
Phil Hughes 已提交
214
        wait_for_board_cards(4, 2)
215

P
Phil Hughes 已提交
216 217 218
        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 已提交
219 220 221 222
      end
    end

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

P
Phil Hughes 已提交
226 227 228
        wait_for_board_cards(2, 2)
        wait_for_board_cards(3, 8)
        wait_for_board_cards(4, 1)
229

P
Phil Hughes 已提交
230 231
        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 已提交
232 233
      end

P
Phil Hughes 已提交
234
      it 'issue moves between lists' do
P
Phil Hughes 已提交
235
        drag(list_from_index: 1, from_index: 1, list_to_index: 2)
P
Phil Hughes 已提交
236

P
Phil Hughes 已提交
237 238 239
        wait_for_board_cards(2, 7)
        wait_for_board_cards(3, 2)
        wait_for_board_cards(4, 1)
240

P
Phil Hughes 已提交
241
        expect(find('.board:nth-child(3)')).to have_content(issue6.title)
R
Regis Boudinot 已提交
242
        expect(find('.board:nth-child(3)').all('.card').last).to have_content(development.title)
P
Phil Hughes 已提交
243 244
      end

P
Phil Hughes 已提交
245
      it 'issue moves between lists' do
P
Phil Hughes 已提交
246
        drag(list_from_index: 2, list_to_index: 1)
P
Phil Hughes 已提交
247

P
Phil Hughes 已提交
248
        wait_for_board_cards(2, 9)
249
        wait_for_board_cards(3, 1)
P
Phil Hughes 已提交
250
        wait_for_board_cards(4, 1)
251

P
Phil Hughes 已提交
252
        expect(find('.board:nth-child(2)')).to have_content(issue7.title)
R
Regis Boudinot 已提交
253
        expect(find('.board:nth-child(2)').all('.card').first).to have_content(planning.title)
P
Phil Hughes 已提交
254 255
      end

256
      it 'issue moves from closed' do
P
Phil Hughes 已提交
257
        drag(list_from_index: 2, list_to_index: 3)
P
Phil Hughes 已提交
258

P
Phil Hughes 已提交
259
        wait_for_board_cards(2, 8)
P
Phil Hughes 已提交
260 261
        wait_for_board_cards(3, 1)
        wait_for_board_cards(4, 2)
262

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

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

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

          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
287
          click_button 'Add list'
288
          wait_for_requests
P
Phil Hughes 已提交
289 290 291 292 293

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

294
          wait_for_requests
295

P
Phil Hughes 已提交
296
          expect(page).to have_selector('.board', count: 5)
P
Phil Hughes 已提交
297 298
        end

299
        it 'creates new list for Backlog label' do
300
          click_button 'Add list'
301
          wait_for_requests
302 303 304 305 306

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

307
          wait_for_requests
308

P
Phil Hughes 已提交
309
          expect(page).to have_selector('.board', count: 5)
310 311
        end

312
        it 'creates new list for Closed label' do
313
          click_button 'Add list'
314
          wait_for_requests
315 316

          page.within('.dropdown-menu-issues-board-new') do
317
            click_link closed.title
318 319
          end

320
          wait_for_requests
321

P
Phil Hughes 已提交
322
          expect(page).to have_selector('.board', count: 5)
323 324
        end

325
        it 'keeps dropdown open after adding new list' do
326
          click_button 'Add list'
327
          wait_for_requests
328 329

          page.within('.dropdown-menu-issues-board-new') do
330
            click_link closed.title
331 332
          end

333
          wait_for_requests
334

335
          expect(page).to have_css('#js-add-list.open')
336 337
        end

P
Phil Hughes 已提交
338
        it 'creates new list from a new label' do
339
          click_button 'Add list'
P
Phil Hughes 已提交
340

341
          wait_for_requests
P
Phil Hughes 已提交
342 343 344 345 346 347 348 349 350

          click_link 'Create new label'

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

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

          click_button 'Create'

351 352
          wait_for_requests
          wait_for_requests
P
Phil Hughes 已提交
353

P
Phil Hughes 已提交
354
          expect(page).to have_selector('.board', count: 5)
P
Phil Hughes 已提交
355
        end
P
Phil Hughes 已提交
356 357 358 359
      end
    end

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

365
        wait_for_requests
P
Phil Hughes 已提交
366 367
        wait_for_board_cards(2, 1)
        wait_for_empty_boards((3..4))
P
Phil Hughes 已提交
368 369 370
      end

      it 'filters by assignee' do
P
Phil Hughes 已提交
371 372 373
        set_filter("assignee", user.username)
        click_filter_link(user.username)
        submit_filter
P
Phil Hughes 已提交
374

375
        wait_for_requests
P
Phil Hughes 已提交
376

P
Phil Hughes 已提交
377 378
        wait_for_board_cards(2, 1)
        wait_for_empty_boards((3..4))
P
Phil Hughes 已提交
379 380 381
      end

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

386
        wait_for_requests
P
Phil Hughes 已提交
387
        wait_for_board_cards(2, 1)
388
        wait_for_board_cards(3, 0)
P
Phil Hughes 已提交
389
        wait_for_board_cards(4, 0)
P
Phil Hughes 已提交
390 391 392
      end

      it 'filters by label' do
P
Phil Hughes 已提交
393 394 395
        set_filter("label", testing.title)
        click_filter_link(testing.title)
        submit_filter
P
Phil Hughes 已提交
396

397
        wait_for_requests
P
Phil Hughes 已提交
398 399
        wait_for_board_cards(2, 1)
        wait_for_empty_boards((3..4))
P
Phil Hughes 已提交
400 401
      end

402
      it 'filters by label with space after reload' do
403
        set_filter("label", "\"#{accepting.title}")
P
Phil Hughes 已提交
404 405
        click_filter_link(accepting.title)
        submit_filter
406 407 408

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

412
        wait_for_requests
413

P
Phil Hughes 已提交
414
        page.within(find('.board:nth-child(2)')) do
415 416 417 418
          expect(page.find('.board-header')).to have_content('1')
          expect(page).to have_selector('.card', count: 1)
        end

P
Phil Hughes 已提交
419
        page.within(find('.board:nth-child(3)')) do
420 421 422 423 424
          expect(page.find('.board-header')).to have_content('0')
          expect(page).to have_selector('.card', count: 0)
        end
      end

425
      it 'removes filtered labels' do
P
Phil Hughes 已提交
426 427 428
        set_filter("label", testing.title)
        click_filter_link(testing.title)
        submit_filter
429

P
Phil Hughes 已提交
430
        wait_for_board_cards(2, 1)
431

P
Phil Hughes 已提交
432 433
        find('.clear-search').click
        submit_filter
434

P
Phil Hughes 已提交
435
        wait_for_board_cards(2, 8)
436 437
      end

438 439
      it 'infinite scrolls list with label filter' do
        50.times do
440
          create(:labeled_issue, project: project, labels: [planning, testing])
441 442
        end

P
Phil Hughes 已提交
443 444 445
        set_filter("label", testing.title)
        click_filter_link(testing.title)
        submit_filter
446

447
        wait_for_requests
P
Phil Hughes 已提交
448

P
Phil Hughes 已提交
449
        page.within(find('.board:nth-child(2)')) do
450
          expect(page.find('.board-header')).to have_content('51')
451
          expect(page).to have_selector('.card', count: 20)
P
Phil Hughes 已提交
452
          expect(page).to have_content('Showing 20 of 51 issues')
453

454
          find('.board .board-list')
P
Phil Hughes 已提交
455
          evaluate_script("document.querySelectorAll('.board .board-list')[1].scrollTop = document.querySelectorAll('.board .board-list')[1].scrollHeight")
456 457

          expect(page).to have_selector('.card', count: 40)
P
Phil Hughes 已提交
458 459
          expect(page).to have_content('Showing 40 of 51 issues')

460
          find('.board .board-list')
P
Phil Hughes 已提交
461
          evaluate_script("document.querySelectorAll('.board .board-list')[1].scrollTop = document.querySelectorAll('.board .board-list')[1].scrollHeight")
P
Phil Hughes 已提交
462 463 464

          expect(page).to have_selector('.card', count: 51)
          expect(page).to have_content('Showing all issues')
465 466 467
        end
      end

P
Phil Hughes 已提交
468
      it 'filters by multiple labels' do
P
Phil Hughes 已提交
469 470
        set_filter("label", testing.title)
        click_filter_link(testing.title)
P
Phil Hughes 已提交
471

P
Phil Hughes 已提交
472 473 474 475
        set_filter("label", bug.title)
        click_filter_link(bug.title)

        submit_filter
P
Phil Hughes 已提交
476

477
        wait_for_requests
P
Phil Hughes 已提交
478

P
Phil Hughes 已提交
479 480
        wait_for_board_cards(2, 1)
        wait_for_empty_boards((3..4))
P
Phil Hughes 已提交
481
      end
482 483

      it 'filters by clicking label button on issue' do
P
Phil Hughes 已提交
484
        page.within(find('.board:nth-child(2)')) do
485
          expect(page).to have_selector('.card', count: 8)
486
          expect(find('.card', match: :first)).to have_content(bug.title)
P
Phil Hughes 已提交
487
          click_button(bug.title)
488
          wait_for_requests
489 490
        end

P
Phil Hughes 已提交
491 492 493 494
        page.within('.tokens-container') do
          expect(page).to have_content(bug.title)
        end

495
        wait_for_requests
496

P
Phil Hughes 已提交
497 498
        wait_for_board_cards(2, 1)
        wait_for_empty_boards((3..4))
499 500 501
      end

      it 'removes label filter by clicking label button on issue' do
P
Phil Hughes 已提交
502
        page.within(find('.board:nth-child(2)')) do
P
Phil Hughes 已提交
503
          page.within(find('.card', match: :first)) do
504 505
            click_button(bug.title)
          end
P
Phil Hughes 已提交
506

507
          wait_for_requests
508 509 510 511

          expect(page).to have_selector('.card', count: 1)
        end

512
        wait_for_requests
513
      end
P
Phil Hughes 已提交
514 515 516
    end
  end

517 518
  context 'keyboard shortcuts' do
    before do
519
      visit project_board_path(project, board)
520
      wait_for_requests
521 522 523
    end

    it 'allows user to use keyboard shortcuts' do
524
      find('body').native.send_keys('i')
525 526 527 528
      expect(page).to have_content('New Issue')
    end
  end

529 530
  context 'signed out user' do
    before do
531
      sign_out(:user)
532
      visit project_board_path(project, board)
533
      wait_for_requests
534 535
    end

536 537 538 539
    it 'displays lists' do
      expect(page).to have_selector('.board')
    end

540
    it 'does not show create new list' do
E
Eric Eastwood 已提交
541
      expect(page).not_to have_button('.js-new-board-list')
542
    end
543 544 545 546

    it 'does not allow dragging' do
      expect(page).not_to have_selector('.user-can-drag')
    end
547 548 549 550 551 552 553
  end

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

    before do
      project.team << [user_guest, :guest]
554 555
      sign_out(:user)
      sign_in(user_guest)
556
      visit project_board_path(project, board)
557
      wait_for_requests
558 559 560 561 562 563 564
    end

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

P
Phil Hughes 已提交
565
  def drag(selector: '.board-list', list_from_index: 0, from_index: 0, to_index: 0, list_to_index: 0)
566 567 568
    # ensure there is enough horizontal space for four boards
    page.current_window.resize_to(2000, 800)

P
Phil Hughes 已提交
569 570 571 572 573 574
    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 已提交
575
  end
576 577 578 579 580 581 582 583 584 585 586 587 588

  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)
      expect(page).to have_selector('.card', count: expected_cards)
    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 已提交
589 590 591 592 593 594 595 596 597 598

  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 已提交
599
    page.within('.filtered-search-box') do
P
Phil Hughes 已提交
600 601 602 603 604
      expect(page).to have_button(link_text)

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