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

3
describe 'Issue Boards', js: true 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

16
    page.driver.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
P
Phil Hughes 已提交
138
        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 154
        find('.board-delete').click
      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

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

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

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

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

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

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

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

P
Phil Hughes 已提交
201 202 203 204
        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 已提交
205 206
      end

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

292
          wait_for_requests
293

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

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

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

305
          wait_for_requests
306

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

310
        it 'creates new list for Closed label' do
311
          click_button 'Add list'
312
          wait_for_requests
313 314

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

318
          wait_for_requests
319

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

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

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

331
          wait_for_requests
332

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

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

339
          wait_for_requests
P
Phil Hughes 已提交
340 341 342 343 344 345 346 347 348

          click_link 'Create new label'

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

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

          click_button 'Create'

349 350
          wait_for_requests
          wait_for_requests
P
Phil Hughes 已提交
351

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

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

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

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

373
        wait_for_requests
P
Phil Hughes 已提交
374

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

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

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

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

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

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

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

410
        wait_for_requests
411

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

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

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

P
Phil Hughes 已提交
428
        wait_for_board_cards(2, 1)
429

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

P
Phil Hughes 已提交
433
        wait_for_board_cards(2, 8)
434 435
      end

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

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

445
        wait_for_requests
P
Phil Hughes 已提交
446

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

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

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

P
Phil Hughes 已提交
457
          evaluate_script("document.querySelectorAll('.board .board-list')[1].scrollTop = document.querySelectorAll('.board .board-list')[1].scrollHeight")
P
Phil Hughes 已提交
458 459 460

          expect(page).to have_selector('.card', count: 51)
          expect(page).to have_content('Showing all issues')
461 462 463
        end
      end

P
Phil Hughes 已提交
464
      it 'filters by multiple labels' do
P
Phil Hughes 已提交
465 466
        set_filter("label", testing.title)
        click_filter_link(testing.title)
P
Phil Hughes 已提交
467

P
Phil Hughes 已提交
468 469 470 471
        set_filter("label", bug.title)
        click_filter_link(bug.title)

        submit_filter
P
Phil Hughes 已提交
472

473
        wait_for_requests
P
Phil Hughes 已提交
474

P
Phil Hughes 已提交
475 476
        wait_for_board_cards(2, 1)
        wait_for_empty_boards((3..4))
P
Phil Hughes 已提交
477
      end
478 479

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

P
Phil Hughes 已提交
487 488 489 490
        page.within('.tokens-container') do
          expect(page).to have_content(bug.title)
        end

491
        wait_for_requests
492

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

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

503
          wait_for_requests
504 505 506 507

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

508
        wait_for_requests
509
      end
P
Phil Hughes 已提交
510 511 512
    end
  end

513 514
  context 'keyboard shortcuts' do
    before do
515
      visit project_board_path(project, board)
516
      wait_for_requests
517 518 519 520 521 522 523 524
    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

525 526
  context 'signed out user' do
    before do
527
      sign_out(:user)
528
      visit project_board_path(project, board)
529
      wait_for_requests
530 531
    end

532 533 534 535
    it 'displays lists' do
      expect(page).to have_selector('.board')
    end

536 537 538
    it 'does not show create new list' do
      expect(page).not_to have_selector('.js-new-board-list')
    end
539 540 541 542

    it 'does not allow dragging' do
      expect(page).not_to have_selector('.user-can-drag')
    end
543 544 545 546 547 548 549
  end

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

    before do
      project.team << [user_guest, :guest]
550 551
      sign_out(:user)
      sign_in(user_guest)
552
      visit project_board_path(project, board)
553
      wait_for_requests
554 555 556 557 558 559 560
    end

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

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

  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 已提交
582 583 584 585 586 587 588 589 590 591

  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 已提交
592
    page.within('.filtered-search-box') do
P
Phil Hughes 已提交
593 594 595 596 597
      expect(page).to have_button(link_text)

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