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

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

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

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

15
    gitlab_sign_in(user)
P
Phil Hughes 已提交
16 17
  end

P
Phil Hughes 已提交
18 19
  context 'no lists' do
    before do
20
      visit namespace_project_board_path(project.namespace, project, board)
21
      wait_for_requests
P
Phil Hughes 已提交
22
      expect(page).to have_selector('.board', count: 3)
P
Phil Hughes 已提交
23
    end
P
Phil Hughes 已提交
24

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

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

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

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

P
Phil Hughes 已提交
42
    it 'creates default lists' do
P
Phil Hughes 已提交
43
      lists = ['Backlog', 'To Do', 'Doing', 'Closed']
P
Phil Hughes 已提交
44

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

P
Phil Hughes 已提交
50
      expect(page).to have_selector('.board', count: 4)
P
Phil Hughes 已提交
51 52 53 54 55

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

P
Phil Hughes 已提交
58
  context 'with lists' do
59
    let(:milestone) { create(:milestone, project: project) }
P
Phil Hughes 已提交
60

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

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

P
Phil Hughes 已提交
72
    let!(:confidential_issue) { create(:labeled_issue, :confidential, project: project, author: user, labels: [planning], relative_position: 9) }
73
    let!(:issue1) { create(:labeled_issue, project: project, assignees: [user], labels: [planning], relative_position: 8) }
P
Phil Hughes 已提交
74 75 76 77 78 79
    let!(:issue2) { create(:labeled_issue, project: project, author: user2, labels: [planning], relative_position: 7) }
    let!(:issue3) { create(:labeled_issue, project: project, labels: [planning], relative_position: 6) }
    let!(:issue4) { create(:labeled_issue, project: project, labels: [planning], relative_position: 5) }
    let!(:issue5) { create(:labeled_issue, project: project, labels: [planning], milestone: milestone, relative_position: 4) }
    let!(:issue6) { create(:labeled_issue, project: project, labels: [planning, development], relative_position: 3) }
    let!(:issue7) { create(:labeled_issue, project: project, labels: [development], relative_position: 2) }
80
    let!(:issue8) { create(:closed_issue, project: project) }
P
Phil Hughes 已提交
81
    let!(:issue9) { create(:labeled_issue, project: project, labels: [planning, testing, bug, accepting], relative_position: 1) }
P
Phil Hughes 已提交
82 83

    before do
84
      visit namespace_project_board_path(project.namespace, project, board)
P
Phil Hughes 已提交
85

86
      wait_for_requests
P
Phil Hughes 已提交
87

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

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

P
Phil Hughes 已提交
100
    it 'shows issues in lists' do
P
Phil Hughes 已提交
101 102
      wait_for_board_cards(2, 8)
      wait_for_board_cards(3, 2)
P
Phil Hughes 已提交
103
    end
P
Phil Hughes 已提交
104

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

111
    it 'search closed list' do
112 113
      find('.filtered-search').set(issue8.title)
      find('.filtered-search').native.send_keys(:enter)
114

115
      wait_for_requests
116 117

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

    it 'search list' do
123 124
      find('.filtered-search').set(issue5.title)
      find('.filtered-search').native.send_keys(:enter)
125

126
      wait_for_requests
127

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

P
Phil Hughes 已提交
133
    it 'allows user to delete board' do
P
Phil Hughes 已提交
134
      page.within(find('.board:nth-child(2)')) do
P
Phil Hughes 已提交
135
        find('.board-delete').click
P
Phil Hughes 已提交
136
      end
P
Phil Hughes 已提交
137

138
      wait_for_requests
P
Phil Hughes 已提交
139

P
Phil Hughes 已提交
140
      expect(page).to have_selector('.board', count: 3)
P
Phil Hughes 已提交
141 142
    end

143
    it 'removes checkmark in new list dropdown after deleting' do
144
      click_button 'Add list'
145
      wait_for_requests
146

P
Phil Hughes 已提交
147
      page.within(find('.board:nth-child(2)')) do
148 149
        find('.board-delete').click
      end
150

151
      wait_for_requests
152

P
Phil Hughes 已提交
153
      expect(page).to have_selector('.board', count: 3)
154 155
    end

156 157
    it 'infinite scrolls list' do
      50.times do
158
        create(:labeled_issue, project: project, labels: [planning])
