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

3
describe 'Issue Boards', :js do
M
Mike Greiling 已提交
4
  include CookieHelper
P
Phil Hughes 已提交
5
  include DragTo
6

7
  let(:group) { create(:group, :nested) }
8
  let(:project) { create(:project, :public, namespace: group) }
9
  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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

90
      wait_for_requests
P
Phil Hughes 已提交
91

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

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

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

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

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

119
      wait_for_requests
120 121

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

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

130
      wait_for_requests
131

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

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

142
      wait_for_requests
P
Phil Hughes 已提交
143

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

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

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

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

157
      wait_for_requests
158

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

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

167
      visit project_board_path(project, board)
168
      wait_for_requests
169

P
Phil Hughes 已提交
170
      page.within(find('.board:nth-child(2)')) do
171
        expect(page.find('.board-header')).to have_content('58')
172
        expect(page).to have_selector('.card', count: 20)
173
        expect(page).to have_content('Showing 20 of 58 issues')
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
177 178

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

293
          wait_for_requests
294

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

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

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

306
          wait_for_requests
307

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

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

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

319
          wait_for_requests
320

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

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

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

332
          wait_for_requests
333

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

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

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

          click_link 'Create new label'

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

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

          click_button 'Create'

350 351
          wait_for_requests
          wait_for_requests
P
Phil Hughes 已提交
352

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

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

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

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

374
        wait_for_requests
P
Phil Hughes 已提交
375

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

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

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

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

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

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

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

411
        wait_for_requests
412

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

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

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

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

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

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

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

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

446
        wait_for_requests
P
Phil Hughes 已提交
447

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

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

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

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

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

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

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

        submit_filter
P
Phil Hughes 已提交
473

474
        wait_for_requests
P
Phil Hughes 已提交
475

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

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

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

492
        wait_for_requests
493

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

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

504
          wait_for_requests
505 506 507 508

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

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

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

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

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

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

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

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

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

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

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

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

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

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