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

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

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

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

P
Phil Hughes 已提交
17 18 19
    login_as(user)
  end

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

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

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

P
Phil Hughes 已提交
38
    it 'creates default lists' do
39
      lists = ['To Do', 'Doing', 'Done']
P
Phil Hughes 已提交
40

P
Phil Hughes 已提交
41
      page.within(find('.board-blank-state')) do
P
Phil Hughes 已提交
42 43
        click_button('Add default lists')
      end
P
Phil Hughes 已提交
44 45
      wait_for_vue_resource

46
      expect(page).to have_selector('.board', count: 3)
P
Phil Hughes 已提交
47 48 49 50 51

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

P
Phil Hughes 已提交
54
  context 'with lists' do
55
    let(:milestone) { create(:milestone, project: project) }
P
Phil Hughes 已提交
56

57
    let(:planning)    { create(:label, project: project, name: 'Planning', description: 'Test') }
P
Phil Hughes 已提交
58 59
    let(:development) { create(:label, project: project, name: 'Development') }
    let(:testing)     { create(:label, project: project, name: 'Testing') }
P
Phil Hughes 已提交
60
    let(:bug)         { create(:label, project: project, name: 'Bug') }
61 62
    let!(:backlog)    { create(:label, project: project, name: 'Backlog') }
    let!(:done)       { create(:label, project: project, name: 'Done') }
63
    let!(:accepting)  { create(:label, project: project, name: 'Accepting Merge Requests') }
P
Phil Hughes 已提交
64

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

68 69 70 71 72
    let!(:confidential_issue) { create(:labeled_issue, :confidential, project: project, author: user, labels: [planning]) }
    let!(:issue1) { create(:labeled_issue, project: project, assignee: user, labels: [planning]) }
    let!(:issue2) { create(:labeled_issue, project: project, author: user2, labels: [planning]) }
    let!(:issue3) { create(:labeled_issue, project: project, labels: [planning]) }
    let!(:issue4) { create(:labeled_issue, project: project, labels: [planning]) }
P
Phil Hughes 已提交
73
    let!(:issue5) { create(:labeled_issue, project: project, labels: [planning], milestone: milestone) }
74 75
    let!(:issue6) { create(:labeled_issue, project: project, labels: [planning, development]) }
    let!(:issue7) { create(:labeled_issue, project: project, labels: [development]) }
76
    let!(:issue8) { create(:closed_issue, project: project) }
77
    let!(:issue9) { create(:labeled_issue, project: project, labels: [planning, testing, bug, accepting]) }
P
Phil Hughes 已提交
78 79

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

P
Phil Hughes 已提交
82
      wait_for_vue_resource
P
Phil Hughes 已提交
83

84
      expect(page).to have_selector('.board', count: 3)
85 86 87
      expect(find('.board:nth-child(1)')).to have_selector('.card')
      expect(find('.board:nth-child(2)')).to have_selector('.card')
      expect(find('.board:nth-child(3)')).to have_selector('.card')
P
Phil Hughes 已提交
88 89 90
    end

    it 'shows lists' do
91
      expect(page).to have_selector('.board', count: 3)
P
Phil Hughes 已提交
92 93
    end

94
    it 'shows description tooltip on list title' do
95
      page.within('.board:nth-child(1)') 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
101
      wait_for_board_cards(1, 8)