159 160
      end

161
      visit namespace_project_board_path(project.namespace, project, board)
162
      wait_for_requests
163

P
Phil Hughes 已提交
164
      page.within(find('.board:nth-child(2)')) do
165
        expect(page.find('.board-header')).to have_content('58')
166
        expect(page).to have_selector('.card', count: 20)
167
        expect(page).to have_content('Showing 20 of 58 issues')
168

P
Phil Hughes 已提交
169
        evaluate_script("document.querySelectorAll('.board .board-list')[1].scrollTop = document.querySelectorAll('.board .board-list')[1].scrollHeight")
170
        wait_for_requests
171 172

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

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

178
        expect(page).to have_selector('.card', count: 58)
P
Phil Hughes 已提交
179
        expect(page).to have_content('Showing all issues')
180 181 182
      end
    end

183 184
    context 'closed' do
      it 'shows list of closed issues' do
P
Phil Hughes 已提交
185
        wait_for_board_cards(4, 1)
186
        wait_for_requests
P
Phil Hughes 已提交
187 188
      end

189
      it 'moves issue to closed' do
P
Phil Hughes 已提交
190
        drag(list_from_index: 1, list_to_index: 3)
P
Phil Hughes 已提交
191

P
Phil Hughes 已提交
192
        wait_for_board_cards(2, 7)
193
        wait_for_board_cards(3, 2)
P
Phil Hughes 已提交
194
        wait_for_board_cards(4, 2)
195

P
Phil Hughes 已提交
196 197 198 199
        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 已提交
200 201
      end

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

P
Phil Hughes 已提交
205
        wait_for_board_cards(2, 7)
206
        wait_for_board_cards(3, 2)
P
Phil Hughes 已提交
207
        wait_for_board_cards(4, 2)
208

P
Phil Hughes 已提交
209 210 211
        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 已提交
212 213 214 215
      end
    end

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

P
Phil Hughes 已提交
219 220 221
        wait_for_board_cards(2, 2)
        wait_for_board_cards(3, 8)
        wait_for_board_cards(4, 1)
222

P
Phil Hughes 已提交
223 224
        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 已提交
225 226
      end

P
Phil Hughes 已提交
227
      it 'issue moves between lists' do
P
Phil Hughes 已提交
228
        drag(list_from_index: 1, from_index: 1, list_to_index: 2)
P
Phil Hughes 已提交
229

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

P
Phil Hughes 已提交
234 235
        expect(find('.board:nth-child(3)')).to have_content(issue6.title)
        expect(find('.board:nth-child(3)').all('.card').last).not_to have_content(development.title)
P
Phil Hughes 已提交
236 237
      end

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

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

P
Phil Hughes 已提交
245 246
        expect(find('.board:nth-child(2)')).to have_content(issue7.title)
        expect(find('.board:nth-child(2)').all('.card').first).not_to have_content(planning.title)
P
Phil Hughes 已提交
247 248
      end

249
      it 'issue moves from closed' do
P
Phil Hughes 已提交
250
        drag(list_from_index: 2, list_to_index: 3)
P
Phil Hughes 已提交
251

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

P
Phil Hughes 已提交
256
        expect(find('.board:nth-child(4)')).to have_content(issue8.title)
P
Phil Hughes 已提交
257 258 259 260
      end

      context 'issue card' do
        it 'shows assignee' do
P
Phil Hughes 已提交
261
          page.within(find('.board:nth-child(2)')) do
P
Phil Hughes 已提交
262
            expect(page).to have_selector('.avatar', count: 1)
P
Phil Hughes 已提交
263 264 265 266 267 268
          end
        end
      end

      context 'new list' do
        it 'shows all labels in new list dropdown' do
269
          click_button 'Add list'
270
          wait_for_requests
P
Phil Hughes 已提交
271 272 273 274 275 276 277 278 279

          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
280
          click_button 'Add list'
281
          wait_for_requests
P
Phil Hughes 已提交
282 283 284 285 286

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

287
          wait_for_requests
288

P
Phil Hughes 已提交
289
          expect(page).to have_selector('.board', count: 5)
P
Phil Hughes 已提交
290 291
        end

292
        it 'creates new list for Backlog label' do
293
          click_button 'Add list'
294
          wait_for_requests
295 296 297 298 299

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

