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

630 lines
20 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
require 'spec_helper'
2016-08-03 03:42:26 -04:00
describe 'Issue Boards', :js do
2017-01-06 11:52:18 -05:00
include DragTo
2017-11-02 16:45:46 -04:00
include MobileHelpers
let(:group) { create(:group, :nested) }
let(:project) { create(:project, :public, namespace: group) }
let(:board) { create(:board, project: project) }
2016-08-16 15:45:07 -04:00
let(:user) { create(:user) }
let!(:user2) { create(:user) }
2016-08-03 03:42:26 -04:00
before do
project.add_maintainer(user)
project.add_maintainer(user2)
2016-08-16 15:45:07 -04:00
2017-09-22 14:15:43 -04:00
set_cookie('sidebar_collapsed', 'true')
2017-08-29 10:45:18 -04:00
sign_in(user)
2016-08-03 03:42:26 -04:00
end
2016-08-09 11:53:56 -04:00
context 'no lists' do
before do
visit project_board_path(project, board)
wait_for_requests
2017-06-01 06:11:02 -04:00
expect(page).to have_selector('.board', count: 3)
2016-08-09 11:53:56 -04:00
end
2016-08-03 03:42:26 -04:00
2016-08-09 11:53:56 -04:00
it 'shows blank state' do
expect(page).to have_content('Welcome to your Issue Board!')
2016-08-03 03:42:26 -04:00
end
2017-02-10 11:38:11 -05:00
it 'shows tooltip on add issues button' do
button = page.find('.filter-dropdown-container button', text: 'Add issues')
2017-02-10 11:38:11 -05:00
expect(button[:"data-original-title"]).to eq("Please add a list to your board first")
end
it 'hides the blank state when clicking nevermind button' do
2016-08-16 07:57:59 -04:00
page.within(find('.board-blank-state')) do
2016-08-15 03:36:37 -04:00
click_button("Nevermind, I'll use my own")
2016-08-09 11:53:56 -04:00
end
2017-06-01 06:11:02 -04:00
expect(page).to have_selector('.board', count: 2)
2016-08-03 03:42:26 -04:00
end
2016-08-09 11:53:56 -04:00
it 'creates default lists' do
2018-08-10 06:41:09 -04:00
lists = ['Open', 'To Do', 'Doing', 'Closed']
2016-08-03 03:42:26 -04:00
2016-08-16 07:57:59 -04:00
page.within(find('.board-blank-state')) do
2016-08-09 11:53:56 -04:00
click_button('Add default lists')
end
wait_for_requests
2016-08-16 07:57:59 -04:00
2017-06-01 06:11:02 -04:00
expect(page).to have_selector('.board', count: 4)
2016-08-09 11:53:56 -04:00
page.all('.board').each_with_index do |list, i|
expect(list.find('.board-title')).to have_content(lists[i])
end
end
2016-08-03 03:42:26 -04:00
end
2016-08-09 11:53:56 -04:00
context 'with lists' do
2016-08-16 15:45:07 -04:00
let(:milestone) { create(:milestone, project: project) }
2016-08-10 04:10:50 -04:00
let(:planning) { create(:label, project: project, name: 'Planning', description: 'Test') }
2016-08-09 11:53:56 -04:00
let(:development) { create(:label, project: project, name: 'Development') }
let(:testing) { create(:label, project: project, name: 'Testing') }
2016-08-10 04:10:50 -04:00
let(:bug) { create(:label, project: project, name: 'Bug') }
let!(:backlog) { create(:label, project: project, name: 'Backlog') }
let!(:closed) { create(:label, project: project, name: 'Closed') }
let!(:accepting) { create(:label, project: project, name: 'Accepting Merge Requests') }
let!(:a_plus) { create(:label, project: project, name: 'A+') }
2016-08-09 11:53:56 -04:00
2016-10-10 22:29:20 -04:00
let!(:list1) { create(:list, board: board, label: planning, position: 0) }
let!(:list2) { create(:list, board: board, label: development, position: 1) }
2016-08-09 11:53:56 -04:00
2017-03-01 06:18:58 -05:00
let!(:confidential_issue) { create(:labeled_issue, :confidential, project: project, author: user, labels: [planning], relative_position: 9) }
2017-08-30 10:37:23 -04:00
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) }
let!(:issue10) { create(:labeled_issue, project: project, title: 'issue +', description: 'A+ great issue', labels: [a_plus]) }
2016-08-09 11:53:56 -04:00
before do
visit project_board_path(project, board)
2016-08-09 11:53:56 -04:00
wait_for_requests
2016-08-16 12:32:38 -04:00
2017-06-01 06:11:02 -04:00
expect(page).to have_selector('.board', count: 4)
expect(find('.board:nth-child(2)')).to have_selector('.board-card')
expect(find('.board:nth-child(3)')).to have_selector('.board-card')
expect(find('.board:nth-child(4)')).to have_selector('.board-card')
2016-08-09 11:53:56 -04:00
end
it 'shows description tooltip on list title', :quarantine do
2017-06-01 06:11:02 -04:00
page.within('.board:nth-child(2)') do
expect(find('.board-title span.has-tooltip')[:title]).to eq('Test')
end
end
2016-08-09 11:53:56 -04:00
it 'shows issues in lists' do
2017-06-01 06:11:02 -04:00
wait_for_board_cards(2, 8)
wait_for_board_cards(3, 2)
2016-08-09 11:53:56 -04:00
end
2016-08-03 03:42:26 -04:00
it 'shows confidential issues with icon' do
2017-06-01 06:11:02 -04:00
page.within(find('.board:nth-child(2)')) do
expect(page).to have_selector('.confidential-icon', count: 1)
end
end
it 'search closed list' do
find('.filtered-search').set(issue8.title)
find('.filtered-search').native.send_keys(:enter)
wait_for_requests
expect(find('.board:nth-child(2)')).to have_selector('.board-card', count: 0)
expect(find('.board:nth-child(3)')).to have_selector('.board-card', count: 0)
expect(find('.board:nth-child(4)')).to have_selector('.board-card', count: 1)
end
it 'search list' do
find('.filtered-search').set(issue5.title)
find('.filtered-search').native.send_keys(:enter)
wait_for_requests
expect(find('.board:nth-child(2)')).to have_selector('.board-card', count: 1)
expect(find('.board:nth-child(3)')).to have_selector('.board-card', count: 0)
expect(find('.board:nth-child(4)')).to have_selector('.board-card', count: 0)
end
2016-08-09 11:53:56 -04:00
it 'allows user to delete board' do
2017-06-01 06:11:02 -04:00
page.within(find('.board:nth-child(2)')) do
accept_confirm { find('.board-delete').click }
2016-08-03 03:42:26 -04:00
end
2016-08-16 07:57:59 -04:00
wait_for_requests
2016-08-16 07:57:59 -04:00
2017-06-01 06:11:02 -04:00
expect(page).to have_selector('.board', count: 3)
2016-08-03 03:42:26 -04:00
end
it 'removes checkmark in new list dropdown after deleting' do
click_button 'Add list'
wait_for_requests
find('.js-new-board-list').click
2017-08-17 04:51:19 -04:00
2017-06-01 06:11:02 -04:00
page.within(find('.board:nth-child(2)')) do
accept_confirm { find('.board-delete').click }
end
2016-08-16 15:45:07 -04:00
wait_for_requests
2017-06-01 06:11:02 -04:00
expect(page).to have_selector('.board', count: 3)
end
it 'infinite scrolls list' do
50.times do
create(:labeled_issue, project: project, labels: [planning])
end
visit project_board_path(project, board)
wait_for_requests
2017-06-01 06:11:02 -04:00
page.within(find('.board:nth-child(2)')) do
expect(page.find('.board-header')).to have_content('58')
expect(page).to have_selector('.board-card', count: 20)
expect(page).to have_content('Showing 20 of 58 issues')
find('.board .board-list')
2017-06-01 06:11:02 -04:00
evaluate_script("document.querySelectorAll('.board .board-list')[1].scrollTop = document.querySelectorAll('.board .board-list')[1].scrollHeight")
wait_for_requests
expect(page).to have_selector('.board-card', count: 40)
expect(page).to have_content('Showing 40 of 58 issues')
find('.board .board-list')
2017-06-01 06:11:02 -04:00
evaluate_script("document.querySelectorAll('.board .board-list')[1].scrollTop = document.querySelectorAll('.board .board-list')[1].scrollHeight")
wait_for_requests
expect(page).to have_selector('.board-card', count: 58)
expect(page).to have_content('Showing all issues')
end
end
context 'closed' do
it 'shows list of closed issues' do
2017-06-01 06:11:02 -04:00
wait_for_board_cards(4, 1)
wait_for_requests
2016-08-09 11:53:56 -04:00
end
it 'moves issue to closed' do
2017-06-01 06:11:02 -04:00
drag(list_from_index: 1, list_to_index: 3)
2016-08-09 11:53:56 -04:00
2017-06-01 06:11:02 -04:00
wait_for_board_cards(2, 7)
wait_for_board_cards(3, 2)
2017-06-01 06:11:02 -04:00
wait_for_board_cards(4, 2)
2017-06-01 06:11:02 -04:00
expect(find('.board:nth-child(2)')).not_to have_content(issue9.title)
expect(find('.board:nth-child(4)')).to have_selector('.board-card', count: 2)
2017-06-01 06:11:02 -04:00
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 11:53:56 -04:00
end
it 'removes all of the same issue to closed' do
2017-06-01 06:11:02 -04:00
drag(list_from_index: 1, list_to_index: 3)
2016-08-09 11:53:56 -04:00
2017-06-01 06:11:02 -04:00
wait_for_board_cards(2, 7)
wait_for_board_cards(3, 2)
2017-06-01 06:11:02 -04:00
wait_for_board_cards(4, 2)
2017-06-01 06:11:02 -04:00
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)
2016-08-09 11:53:56 -04:00
end
end
context 'lists' do
2016-08-10 04:10:50 -04:00
it 'changes position of list' do
2017-06-01 06:11:02 -04:00
drag(list_from_index: 2, list_to_index: 1, selector: '.board-header')
2016-08-10 04:10:50 -04:00
2017-06-01 06:11:02 -04:00
wait_for_board_cards(2, 2)
wait_for_board_cards(3, 8)
wait_for_board_cards(4, 1)
2017-06-01 06:11:02 -04: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 04:10:50 -04:00
end
it 'dragging does not duplicate list' do
selector = '.board:not(.is-ghost) .board-header'
expect(page).to have_selector(selector, text: development.title, count: 1)
drag(list_from_index: 2, list_to_index: 1, selector: '.board-header', perform_drop: false)
expect(page).to have_selector(selector, text: development.title, count: 1)
end
2016-08-16 07:57:59 -04:00
it 'issue moves between lists' do
2017-06-01 06:11:02 -04:00
drag(list_from_index: 1, from_index: 1, list_to_index: 2)
2016-08-09 11:53:56 -04:00
2017-06-01 06:11:02 -04:00
wait_for_board_cards(2, 7)
wait_for_board_cards(3, 2)
wait_for_board_cards(4, 1)
2017-06-01 06:11:02 -04:00
expect(find('.board:nth-child(3)')).to have_content(issue6.title)
expect(find('.board:nth-child(3)').all('.board-card').last).to have_content(development.title)
2016-08-09 11:53:56 -04:00
end
2016-08-16 07:57:59 -04:00
it 'issue moves between lists' do
2017-06-01 06:11:02 -04:00
drag(list_from_index: 2, list_to_index: 1)
2016-08-09 11:53:56 -04:00
2017-06-01 06:11:02 -04:00
wait_for_board_cards(2, 9)
wait_for_board_cards(3, 1)
2017-06-01 06:11:02 -04:00
wait_for_board_cards(4, 1)
2017-06-01 06:11:02 -04:00
expect(find('.board:nth-child(2)')).to have_content(issue7.title)
expect(find('.board:nth-child(2)').all('.board-card').first).to have_content(planning.title)
2016-08-09 11:53:56 -04:00
end
it 'issue moves from closed' do
drag(list_from_index: 2, list_to_index: 3)
2016-08-09 11:53:56 -04:00
2017-06-01 06:11:02 -04:00
wait_for_board_cards(2, 8)
wait_for_board_cards(3, 1)
wait_for_board_cards(4, 2)
expect(find('.board:nth-child(4)')).to have_content(issue8.title)
2016-08-09 11:53:56 -04:00
end
context 'issue card' do
it 'shows assignee' do
2017-06-01 06:11:02 -04:00
page.within(find('.board:nth-child(2)')) do
expect(page).to have_selector('.avatar', count: 1)
2016-08-09 11:53:56 -04:00
end
end
end
context 'new list' do
it 'shows all labels in new list dropdown' do
click_button 'Add list'
wait_for_requests
2016-08-09 11:53:56 -04:00
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 'Add list'
wait_for_requests
2016-08-09 11:53:56 -04:00
page.within('.dropdown-menu-issues-board-new') do
click_link testing.title
end
wait_for_requests
2016-08-16 15:45:07 -04:00
2017-06-01 06:11:02 -04:00
expect(page).to have_selector('.board', count: 5)
2016-08-09 11:53:56 -04:00
end
it 'creates new list for Backlog label' do
click_button 'Add list'
wait_for_requests
page.within('.dropdown-menu-issues-board-new') do
click_link backlog.title
end
wait_for_requests
2016-08-16 15:45:07 -04:00
2017-06-01 06:11:02 -04:00
expect(page).to have_selector('.board', count: 5)
end
it 'creates new list for Closed label' do
click_button 'Add list'
wait_for_requests
page.within('.dropdown-menu-issues-board-new') do
click_link closed.title
end
wait_for_requests
2016-08-16 15:45:07 -04:00
2017-06-01 06:11:02 -04:00
expect(page).to have_selector('.board', count: 5)
end
it 'keeps dropdown open after adding new list' do
click_button 'Add list'
wait_for_requests
page.within('.dropdown-menu-issues-board-new') do
click_link closed.title
end
wait_for_requests
2018-04-23 20:32:30 -04:00
expect(page).to have_css('#js-add-list.show')
end
it 'creates new list from a new label' do
click_button 'Add list'
wait_for_requests
click_link 'Create project label'
fill_in('new_label_name', with: 'Testing New Label - with list')
first('.suggest-colors a').click
click_button 'Create'
wait_for_requests
wait_for_requests
2017-06-01 06:11:02 -04:00
expect(page).to have_selector('.board', count: 5)
end
2016-08-09 11:53:56 -04:00
end
end
context 'filtering' do
2016-08-10 04:10:50 -04:00
it 'filters by author' do
2017-03-08 07:17:01 -05:00
set_filter("author", user2.username)
click_filter_link(user2.username)
submit_filter
2016-08-10 04:10:50 -04:00
wait_for_requests
2017-06-01 06:11:02 -04:00
wait_for_board_cards(2, 1)
wait_for_empty_boards((3..4))
2016-08-10 04:10:50 -04:00
end
it 'filters by assignee' do
2017-03-08 07:17:01 -05:00
set_filter("assignee", user.username)
click_filter_link(user.username)
submit_filter
2016-08-10 04:10:50 -04:00
wait_for_requests
2016-08-16 06:34:32 -04:00
2017-06-01 06:11:02 -04:00
wait_for_board_cards(2, 1)
wait_for_empty_boards((3..4))
2016-08-10 04:10:50 -04:00
end
it 'filters by milestone' do
set_filter("milestone", "\"#{milestone.title}")
2017-03-08 07:17:01 -05:00
click_filter_link(milestone.title)
submit_filter
2016-08-10 04:10:50 -04:00
wait_for_requests
2017-06-01 06:11:02 -04:00
wait_for_board_cards(2, 1)
wait_for_board_cards(3, 0)
2017-06-01 06:11:02 -04:00
wait_for_board_cards(4, 0)
2016-08-10 04:10:50 -04:00
end
it 'filters by label' do
2017-03-08 07:17:01 -05:00
set_filter("label", testing.title)
click_filter_link(testing.title)
submit_filter
2016-08-10 04:10:50 -04:00
wait_for_requests
2017-06-01 06:11:02 -04:00
wait_for_board_cards(2, 1)
wait_for_empty_boards((3..4))
2016-08-10 04:10:50 -04:00
end
it 'filters by label with encoded character' do
set_filter("label", a_plus.title)
click_filter_link(a_plus.title)
submit_filter
wait_for_board_cards(1, 1)
wait_for_empty_boards((2..4))
end
it 'filters by label with space after reload', :quarantine do
set_filter("label", "\"#{accepting.title}")
2017-03-08 07:17:01 -05:00
click_filter_link(accepting.title)
submit_filter
# Test after reload
page.evaluate_script 'window.location.reload()'
2017-06-01 06:11:02 -04:00
wait_for_board_cards(2, 1)
wait_for_empty_boards((3..4))
wait_for_requests
2017-06-01 06:11:02 -04:00
page.within(find('.board:nth-child(2)')) do
expect(page.find('.board-header')).to have_content('1')
expect(page).to have_selector('.board-card', count: 1)
end
2017-06-01 06:11:02 -04:00
page.within(find('.board:nth-child(3)')) do
expect(page.find('.board-header')).to have_content('0')
expect(page).to have_selector('.board-card', count: 0)
end
end
it 'removes filtered labels' do
2017-03-08 07:17:01 -05:00
set_filter("label", testing.title)
click_filter_link(testing.title)
submit_filter
2017-06-01 06:11:02 -04:00
wait_for_board_cards(2, 1)
2017-03-08 07:17:01 -05:00
find('.clear-search').click
submit_filter
2017-06-01 06:11:02 -04:00
wait_for_board_cards(2, 8)
end
it 'infinite scrolls list with label filter' do
50.times do
create(:labeled_issue, project: project, labels: [planning, testing])
end
2017-03-08 07:17:01 -05:00
set_filter("label", testing.title)
click_filter_link(testing.title)
submit_filter
wait_for_requests
2016-08-16 06:34:32 -04:00
2017-06-01 06:11:02 -04:00
page.within(find('.board:nth-child(2)')) do
expect(page.find('.board-header')).to have_content('51')
expect(page).to have_selector('.board-card', count: 20)
expect(page).to have_content('Showing 20 of 51 issues')
find('.board .board-list')
2017-06-01 06:11:02 -04:00
evaluate_script("document.querySelectorAll('.board .board-list')[1].scrollTop = document.querySelectorAll('.board .board-list')[1].scrollHeight")
expect(page).to have_selector('.board-card', count: 40)
expect(page).to have_content('Showing 40 of 51 issues')
find('.board .board-list')
2017-06-01 06:11:02 -04:00
evaluate_script("document.querySelectorAll('.board .board-list')[1].scrollTop = document.querySelectorAll('.board .board-list')[1].scrollHeight")
expect(page).to have_selector('.board-card', count: 51)
expect(page).to have_content('Showing all issues')
end
end
it 'filters by multiple labels', :quarantine do
2017-03-08 07:17:01 -05:00
set_filter("label", testing.title)
click_filter_link(testing.title)
2016-08-10 04:10:50 -04:00
2017-03-08 07:17:01 -05:00
set_filter("label", bug.title)
click_filter_link(bug.title)
submit_filter
2016-08-10 04:10:50 -04:00
wait_for_requests
2016-08-16 06:34:32 -04:00
2017-06-01 06:11:02 -04:00
wait_for_board_cards(2, 1)
wait_for_empty_boards((3..4))
2016-08-10 04:10:50 -04:00
end
it 'filters by clicking label button on issue' do
2017-06-01 06:11:02 -04:00
page.within(find('.board:nth-child(2)')) do
expect(page).to have_selector('.board-card', count: 8)
expect(find('.board-card', match: :first)).to have_content(bug.title)
click_button(bug.title)
wait_for_requests
end
2017-03-08 07:17:01 -05:00
page.within('.tokens-container') do
expect(page).to have_content(bug.title)
end
wait_for_requests
2017-06-01 06:11:02 -04:00
wait_for_board_cards(2, 1)
wait_for_empty_boards((3..4))
end
it 'removes label filter by clicking label button on issue' do
2017-06-01 06:11:02 -04:00
page.within(find('.board:nth-child(2)')) do
page.within(find('.board-card', match: :first)) do
click_button(bug.title)
end
2017-03-08 07:17:01 -05:00
wait_for_requests
expect(page).to have_selector('.board-card', count: 1)
end
wait_for_requests
end
2016-08-03 03:42:26 -04:00
end
end
context 'keyboard shortcuts' do
before do
visit project_board_path(project, board)
wait_for_requests
end
it 'allows user to use keyboard shortcuts' do
find('body').native.send_keys('i')
expect(page).to have_content('New Issue')
end
end
context 'signed out user' do
before do
sign_out(:user)
visit project_board_path(project, board)
wait_for_requests
end
2016-11-14 07:12:01 -05:00
it 'displays lists' do
expect(page).to have_selector('.board')
end
it 'does not show create new list' do
2017-10-31 12:15:03 -04:00
expect(page).not_to have_button('.js-new-board-list')
end
it 'does not allow dragging' do
expect(page).not_to have_selector('.user-can-drag')
end
end
context 'as guest user' do
let(:user_guest) { create(:user) }
before do
project.add_guest(user_guest)
sign_out(:user)
sign_in(user_guest)
visit project_board_path(project, board)
wait_for_requests
end
it 'does not show create new list' do
expect(page).not_to have_selector('.js-new-board-list')
end
end
def drag(selector: '.board-list', list_from_index: 0, from_index: 0, to_index: 0, list_to_index: 0, perform_drop: true)
# ensure there is enough horizontal space for four boards
2017-11-02 16:45:46 -04:00
resize_window(2000, 800)
2017-01-06 11:52:18 -05:00
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,
perform_drop: perform_drop)
2016-08-03 03:42:26 -04:00
end
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('.board-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
2017-03-08 07:17:01 -05:00
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)
page.within('.filtered-search-box') do
2017-03-08 07:17:01 -05:00
expect(page).to have_button(link_text)
click_button(link_text)
end
end
2016-08-03 03:42:26 -04:00
end