boards_spec.rb 1.9 KB
Newer Older
P
Phil Hughes 已提交
1 2 3 4 5 6 7 8 9 10
require 'rails_helper'

describe 'Issue Boards', feature: true, js: true do
  let(:project)   { create(:project) }
  let(:user)      { create(:user) }

  before do
    project.team << [user, :master]
    login_as(user)

P
Phil Hughes 已提交
11
    visit namespace_project_board_path(project.namespace, project)
P
Phil Hughes 已提交
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
  end

  it 'shows default lists' do
    lists = all('.board')

    page.within lists.first do
      expect(page).to have_content 'Backlog'
    end

    page.within lists.last do
      expect(page).to have_content 'Done'
    end
  end

  it 'removes blank state list' do
    click_button 'Nevermind, i\'ll use my own'

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

  it 'can drag card to new list' do
    sleep 0.5
    lists = all('.board')
    drag_to(list_from_index: 0, list_to_index: 1)

    page.within lists[1].find('.board-list') do
      expect(page).to have_content('Test')
      expect(page).to have_selector('.card', count: 2)

      page.within first('.card .card-footer') do
        expect(page).to have_content 'Frontend'
      end
    end
  end

  it 'removes all labels from card' do
    sleep 0.5
    lists = all('.board')
    drag_to(list_from_index: 1, list_to_index: 3)

    page.within lists[3].find('.board-list') do
      expect(page).to have_content('Frontend bug')
      expect(page).to have_selector('.card', count: 2)

      page.within first('.card .card-footer') do
        expect(page).not_to have_content 'Frontend'
      end
    end

    page.within lists[1].find('.board-list') do
      expect(page).not_to have_content('Frontend bug')
      expect(page).not_to have_selector('.card')
    end
  end

  def drag_to(list_from_index: 0, card_index: 0, to_index: 0, list_to_index: 0)
    evaluate_script("simulateDrag({scrollable: document.getElementById('board-app'), from: {el: $('.board-list').eq(#{list_from_index}).get(0), index: #{card_index}}, to: {el: $('.board-list').eq(#{list_to_index}).get(0), index: #{to_index}}});")
    sleep 1
  end
end