300
          wait_for_requests
301

P
Phil Hughes 已提交
302
          expect(page).to have_selector('.board', count: 5)
303 304
        end

305
        it 'creates new list for Closed label' do
306
          click_button 'Add list'
307
          wait_for_requests
308 309

          page.within('.dropdown-menu-issues-board-new') do
310
            click_link closed.title
311 312
          end

313
          wait_for_requests
314

P
Phil Hughes 已提交
315
          expect(page).to have_selector('.board', count: 5)
316 317
        end

318
        it 'keeps dropdown open after adding new list' do
319
          click_button 'Add list'
320
          wait_for_requests
321 322

          page.within('.dropdown-menu-issues-board-new') do
323
            click_link closed.title
324 325
          end

326
          wait_for_requests
327

328
          expect(page).to have_css('#js-add-list.open')
329 330
        end

P
Phil Hughes 已提交
331
        it 'creates new list from a new label' do
332
          click_button 'Add list'
P
Phil Hughes 已提交
333

334
          wait_for_requests
P
Phil Hughes 已提交
335 336 337 338 339 340 341 342 343

          click_link 'Create new label'

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

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

          click_button 'Create'

344 345
          wait_for_requests
          wait_for_requests
P
Phil Hughes 已提交
346

P
Phil Hughes 已提交
347
          expect(page).to have_selector('.board', count: 5)
P
Phil Hughes 已提交
348
        end
P
Phil Hughes 已提交
349 350 351 352
      end
    end

    context 'filtering' do
P
Phil Hughes 已提交
353
      it 'filters by author' do
P
Phil Hughes 已提交
354 355 356
        set_filter("author", user2.username)
        click_filter_link(user2.username)
        submit_filter
P
Phil Hughes 已提交
357

358
        wait_for_requests
P
Phil Hughes 已提交
359 360
        wait_for_board_cards(2, 1)
        wait_for_empty_boards((3..4))
P
Phil Hughes 已提交
361 362 363
      end

      it 'filters by assignee' do
P
Phil Hughes 已提交
364 365 366
        set_filter("assignee", user.username)
        click_filter_link(user.username)
        submit_filter
P
Phil Hughes 已提交
367

368
        wait_for_requests
P
Phil Hughes 已提交
369

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

      it 'filters by milestone' do
P
Phil Hughes 已提交
375 376 377
        set_filter("milestone", "\"#{milestone.title}\"")
        click_filter_link(milestone.title)
        submit_filter
P
Phil Hughes 已提交
378

379
        wait_for_requests
P
Phil Hughes 已提交
380
        wait_for_board_cards(2, 1)
381
        wait_for_board_cards(3, 0)
P
Phil Hughes 已提交
382
        wait_for_board_cards(4, 0)
P
Phil Hughes 已提交
383 384 385
      end

      it 'filters by label' do
P
Phil Hughes 已提交
386 387 388
        set_filter("label", testing.title)
        click_filter_link(testing.title)
        submit_filter
P
Phil Hughes 已提交
389

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

395
      it 'filters by label with space after reload' do
P
Phil Hughes 已提交
396 397 398
        set_filter("label", "\"#{accepting.title}\"")
        click_filter_link(accepting.title)
        submit_filter
399 400 401

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

405
        wait_for_requests
406

P
Phil Hughes 已提交
407
        page.within(find('.board:nth-child(2)')) do
408 409 410 411
          expect(page.find('.board-header')).to have_content('1')
          expect(page).to have_selector('.card', count: 1)
        end

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

418
      it 'removes filtered labels' do
P
Phil Hughes 已提交
419 420 421
        set_filter("label", testing.title)
        click_filter_link(testing.title)
        submit_filter
422

P
Phil Hughes 已提交
423
        wait_for_board_cards(2, 1)
424

P
Phil Hughes 已提交
425 426
        find('.clear-search').click
        submit_filter
427

P
Phil Hughes 已提交
428
        wait_for_board_cards(2, 8)
429 430
      end

431 432
      it 'infinite scrolls list with label filter' do
        50.times do
433
          create(:labeled_issue, project: project, labels: [planning, testing])
434 435
        end

P
Phil Hughes 已提交
436 437 438
        set_filter("label", testing.title)
        click_filter_link(testing.title)
        submit_filter
439

440
        wait_for_requests