102
      wait_for_board_cards(2, 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', match: :first)) do
P
Phil Hughes 已提交
107 108 109 110
        expect(page).to have_selector('.confidential-icon', count: 1)
      end
    end

111
    it 'search done list' do
V
victorwu 已提交
112
      page.within('#js-boards-search') do
113 114 115 116 117 118 119
        find('.form-control').set(issue8.title)
      end

      wait_for_vue_resource

      expect(find('.board:nth-child(1)')).to have_selector('.card', count: 0)
      expect(find('.board:nth-child(2)')).to have_selector('.card', count: 0)
120
      expect(find('.board:nth-child(3)')).to have_selector('.card', count: 1)
121 122 123
    end

    it 'search list' do
V
victorwu 已提交
124
      page.within('#js-boards-search') do
125 126 127 128 129
        find('.form-control').set(issue5.title)
      end

      wait_for_vue_resource

130 131
      expect(find('.board:nth-child(1)')).to have_selector('.card', count: 1)
      expect(find('.board:nth-child(2)')).to have_selector('.card', count: 0)
132 133 134
      expect(find('.board:nth-child(3)')).to have_selector('.card', count: 0)
    end

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

      wait_for_vue_resource

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

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

149
      page.within(find('.board:nth-child(1)')) do
150 151
        find('.board-delete').click
      end
152

P
Phil Hughes 已提交
153
      wait_for_vue_resource
154

155
      expect(page).to have_selector('.board', count: 2)
156 157
    end

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

163
      visit namespace_project_board_path(project.namespace, project, board)
P
Phil Hughes 已提交
164
      wait_for_vue_resource
165

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

        evaluate_script("document.querySelectorAll('.board .board-list')[0].scrollTop = document.querySelectorAll('.board .board-list')[0].scrollHeight")
P
Phil Hughes 已提交
172
        wait_for_vue_resource
173 174

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

        evaluate_script("document.querySelectorAll('.board .board-list')[0].scrollTop = document.querySelectorAll('.board .board-list')[0].scrollHeight")
P
Phil Hughes 已提交
178
        wait_for_vue_resource
P
Phil Hughes 已提交
179

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

P
Phil Hughes 已提交
185 186
    context 'done' do
      it 'shows list of done issues' do
187
        wait_for_board_cards(3, 1)
188
        wait_for_ajax
P
Phil Hughes 已提交
189 190 191
      end

      it 'moves issue to done' do
P
Phil Hughes 已提交
192
        drag(list_from_index: 0, list_to_index: 2)
P
Phil Hughes 已提交
193

194
        wait_for_board_cards(1, 7)
195 196 197 198
        wait_for_board_cards(2, 2)
        wait_for_board_cards(3, 2)

        expect(find('.board:nth-child(1)')).not_to have_content(issue9.title)
199 200 201
        expect(find('.board:nth-child(3)')).to have_selector('.card', count: 2)
        expect(find('.board:nth-child(3)')).to have_content(issue9.title)
        expect(find('.board:nth-child(3)')).not_to have_content(planning.title)
P
Phil Hughes 已提交
202 203 204
      end

      it 'removes all of the same issue to done' do
P
Phil Hughes 已提交
205
        drag(list_from_index: 0, list_to_index: 2)
P
Phil Hughes 已提交
206

207 208 209
        wait_for_board_cards(1, 7)
        wait_for_board_cards(2, 2)
        wait_for_board_cards(3, 2)
210

211 212 213
        expect(find('.board:nth-child(1)')).not_to have_content(issue9.title)
        expect(find('.board:nth-child(3)')).to have_content(issue9.title)
        expect(find('.board:nth-child(3)')).not_to have_content(planning.title)
P
Phil Hughes 已提交
214 215 216 217
      end
    end

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

221 222 223
        wait_for_board_cards(1, 2)
        wait_for_board_cards(2, 8)
        wait_for_board_cards(3, 1)
224

225 226
        expect(find('.board:nth-child(1)')).to have_content(development.title)
        expect(find('.board:nth-child(1)')).to have_content(planning.title)
P
Phil Hughes 已提交
227 228
      end

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

232 233 234
        wait_for_board_cards(1, 7)
        wait_for_board_cards(2, 2)
        wait_for_board_cards(3, 1)
235

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

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

243 244
        wait_for_board_cards(1, 9)
        wait_for_board_cards(2, 1)
245 246
        wait_for_board_cards(3, 1)

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

P
Phil Hughes 已提交
251
      it 'issue moves from done' do
P
Phil Hughes 已提交
252
        drag(list_from_index: 2, list_to_index: 1)
P
Phil Hughes 已提交
253

P
Phil Hughes 已提交
254
        expect(find('.board:nth-child(2)')).to have_content(issue8.title)
255

256
        wait_for_board_cards(1, 8)
257
        wait_for_board_cards(2, 3)
258
        wait_for_board_cards(3, 0)
P
Phil Hughes 已提交
259 260 261 262
      end

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

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

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

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

289 290
          wait_for_vue_resource

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

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

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

302 303
          wait_for_vue_resource

304
          expect(page).to have_selector('.board', count: 4)
305 306 307
        end

        it 'creates new list for Done label' do
308
          click_button 'Add list'
309
          wait_for_ajax
310 311 312 313 314

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

315 316
          wait_for_vue_resource

317
          expect(page).to have_selector('.board', count: 4)
318 319
        end

320
        it 'keeps dropdown open after adding new list' do
321
          click_button 'Add list'
322 323 324 325 326 327 328 329 330 331 332
          wait_for_ajax

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

          wait_for_vue_resource

          expect(find('.issue-boards-search')).to have_selector('.open')
        end

P
Phil Hughes 已提交
333
        it 'creates new list from a new label' do
334
          click_button 'Add list'
P
Phil Hughes 已提交
335 336 337 338 339 340 341 342 343 344 345 346 347 348

          wait_for_ajax

          click_link 'Create new label'

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

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

          click_button 'Create'

          wait_for_ajax
          wait_for_vue_resource

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

    context 'filtering' do
P
Phil Hughes 已提交
355 356 357
      it 'filters by author' do
        page.within '.issues-filters' do
          click_button('Author')
358
          wait_for_ajax
P
Phil Hughes 已提交
359 360 361 362

          page.within '.dropdown-menu-author' do
            click_link(user2.name)
          end
P
Phil Hughes 已提交
363
          wait_for_vue_resource
P
Phil Hughes 已提交
364 365 366 367

          expect(find('.js-author-search')).to have_content(user2.name)
        end

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

      it 'filters by assignee' do
        page.within '.issues-filters' do
          click_button('Assignee')
376
          wait_for_ajax
P
Phil Hughes 已提交
377 378 379 380

          page.within '.dropdown-menu-assignee' do
            click_link(user.name)
          end
P
Phil Hughes 已提交
381
          wait_for_vue_resource
P
Phil Hughes 已提交
382 383 384 385

          expect(find('.js-assignee-search')).to have_content(user.name)
        end

P
Phil Hughes 已提交
386 387
        wait_for_vue_resource

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

      it 'filters by milestone' do
        page.within '.issues-filters' do
394
          click_button('Milestone')
395
          wait_for_ajax
P
Phil Hughes 已提交
396 397 398 399

          page.within '.milestone-filter' do
            click_link(milestone.title)
          end
P
Phil Hughes 已提交
400
          wait_for_vue_resource
P
Phil Hughes 已提交
401 402 403 404

          expect(find('.js-milestone-select')).to have_content(milestone.title)
        end

P
Phil Hughes 已提交
405
        wait_for_vue_resource
406 407
        wait_for_board_cards(1, 1)
        wait_for_board_cards(2, 0)
408
        wait_for_board_cards(3, 0)
P
Phil Hughes 已提交
409 410 411 412 413
      end

      it 'filters by label' do
        page.within '.issues-filters' do
          click_button('Label')
414
          wait_for_ajax
P
Phil Hughes 已提交
415 416 417

          page.within '.dropdown-menu-labels' do
            click_link(testing.title)
P
Phil Hughes 已提交
418
            wait_for_vue_resource
P
Phil Hughes 已提交
419 420 421 422
            find('.dropdown-menu-close').click
          end
        end

P
Phil Hughes 已提交
423
        wait_for_vue_resource
424
        wait_for_board_cards(1, 1)
425
        wait_for_empty_boards((2..3))
P
Phil Hughes 已提交
426 427
      end

428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455
      it 'filters by label with space after reload' do
        page.within '.issues-filters' do
          click_button('Label')
          wait_for_ajax

          page.within '.dropdown-menu-labels' do
            click_link(accepting.title)
            wait_for_vue_resource(spinner: false)
            find('.dropdown-menu-close').click
          end
        end

        # Test after reload
        page.evaluate_script 'window.location.reload()'

        wait_for_vue_resource

        page.within(find('.board', match: :first)) do
          expect(page.find('.board-header')).to have_content('1')
          expect(page).to have_selector('.card', count: 1)
        end

        page.within(find('.board:nth-child(2)')) do
          expect(page.find('.board-header')).to have_content('0')
          expect(page).to have_selector('.card', count: 0)
        end
      end

456
      it 'removes filtered labels' do
P
Phil Hughes 已提交
457
        wait_for_vue_resource
458

459 460 461 462 463 464
        page.within '.labels-filter' do
          click_button('Label')
          wait_for_ajax

          page.within '.dropdown-menu-labels' do
            click_link(testing.title)
P
Phil Hughes 已提交
465
            wait_for_vue_resource(spinner: false)
466 467 468 469 470 471
          end

          expect(page).to have_css('input[name="label_name[]"]', visible: false)

          page.within '.dropdown-menu-labels' do
            click_link(testing.title)
P
Phil Hughes 已提交
472
            wait_for_vue_resource(spinner: false)
473 474 475 476 477 478
          end

          expect(page).not_to have_css('input[name="label_name[]"]', visible: false)
        end
      end

479 480
      it 'infinite scrolls list with label filter' do
        50.times do
481
          create(:labeled_issue, project: project, labels: [planning, testing])
482 483 484 485
        end

        page.within '.issues-filters' do
          click_button('Label')
486
          wait_for_ajax
487 488 489

          page.within '.dropdown-menu-labels' do
            click_link(testing.title)
P
Phil Hughes 已提交
490
            wait_for_vue_resource
491 492 493 494
            find('.dropdown-menu-close').click
          end
        end

P
Phil Hughes 已提交
495 496
        wait_for_vue_resource

P
Phil Hughes 已提交
497
        page.within(find('.board', match: :first)) do
498
          expect(page.find('.board-header')).to have_content('51')
499
          expect(page).to have_selector('.card', count: 20)
P
Phil Hughes 已提交
500
          expect(page).to have_content('Showing 20 of 51 issues')
501 502 503 504

          evaluate_script("document.querySelectorAll('.board .board-list')[0].scrollTop = document.querySelectorAll('.board .board-list')[0].scrollHeight")

          expect(page).to have_selector('.card', count: 40)
P
Phil Hughes 已提交
505 506 507 508 509 510
          expect(page).to have_content('Showing 40 of 51 issues')

          evaluate_script("document.querySelectorAll('.board .board-list')[0].scrollTop = document.querySelectorAll('.board .board-list')[0].scrollHeight")

          expect(page).to have_selector('.card', count: 51)
          expect(page).to have_content('Showing all issues')
511 512 513
        end
      end

P
Phil Hughes 已提交
514 515 516
      it 'filters by multiple labels' do
        page.within '.issues-filters' do
          click_button('Label')
517
          wait_for_ajax
P
Phil Hughes 已提交
518

519
          page.within(find('.dropdown-menu-labels')) do
P
Phil Hughes 已提交
520
            click_link(testing.title)
P
Phil Hughes 已提交
521
            wait_for_vue_resource
P
Phil Hughes 已提交
522
            click_link(bug.title)
P
Phil Hughes 已提交
523
            wait_for_vue_resource
P
Phil Hughes 已提交
524 525 526 527
            find('.dropdown-menu-close').click
          end
        end

P
Phil Hughes 已提交
528 529
        wait_for_vue_resource

530
        wait_for_board_cards(1, 1)
531
        wait_for_empty_boards((2..3))
P
Phil Hughes 已提交
532
      end
533 534

      it 'filters by clicking label button on issue' do
P
Phil Hughes 已提交
535
        page.within(find('.board', match: :first)) do
536
          expect(page).to have_selector('.card', count: 8)
537
          expect(find('.card', match: :first)).to have_content(bug.title)
P
Phil Hughes 已提交
538
          click_button(bug.title)
P
Phil Hughes 已提交
539
          wait_for_vue_resource
540 541
        end

542 543
        wait_for_vue_resource

544
        wait_for_board_cards(1, 1)
545
        wait_for_empty_boards((2..3))
546 547

        page.within('.labels-filter') do
P
Phil Hughes 已提交
548
          expect(find('.dropdown-toggle-text')).to have_content(bug.title)
549 550 551 552
        end
      end

      it 'removes label filter by clicking label button on issue' do
P
Phil Hughes 已提交
553 554
        page.within(find('.board', match: :first)) do
          page.within(find('.card', match: :first)) do
555 556
            click_button(bug.title)
          end
P
Phil Hughes 已提交
557
          wait_for_vue_resource
558 559 560 561

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

P
Phil Hughes 已提交
562 563
        wait_for_vue_resource

564 565 566 567
        page.within('.labels-filter') do
          expect(find('.dropdown-toggle-text')).to have_content(bug.title)
        end
      end
P
Phil Hughes 已提交
568 569 570
    end
  end

571 572
  context 'keyboard shortcuts' do
    before do
573
      visit namespace_project_board_path(project.namespace, project, board)
574 575 576 577 578 579 580 581 582
      wait_for_vue_resource
    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

583 584 585
  context 'signed out user' do
    before do
      logout
586
      visit namespace_project_board_path(project.namespace, project, board)
587
      wait_for_vue_resource
588 589
    end

590 591 592 593
    it 'displays lists' do
      expect(page).to have_selector('.board')
    end

594 595 596
    it 'does not show create new list' do
      expect(page).not_to have_selector('.js-new-board-list')
    end
597 598 599 600

    it 'does not allow dragging' do
      expect(page).not_to have_selector('.user-can-drag')
    end
601 602 603 604 605 606 607 608 609
  end

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

    before do
      project.team << [user_guest, :guest]
      logout
      login_as(user_guest)
610
      visit namespace_project_board_path(project.namespace, project, board)
611
      wait_for_vue_resource
612 613 614 615 616 617 618
    end

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

P
Phil Hughes 已提交
619 620 621 622 623 624 625
  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 已提交
626
  end
627 628 629 630 631 632 633 634 635 636 637 638 639

  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 已提交
640
end