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

Added some tests

parent 71605f31
......@@ -3,6 +3,7 @@
function simulateEvent(el, type, options) {
var event;
if (!el) return;
var ownerDocument = el.ownerDocument;
options = options || {};
......
......@@ -4,7 +4,7 @@
- content_for :page_specific_javascripts do
= 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"
......
......@@ -3,64 +3,239 @@ require 'rails_helper'
describe 'Issue Boards', feature: true, js: true do
let(:project) { create(:project) }
let(:user) { create(:user) }
let!(:board) { Boards::CreateService.new(project, user).execute }
before do
project.team << [user, :master]
login_as(user)
end
context 'no lists' do
before do
visit namespace_project_board_path(project.namespace, project)
end
it 'shows default lists' do
lists = all('.board')
it 'shows blank state' do
expect(page).to have_selector('.board', count: 3)
expect(page).to have_content('Welcome to your Issue Board!')
end
page.within lists.first do
expect(page).to have_content 'Backlog'
it 'hides the blank state when clicking nermind button' do
page.within('.board-blank-state') do
click_button('Nevermind, I\'ll use my own')
end
expect(page).to have_selector('.board', count: 2)
end
it 'creates default lists' do
lists = ['Backlog', 'Development', 'Testing', 'Production', 'Ready', 'Done']
page.within lists.last do
expect(page).to have_content 'Done'
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
it 'removes blank state list' do
click_button 'Nevermind, i\'ll use my own'
context 'with lists' do
let(:planning) { create(:label, project: project, name: 'Planning') }
let(:development) { create(:label, project: project, name: 'Development') }
let(:testing) { create(:label, project: project, name: 'Testing') }
expect(page).to have_selector('.board', count: 2)
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 'can drag card to new list' do
sleep 0.5
lists = all('.board')
drag_to(list_from_index: 0, list_to_index: 1)
it 'shows lists' do
expect(page).to have_selector('.board', count: 4)
end
page.within lists[1].find('.board-list') do
expect(page).to have_content('Test')
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 first('.card .card-footer') do
expect(page).to have_content 'Frontend'
page.within(all('.board')[2]) do
expect(page.find('.board-header')).to have_content('2')
expect(page).to have_selector('.card', count: 2)
end
end
it 'allows user to delete board' do
page.within(all('.board')[1]) do
find('.board-delete').click
end
expect(page).to have_selector('.board', count: 3)
end
it 'removes all labels from card' do
sleep 0.5
lists = all('.board')
drag_to(list_from_index: 1, list_to_index: 3)
context 'backlog' do
it 'shows issues in backlog with no labels' do
page.within(first('.board')) do
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
page.within lists[3].find('.board-list') do
expect(page).to have_content('Frontend bug')
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(first('.board')) do
expect(page.find('.board-header')).to have_content('3')
expect(page).to have_selector('.card', count: 3)
end
page.within(all('.board')[1]) do
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
context 'done' do
it 'shows list of done issues' do
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
page.within first('.card .card-footer') do
expect(page).not_to have_content 'Frontend'
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
page.within lists[1].find('.board-list') do
expect(page).not_to have_content('Frontend bug')
expect(page).not_to have_selector('.card')
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
......
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