Commit 0ee548d3 authored by Phil Hughes's avatar Phil Hughes

Added some tests

parent 71605f31
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
function simulateEvent(el, type, options) { function simulateEvent(el, type, options) {
var event; var event;
if (!el) return;
var ownerDocument = el.ownerDocument; var ownerDocument = el.ownerDocument;
options = options || {}; options = options || {};
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
- content_for :page_specific_javascripts do - content_for :page_specific_javascripts do
= page_specific_javascript_tag('boards/boards_bundle.js') = page_specific_javascript_tag('boards/boards_bundle.js')
= page_specific_javascript_tag('boards/test_utils/simulate_drag.js') if Rails.env.test? = page_specific_javascript_tag('boards/test_utils/simulate_drag.js')
= render "projects/issues/head" = render "projects/issues/head"
......
...@@ -3,64 +3,239 @@ require 'rails_helper' ...@@ -3,64 +3,239 @@ require 'rails_helper'
describe 'Issue Boards', feature: true, js: true do describe 'Issue Boards', feature: true, js: true do
let(:project) { create(:project) } let(:project) { create(:project) }
let(:user) { create(:user) } let(:user) { create(:user) }
let!(:board) { Boards::CreateService.new(project, user).execute }
before do before do
project.team << [user, :master] project.team << [user, :master]
login_as(user) login_as(user)
visit namespace_project_board_path(project.namespace, project)
end end
it 'shows default lists' do context 'no lists' do
lists = all('.board') before do
visit namespace_project_board_path(project.namespace, project)
end
page.within lists.first do it 'shows blank state' do
expect(page).to have_content 'Backlog' expect(page).to have_selector('.board', count: 3)
expect(page).to have_content('Welcome to your Issue Board!')
end end
page.within lists.last do it 'hides the blank state when clicking nermind button' do
expect(page).to have_content 'Done' page.within('.board-blank-state') do
click_button('Nevermind, I\'ll use my own')
end
expect(page).to have_selector('.board', count: 2)
end end
end
it 'removes blank state list' do it 'creates default lists' do
click_button 'Nevermind, i\'ll use my own' lists = ['Backlog', 'Development', 'Testing', 'Production', 'Ready', 'Done']
expect(page).to have_selector('.board', count: 2) page.within('.board-blank-state') do
click_button('Add default lists')
end
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
end end
it 'can drag card to new list' do context 'with lists' do
sleep 0.5 let(:planning) { create(:label, project: project, name: 'Planning') }
lists = all('.board') let(:development) { create(:label, project: project, name: 'Development') }
drag_to(list_from_index: 0, list_to_index: 1) let(:testing) { create(:label, project: project, name: 'Testing') }
let!(:list1) { create(:list, board: project.board, label: planning, position: 0) }
let!(:list2) { create(:list, board: project.board, label: development, position: 1) }
let!(:issue1) { create(:issue, project: project, assignee: user) }
let!(:issue2) { create(:issue, project: project) }
let!(:issue3) { create(:issue, project: project) }
let!(:issue4) { create(:issue, project: project) }
let!(:issue5) { create(:labeled_issue, project: project, labels: [planning]) }
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]) }
before do
visit namespace_project_board_path(project.namespace, project)
sleep 1
end
it 'shows lists' do
expect(page).to have_selector('.board', count: 4)
end
it 'shows issues in lists' do
page.within(all('.board')[1]) do
expect(page.find('.board-header')).to have_content('2')
expect(page).to have_selector('.card', count: 2)
end
page.within lists[1].find('.board-list') do page.within(all('.board')[2]) do
expect(page).to have_content('Test') expect(page.find('.board-header')).to have_content('2')
expect(page).to have_selector('.card', count: 2) expect(page).to have_selector('.card', count: 2)
end
end
page.within first('.card .card-footer') do it 'allows user to delete board' do
expect(page).to have_content 'Frontend' page.within(all('.board')[1]) do
find('.board-delete').click
end end
expect(page).to have_selector('.board', count: 3)
end end
end
it 'removes all labels from card' do context 'backlog' do
sleep 0.5 it 'shows issues in backlog with no labels' do
lists = all('.board') page.within(first('.board')) do
drag_to(list_from_index: 1, list_to_index: 3) expect(page.find('.board-header')).to have_content('5')
expect(page).to have_selector('.card', count: 5)
end
end
it 'is searchable' do
page.within(first('.board')) do
find('.form-control').set issue1.title
expect(page).to have_selector('.card', count: 1)
end
end
it 'clears search' do
page.within(first('.board')) do
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: 2)
end
end
it 'moves issue from backlog into list' do
drag_to(list_to_index: 1)
page.within lists[3].find('.board-list') do page.within(first('.board')) do
expect(page).to have_content('Frontend bug') expect(page.find('.board-header')).to have_content('3')
expect(page).to have_selector('.card', count: 2) expect(page).to have_selector('.card', count: 3)
end
page.within first('.card .card-footer') do page.within(all('.board')[1]) do
expect(page).not_to have_content 'Frontend' expect(page.find('.board-header')).to have_content('3')
expect(page).to have_selector('.card', count: 3)
all('.card').each do |card|
expect(card.all('.label').last).to have_content(planning.title)
end
end
end end
end end
page.within lists[1].find('.board-list') do context 'done' do
expect(page).not_to have_content('Frontend bug') it 'shows list of done issues' do
expect(page).not_to have_selector('.card') expect(all('.board').last).to have_selector('.card', count: 1)
end
it 'moves issue to done' do
drag_to(list_from_index: 0, list_to_index: 3)
expect(all('.board').last).to have_selector('.card', count: 2)
expect(all('.board').last).to have_content(issue4.title)
expect(all('.board').last).not_to have_content(planning.title)
end
it 'removes all of the same issue to done' do
drag_to(list_from_index: 1, list_to_index: 3)
expect(all('.board')[1]).to have_selector('.card', count: 1)
expect(all('.board')[2]).to have_selector('.card', count: 1)
expect(all('.board').last).to have_content(issue6.title)
expect(all('.board').last).not_to have_content(planning.title)
end
end
context 'lists' do
it 'moves between lists' do
drag_to(list_from_index: 1, card_index: 1, list_to_index: 2)
expect(all('.board')[1]).to have_selector('.card', count: 1)
expect(all('.board')[2]).to have_selector('.card', count: 3)
expect(all('.board')[2]).to have_content(issue5.title)
expect(all('.board')[2].all('.card').last).to have_content(development.title)
end
it 'moves between lists' do
drag_to(list_from_index: 2, list_to_index: 1)
expect(all('.board')[1]).to have_selector('.card', count: 3)
expect(all('.board')[2]).to have_selector('.card', count: 1)
expect(all('.board')[1]).to have_content(issue7.title)
expect(all('.board')[1].all('.card').first).to have_content(planning.title)
end
it 'moves from done' do
drag_to(list_from_index: 3, list_to_index: 1)
expect(all('.board')[1]).to have_selector('.card', count: 3)
expect(all('.board')[1]).to have_content(issue8.title)
expect(all('.board')[1].all('.card').first).to have_content(planning.title)
end
context 'issue card' do
it 'shows assignee' do
page.within(first('.board')) do
expect(all('.card').last).to have_selector('.avatar')
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 'moves issues from backlog into new list' do
page.within(first('.board')) do
expect(page.find('.board-header')).to have_content('5')
expect(page).to have_selector('.card', count: 5)
end
click_button 'Create new list'
page.within('.dropdown-menu-issues-board-new') do
click_link testing.title
end
page.within(first('.board')) do
expect(page.find('.board-header')).to have_content('4')
expect(page).to have_selector('.card', count: 4)
end
end
end
end
context 'filtering' do
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment