gitlab-org--gitlab-foss/spec/features/boards/boards_spec.rb

555 lines
18 KiB
Ruby
Raw Normal View History

2016-08-03 07:42:26 +00:00
require 'rails_helper'
describe 'Issue Boards', feature: true, js: true do
include WaitForAjax
2016-08-16 19:22:22 +00:00
let(:project) { create(:empty_project) }
2016-08-03 07:42:26 +00:00
let(:user) { create(:user) }
2016-08-16 19:22:22 +00:00
let(:user2) { create(:user) }
2016-08-03 07:42:26 +00:00
before do
2016-08-16 19:22:22 +00:00
project.create_board!
2016-08-16 16:59:02 +00:00
create(:backlog_list, board: project.board)
create(:done_list, board: project.board)
2016-08-03 07:42:26 +00:00
project.team << [user, :master]
2016-08-10 08:10:50 +00:00
project.team << [user2, :master]
2016-08-03 07:42:26 +00:00
login_as(user)
end
2016-08-09 15:53:56 +00:00
context 'no lists' do
before do
visit namespace_project_board_path(project.namespace, project)
2016-08-16 16:32:38 +00:00
wait_for_vue_resource
expect(page).to have_selector('.board', count: 3)
2016-08-09 15:53:56 +00:00
end
2016-08-03 07:42:26 +00:00
2016-08-09 15:53:56 +00:00
it 'shows blank state' do
expect(page).to have_content('Welcome to your Issue Board!')
2016-08-03 07:42:26 +00:00
end
it 'hides the blank state when clicking nevermind button' do
2016-08-16 11:57:59 +00:00
page.within(find('.board-blank-state')) do
2016-08-15 07:36:37 +00:00
click_button("Nevermind, I'll use my own")
2016-08-09 15:53:56 +00:00
end
expect(page).to have_selector('.board', count: 2)
2016-08-03 07:42:26 +00:00
end
2016-08-09 15:53:56 +00:00
it 'creates default lists' do
lists = ['Backlog', 'Development', 'Testing', 'Production', 'Ready', 'Done']
2016-08-03 07:42:26 +00:00
2016-08-16 11:57:59 +00:00
page.within(find('.board-blank-state')) do
2016-08-09 15:53:56 +00:00
click_button('Add default lists')
end
2016-08-16 11:57:59 +00:00
wait_for_vue_resource
2016-08-09 15:53:56 +00:00
expect(page).to have_selector('.board', count: 6)
page.all('.board').each_with_index do |list, i|
expect(list.find('.board-title')).to have_content(lists[i])
end
end
2016-08-03 07:42:26 +00:00
end
2016-08-09 15:53:56 +00:00
context 'with lists' do
2016-08-11 13:41:44 +00:00
let(:milestone) { create(:milestone, project: project) }
2016-08-10 08:10:50 +00:00
2016-08-09 15:53:56 +00:00
let(:planning) { create(:label, project: project, name: 'Planning') }
let(:development) { create(:label, project: project, name: 'Development') }
let(:testing) { create(:label, project: project, name: 'Testing') }
2016-08-10 08:10:50 +00:00
let(:bug) { create(:label, project: project, name: 'Bug') }
let!(:backlog) { create(:label, project: project, name: 'Backlog') }
let!(:done) { create(:label, project: project, name: 'Done') }
2016-08-09 15:53:56 +00:00
let!(:list1) { create(:list, board: project.board, label: planning, position: 0) }
let!(:list2) { create(:list, board: project.board, label: development, position: 1) }
let!(:confidential_issue) { create(:issue, :confidential, project: project, author: user) }
let!(:issue1) { create(:issue, project: project, assignee: user) }
let!(:issue2) { create(:issue, project: project, author: user2) }
let!(:issue3) { create(:issue, project: project) }
let!(:issue4) { create(:issue, project: project) }
2016-08-10 08:10:50 +00:00
let!(:issue5) { create(:labeled_issue, project: project, labels: [planning], milestone: milestone) }
let!(:issue6) { create(:labeled_issue, project: project, labels: [planning, development]) }
let!(:issue7) { create(:labeled_issue, project: project, labels: [development]) }
let!(:issue8) { create(:closed_issue, project: project) }
let!(:issue9) { create(:labeled_issue, project: project, labels: [testing, bug]) }
2016-08-09 15:53:56 +00:00
before do
visit namespace_project_board_path(project.namespace, project)
2016-08-16 10:34:32 +00:00
wait_for_vue_resource
2016-08-16 16:32:38 +00:00
expect(page).to have_selector('.board', count: 4)
has_issues
2016-08-09 15:53:56 +00:00
end
it 'shows lists' do
expect(page).to have_selector('.board', count: 4)
end
it 'shows issues in lists' do
2016-08-16 11:57:59 +00:00
page.within(find('.board:nth-child(2)')) do
expect(page.find('.board-header')).to have_content('2')
expect(page).to have_selector('.card', count: 2)
2016-08-09 15:53:56 +00:00
end
2016-08-03 07:42:26 +00:00
2016-08-16 11:57:59 +00:00
page.within(find('.board:nth-child(3)')) do
2016-08-09 15:53:56 +00:00
expect(page.find('.board-header')).to have_content('2')
expect(page).to have_selector('.card', count: 2)
end
end
2016-08-03 07:42:26 +00:00
it 'shows confidential issues with icon' do
2016-08-16 11:57:59 +00:00
page.within(find('.board', match: :first)) do
expect(page).to have_selector('.confidential-icon', count: 1)
end
end
2016-08-09 15:53:56 +00:00
it 'allows user to delete board' do
2016-08-16 11:57:59 +00:00
page.within(find('.board:nth-child(2)')) do
2016-08-09 15:53:56 +00:00
find('.board-delete').click
2016-08-03 07:42:26 +00:00
end
2016-08-16 11:57:59 +00:00
wait_for_vue_resource
2016-08-09 15:53:56 +00:00
expect(page).to have_selector('.board', count: 3)
2016-08-03 07:42:26 +00:00
end
it 'removes checkmark in new list dropdown after deleting' do
click_button 'Create new list'
wait_for_ajax
2016-08-16 11:57:59 +00:00
page.within(find('.board:nth-child(2)')) do
find('.board-delete').click
end
2016-08-16 11:57:59 +00:00
wait_for_vue_resource
expect(page).to have_selector('.board', count: 3)
expect(find(".js-board-list-#{planning.id}", visible: false)).not_to have_css('.is-active')
end
it 'infinite scrolls list' do
50.times do
create(:issue, project: project)
end
visit namespace_project_board_path(project.namespace, project)
2016-08-16 10:34:32 +00:00
wait_for_vue_resource
2016-08-16 11:57:59 +00:00
page.within(find('.board', match: :first)) do
expect(page.find('.board-header')).to have_content('20')
expect(page).to have_selector('.card', count: 20)
evaluate_script("document.querySelectorAll('.board .board-list')[0].scrollTop = document.querySelectorAll('.board .board-list')[0].scrollHeight")
expect(page.find('.board-header')).to have_content('40')
expect(page).to have_selector('.card', count: 40)
end
end
2016-08-09 15:53:56 +00:00
context 'backlog' do
it 'shows issues in backlog with no labels' do
2016-08-16 11:57:59 +00:00
page.within(find('.board', match: :first)) do
expect(page.find('.board-header')).to have_content('6')
expect(page).to have_selector('.card', count: 6)
2016-08-09 15:53:56 +00:00
end
end
it 'is searchable' do
2016-08-16 11:57:59 +00:00
page.within(find('.board', match: :first)) do
2016-08-09 15:53:56 +00:00
find('.form-control').set issue1.title
expect(page).to have_selector('.card', count: 1)
end
end
it 'clears search' do
2016-08-16 11:57:59 +00:00
page.within(find('.board', match: :first)) do
2016-08-09 15:53:56 +00:00
find('.form-control').set issue1.title
expect(page).to have_selector('.card', count: 1)
find('.board-search-clear-btn').click
expect(page).to have_selector('.card', count: 6)
2016-08-09 15:53:56 +00:00
end
end
it 'moves issue from backlog into list' do
drag_to(list_to_index: 1)
2016-08-03 07:42:26 +00:00
2016-08-16 11:57:59 +00:00
page.within(find('.board', match: :first)) do
expect(page.find('.board-header')).to have_content('5')
expect(page).to have_selector('.card', count: 5)
2016-08-09 15:53:56 +00:00
end
2016-08-03 07:42:26 +00:00
2016-08-16 11:57:59 +00:00
page.within(find('.board:nth-child(2)')) do
expect(page.find('.board-header')).to have_content('3')
expect(page).to have_selector('.card', count: 3)
2016-08-09 15:53:56 +00:00
end
2016-08-03 07:42:26 +00:00
end
end
2016-08-09 15:53:56 +00:00
context 'done' do
it 'shows list of done issues' do
2016-08-16 11:57:59 +00:00
expect(find('.board:nth-child(4)')).to have_selector('.card', count: 1)
2016-08-09 15:53:56 +00:00
end
it 'moves issue to done' do
drag_to(list_from_index: 0, list_to_index: 3)
2016-08-16 11:57:59 +00:00
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)
2016-08-09 15:53:56 +00:00
end
it 'removes all of the same issue to done' do
drag_to(list_from_index: 1, list_to_index: 3)
2016-08-16 11:57:59 +00:00
expect(find('.board:nth-child(2)')).to have_selector('.card', count: 1)
expect(find('.board:nth-child(3)')).to have_selector('.card', count: 1)
expect(find('.board:nth-child(4)')).to have_content(issue6.title)
expect(find('.board:nth-child(4)')).not_to have_content(planning.title)
2016-08-09 15:53:56 +00:00
end
end
context 'lists' do
2016-08-10 08:10:50 +00:00
it 'changes position of list' do
2016-08-16 16:32:38 +00:00
drag_to(list_from_index: 1, list_to_index: 2, selector: '.board-header')
2016-08-10 08:10:50 +00:00
2016-08-16 11:57:59 +00:00
expect(find('.board:nth-child(2)')).to have_content(development.title)
expect(find('.board:nth-child(2)')).to have_content(planning.title)
2016-08-10 08:10:50 +00:00
end
2016-08-16 11:57:59 +00:00
it 'issue moves between lists' do
drag_to(list_from_index: 1, card_index: 1, list_to_index: 2)
2016-08-09 15:53:56 +00:00
2016-08-16 11:57:59 +00:00
expect(find('.board:nth-child(2)')).to have_selector('.card', count: 1)
expect(find('.board:nth-child(3)')).to have_selector('.card', count: 3)
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)
2016-08-09 15:53:56 +00:00
end
2016-08-16 11:57:59 +00:00
it 'issue moves between lists' do
2016-08-09 15:53:56 +00:00
drag_to(list_from_index: 2, list_to_index: 1)
2016-08-16 11:57:59 +00:00
expect(find('.board:nth-child(2)')).to have_selector('.card', count: 3)
expect(find('.board:nth-child(3)')).to have_selector('.card', count: 1)
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)
2016-08-09 15:53:56 +00:00
end
2016-08-16 11:57:59 +00:00
it 'issue moves from done' do
2016-08-09 15:53:56 +00:00
drag_to(list_from_index: 3, list_to_index: 1)
2016-08-16 11:57:59 +00:00
expect(find('.board:nth-child(2)')).to have_selector('.card', count: 3)
expect(find('.board:nth-child(2)')).to have_content(issue8.title)
2016-08-09 15:53:56 +00:00
end
context 'issue card' do
it 'shows assignee' do
2016-08-16 11:57:59 +00:00
page.within(find('.board', match: :first)) do
expect(page).to have_selector('.avatar', count: 1)
2016-08-09 15:53:56 +00:00
end
end
end
context 'new list' do
it 'shows all labels in new list dropdown' do
click_button 'Create new list'
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
click_button 'Create new list'
page.within('.dropdown-menu-issues-board-new') do
click_link testing.title
end
expect(page).to have_selector('.board', count: 5)
end
it 'creates new list for Backlog label' do
click_button 'Create new list'
page.within('.dropdown-menu-issues-board-new') do
click_link backlog.title
end
expect(page).to have_selector('.board', count: 5)
end
it 'creates new list for Done label' do
click_button 'Create new list'
page.within('.dropdown-menu-issues-board-new') do
click_link done.title
end
expect(page).to have_selector('.board', count: 5)
end
2016-08-09 15:53:56 +00:00
it 'moves issues from backlog into new list' do
2016-08-16 11:57:59 +00:00
page.within(find('.board', match: :first)) do
expect(page.find('.board-header')).to have_content('6')
expect(page).to have_selector('.card', count: 6)
2016-08-09 15:53:56 +00:00
end
click_button 'Create new list'
page.within('.dropdown-menu-issues-board-new') do
click_link testing.title
end
2016-08-16 11:57:59 +00:00
page.within(find('.board', match: :first)) do
expect(page.find('.board-header')).to have_content('5')
expect(page).to have_selector('.card', count: 5)
2016-08-09 15:53:56 +00:00
end
end
end
end
context 'filtering' do
2016-08-10 08:10:50 +00:00
it 'filters by author' do
page.within '.issues-filters' do
click_button('Author')
page.within '.dropdown-menu-author' do
click_link(user2.name)
end
expect(find('.js-author-search')).to have_content(user2.name)
end
2016-08-16 10:34:32 +00:00
wait_for_vue_resource
2016-08-16 11:57:59 +00:00
page.within(find('.board', match: :first)) do
2016-08-10 08:10:50 +00:00
expect(page.find('.board-header')).to have_content('1')
expect(page).to have_selector('.card', count: 1)
end
2016-08-16 11:57:59 +00:00
page.within(find('.board:nth-child(2)')) do
2016-08-10 08:10:50 +00:00
expect(page.find('.board-header')).to have_content('0')
expect(page).to have_selector('.card', count: 0)
end
end
it 'filters by assignee' do
page.within '.issues-filters' do
click_button('Assignee')
page.within '.dropdown-menu-assignee' do
click_link(user.name)
end
expect(find('.js-assignee-search')).to have_content(user.name)
end
2016-08-16 10:34:32 +00:00
wait_for_vue_resource
2016-08-16 11:57:59 +00:00
page.within(find('.board', match: :first)) do
2016-08-10 08:10:50 +00:00
expect(page.find('.board-header')).to have_content('1')
expect(page).to have_selector('.card', count: 1)
end
2016-08-16 11:57:59 +00:00
page.within(find('.board:nth-child(2)')) do
2016-08-10 08:10:50 +00:00
expect(page.find('.board-header')).to have_content('0')
expect(page).to have_selector('.card', count: 0)
end
end
it 'filters by milestone' do
page.within '.issues-filters' do
click_button('Milestone')
2016-08-10 08:10:50 +00:00
page.within '.milestone-filter' do
click_link(milestone.title)
end
expect(find('.js-milestone-select')).to have_content(milestone.title)
end
2016-08-16 10:34:32 +00:00
wait_for_vue_resource
2016-08-16 11:57:59 +00:00
page.within(find('.board', match: :first)) do
2016-08-10 08:10:50 +00:00
expect(page.find('.board-header')).to have_content('0')
expect(page).to have_selector('.card', count: 0)
end
2016-08-16 11:57:59 +00:00
page.within(find('.board:nth-child(2)')) do
2016-08-10 08:10:50 +00:00
expect(page.find('.board-header')).to have_content('1')
expect(page).to have_selector('.card', count: 1)
end
end
it 'filters by label' do
page.within '.issues-filters' do
click_button('Label')
page.within '.dropdown-menu-labels' do
click_link(testing.title)
find('.dropdown-menu-close').click
end
end
2016-08-16 10:34:32 +00:00
wait_for_vue_resource
2016-08-16 11:57:59 +00:00
page.within(find('.board', match: :first)) do
2016-08-10 08:10:50 +00:00
expect(page.find('.board-header')).to have_content('1')
expect(page).to have_selector('.card', count: 1)
end
2016-08-16 11:57:59 +00:00
page.within(find('.board:nth-child(2)')) do
2016-08-10 08:10:50 +00:00
expect(page.find('.board-header')).to have_content('0')
expect(page).to have_selector('.card', count: 0)
end
end
it 'infinite scrolls list with label filter' do
50.times do
create(:labeled_issue, project: project, labels: [testing])
end
page.within '.issues-filters' do
click_button('Label')
page.within '.dropdown-menu-labels' do
click_link(testing.title)
find('.dropdown-menu-close').click
end
end
2016-08-16 10:34:32 +00:00
wait_for_vue_resource
2016-08-16 11:57:59 +00:00
page.within(find('.board', match: :first)) do
expect(page.find('.board-header')).to have_content('20')
expect(page).to have_selector('.card', count: 20)
evaluate_script("document.querySelectorAll('.board .board-list')[0].scrollTop = document.querySelectorAll('.board .board-list')[0].scrollHeight")
expect(page.find('.board-header')).to have_content('40')
expect(page).to have_selector('.card', count: 40)
end
end
2016-08-10 08:10:50 +00:00
it 'filters by multiple labels' do
page.within '.issues-filters' do
click_button('Label')
page.within '.dropdown-menu-labels' do
click_link(testing.title)
click_link(bug.title)
find('.dropdown-menu-close').click
end
end
2016-08-16 10:34:32 +00:00
wait_for_vue_resource
2016-08-16 11:57:59 +00:00
page.within(find('.board', match: :first)) do
expect(page.find('.board-header')).to have_content('1')
expect(page).to have_selector('.card', count: 1)
2016-08-10 08:10:50 +00:00
end
2016-08-16 11:57:59 +00:00
page.within(find('.board:nth-child(2)')) do
2016-08-10 08:10:50 +00:00
expect(page.find('.board-header')).to have_content('0')
expect(page).to have_selector('.card', count: 0)
end
end
it 'filters by no label' do
page.within '.issues-filters' do
click_button('Label')
2016-08-09 15:53:56 +00:00
2016-08-10 08:10:50 +00:00
page.within '.dropdown-menu-labels' do
click_link("No Label")
find('.dropdown-menu-close').click
end
end
2016-08-16 10:34:32 +00:00
wait_for_vue_resource
2016-08-16 11:57:59 +00:00
page.within(find('.board', match: :first)) do
expect(page.find('.board-header')).to have_content('5')
expect(page).to have_selector('.card', count: 5)
2016-08-10 08:10:50 +00:00
end
2016-08-16 11:57:59 +00:00
page.within(find('.board:nth-child(2)')) do
2016-08-10 08:10:50 +00:00
expect(page.find('.board-header')).to have_content('0')
expect(page).to have_selector('.card', count: 0)
end
end
it 'filters by clicking label button on issue' do
page.within '.issues-filters' do
click_button('Label')
page.within '.dropdown-menu-labels' do
click_link(bug.title)
find('.dropdown-menu-close').click
end
end
2016-08-16 10:34:32 +00:00
wait_for_vue_resource
2016-08-16 11:57:59 +00:00
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
2016-08-16 11:57:59 +00:00
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
2016-08-16 11:57:59 +00:00
page.within(find('.board', match: :first)) do
click_button(bug.title)
expect(page).to have_selector('.card', count: 6)
end
page.within('.labels-filter') do
expect(find('.dropdown-toggle-text')).not_to have_content(bug.title)
end
end
it 'removes label filter by clicking label button on issue' do
2016-08-16 11:57:59 +00:00
page.within(find('.board', match: :first)) do
page.within(find('.card', match: :first)) do
click_button(bug.title)
end
expect(page).to have_selector('.card', count: 1)
end
2016-08-16 10:34:32 +00:00
wait_for_vue_resource
page.within('.labels-filter') do
expect(find('.dropdown-toggle-text')).to have_content(bug.title)
end
end
2016-08-03 07:42:26 +00:00
end
end
2016-08-16 11:57:59 +00:00
def has_issues
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')
expect(find('.board:nth-child(4)')).to have_selector('.card')
end
2016-08-10 08:10:50 +00:00
def drag_to(list_from_index: 0, card_index: 0, to_index: 0, list_to_index: 0, selector: '.board-list')
evaluate_script("simulateDrag({scrollable: document.getElementById('board-app'), from: {el: $('#{selector}').eq(#{list_from_index}).get(0), index: #{card_index}}, to: {el: $('.board-list').eq(#{list_to_index}).get(0), index: #{to_index}}});")
2016-08-03 07:42:26 +00:00
end
2016-08-16 10:34:32 +00:00
def wait_for_vue_resource
2016-08-16 16:32:38 +00:00
expect(find('.boards-list')).not_to have_selector('.fa-spinner')
2016-08-16 10:34:32 +00:00
end
2016-08-03 07:42:26 +00:00
end