P
Phil Hughes 已提交
441

P
Phil Hughes 已提交
442
        page.within(find('.board:nth-child(2)')) do
443
          expect(page.find('.board-header')).to have_content('51')
444
          expect(page).to have_selector('.card', count: 20)
P
Phil Hughes 已提交
445
          expect(page).to have_content('Showing 20 of 51 issues')
446

P
Phil Hughes 已提交
447
          evaluate_script("document.querySelectorAll('.board .board-list')[1].scrollTop = document.querySelectorAll('.board .board-list')[1].scrollHeight")
448 449

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

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

          expect(page).to have_selector('.card', count: 51)
          expect(page).to have_content('Showing all issues')
456 457 458
        end
      end

P
Phil Hughes 已提交
459
      it 'filters by multiple labels' do
P
Phil Hughes 已提交
460 461
        set_filter("label", testing.title)
        click_filter_link(testing.title)
P
Phil Hughes 已提交
462

P
Phil Hughes 已提交
463 464 465 466
        set_filter("label", bug.title)
        click_filter_link(bug.title)

        submit_filter
P
Phil Hughes 已提交
467

468
        wait_for_requests
P
Phil Hughes 已提交
469

P
Phil Hughes 已提交
470 471
        wait_for_board_cards(2, 1)
        wait_for_empty_boards((3..4))
P
Phil Hughes 已提交
472
      end
473 474

      it 'filters by clicking label button on issue' do
P
Phil Hughes 已提交
475
        page.within(find('.board:nth-child(2)')) do
476
          expect(page).to have_selector('.card', count: 8)
477
          expect(find('.card', match: :first)).to have_content(bug.title)
P
Phil Hughes 已提交
478
          click_button(bug.title)
479
          wait_for_requests
480 481
        end

P
Phil Hughes 已提交
482 483 484 485
        page.within('.tokens-container') do
          expect(page).to have_content(bug.title)
        end

486
        wait_for_requests
487

P
Phil Hughes 已提交
488 489
        wait_for_board_cards(2, 1)
        wait_for_empty_boards((3..4))
490 491 492
      end

      it 'removes label filter by clicking label button on issue' do
P
Phil Hughes 已提交
493
        page.within(find('.board:nth-child(2)')) do
P
Phil Hughes 已提交
494
          page.within(find('.card', match: :first)) do
495 496
            click_button(bug.title)
          end
P
Phil Hughes 已提交
497

498
          wait_for_requests
499 500 501 502

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

503
        wait_for_requests
504
      end
P
Phil Hughes 已提交
505 506 507
    end
  end

508 509
  context 'keyboard shortcuts' do
    before do
510
      visit namespace_project_board_path(project.namespace, project, board)
511
      wait_for_requests
512 513 514 515 516 517 518 519
    end

    it 'allows user to use keyboard shortcuts' do
      find('.boards-list').native.send_keys('i')
      expect(page).to have_content('New Issue')
    end
  end

520 521
  context 'signed out user' do
    before do
522
      gitlab_sign_out
523
      visit namespace_project_board_path(project.namespace, project, board)
524
      wait_for_requests
525 526
    end

527 528 529 530
    it 'displays lists' do
      expect(page).to have_selector('.board')
    end

531 532 533
    it 'does not show create new list' do
      expect(page).not_to have_selector('.js-new-board-list')
    end
534 535 536 537

    it 'does not allow dragging' do
      expect(page).not_to have_selector('.user-can-drag')
    end
538 539 540 541 542 543 544
  end

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

    before do
      project.team << [user_guest, :guest]
545
      gitlab_sign_out
546
      gitlab_sign_in(user_guest)
547
      visit namespace_project_board_path(project.namespace, project, board)
548
      wait_for_requests
549 550 551 552 553 554 555
    end

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

P
Phil Hughes 已提交
556 557 558 559 560 561 562
  def drag(selector: '.board-list', list_from_index: 0, from_index: 0, to_index: 0, list_to_index: 0)
    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 已提交
563
  end
564 565 566 567 568 569 570 571 572 573 574 575 576

  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 已提交
577 578 579 580 581 582 583 584 585 586

  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 已提交
587
    page.within('.filtered-search-box') do
P
Phil Hughes 已提交
588 589 590 591 592
      expect(page).to have_button(link_text)

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