boards_spec.rb 18.1 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(:group) { create(:group, :nested) }
  let(:project) { create(:empty_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

16
    sign_in(user)
P
Phil Hughes 已提交
17 18
  end

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

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

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

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

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

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

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

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

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

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

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

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

P
Phil Hughes 已提交
73
    let!(:confidential_issue) { create(:labeled_issue, :confidential, project: project, author: user, labels: [planning], relative_position: 9) }
74
    let!(:issue1) { create(:labeled_issue, project: project, assignees: [user], labels: [planning], relative_position: 8) }
P
Phil Hughes 已提交
75 76 77 78 79 80
    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) }
81
    let!(:issue8) { create(:closed_issue, project: project) }
P
Phil Hughes 已提交
82
    let!(:issue9) { create(:labeled_issue, project: project, labels: [planning, testing, bug, accepting], relative_position: 1) }
P
Phil Hughes 已提交
83 84

    before do
85
      visit project_board_path(project, board)
P
Phil Hughes 已提交
86

87
      wait_for_requests
P
Phil Hughes 已提交
88

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

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

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

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

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

116
      wait_for_requests
117 118

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

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

127
      wait_for_requests
128

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

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

139
      wait_for_requests
P
Phil Hughes 已提交
140

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

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

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

152
      wait_for_requests
153

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

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

162
      visit project_board_path(project, board)
163
      wait_for_requests
164

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

P
Phil Hughes 已提交
235 236
        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 已提交
237 238
      end

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

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

P
Phil Hughes 已提交
246 247
        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 已提交
248 249
      end

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

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

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

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

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

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

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

288
          wait_for_requests
289

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

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

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

301
          wait_for_requests
302

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

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

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

314
          wait_for_requests
315

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

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

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

327
          wait_for_requests
328

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

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

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

          click_link 'Create new label'

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

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

          click_button 'Create'

345 346
          wait_for_requests
          wait_for_requests
P
Phil Hughes 已提交
347

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

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

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

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

369
        wait_for_requests
P
Phil Hughes 已提交
370

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

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

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

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

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

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

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

406
        wait_for_requests
407

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

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

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

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

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

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

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

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

441
        wait_for_requests
P
Phil Hughes 已提交
442

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

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

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

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

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

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

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

        submit_filter
P
Phil Hughes 已提交
468

469
        wait_for_requests
P
Phil Hughes 已提交
470

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

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

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

487
        wait_for_requests
488

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

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

499
          wait_for_requests
500 501 502 503

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

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

509 510
  context 'keyboard shortcuts' do
    before do
511
      visit project_board_path(project, board)
512
      wait_for_requests
513 514 515 516 517 518 519 520
    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

521 522
  context 'signed out user' do
    before do
523
      sign_out(:user)
524
      visit project_board_path(project, board)
525
      wait_for_requests
526 527
    end

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

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

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

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

    before do
      project.team << [user_guest, :guest]
546 547
      sign_out(:user)
      sign_in(user_guest)
548
      visit project_board_path(project, board)
549
      wait_for_requests
550 551 552 553 554 555 556
    end

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

P
Phil Hughes 已提交
557 558 559 560 561 562 563
  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 已提交
564
  end
565 566 567 568 569 570 571 572 573 574 575 576 577

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

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

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