Commit 541b7515 authored by Simon Knox's avatar Simon Knox

add feature specs for assignee and milestone dropdowns

parent d089f4b2
......@@ -36,7 +36,7 @@
Delete board
%board-form{ ":milestone-path" => "milestonePath",
"labels-path" => labels_filter_path,
"labels-path" => labels_filter_path(true),
"project-id" => @project&.id,
"group-id" => @group&.id,
":can-admin-board" => can?(current_user, :admin_board, parent),
......
require 'rails_helper'
describe 'issue board config', :js do
include FilteredSearchHelpers
let(:user) { create(:user) }
let(:project) { create(:project, :public) }
let!(:planning) { create(:label, project: project, name: 'Planning') }
let!(:board) { create(:board, project: project) }
let(:group) { create(:group, :public) }
let(:project) { create(:project, :public, namespace: group) }
let(:project_2) { create(:project, :public, namespace: group) }
let!(:project_label) { create(:label, project: project, name: 'Planning') }
let!(:group_label) { create(:group_label, group: group, name: 'Group Label') }
let!(:milestone) { create(:milestone, project: project) }
let!(:board) { create(:board, project: project, name: 'Project board') }
let!(:filtered_board) { create(:board, project: project_2, name: 'Filtered board', milestone: milestone, assignee: user, weight: 2) }
let!(:issue) { create(:issue, project: project) }
let!(:issue_milestone) { create(:closed_issue, project: project, milestone: milestone) }
let!(:assigned_issue) { create(:issue, project: project, assignees: [user]) }
let(:edit_board) { find('.btn', text: 'Edit board') }
let(:view_scope) { find('.btn', text: 'View scope') }
let(:board_title) { find('.boards-selector-wrapper .dropdown-menu-toggle') }
before do
allow_any_instance_of(ApplicationHelper).to receive(:collapsed_sidebar?).and_return(true)
stub_licensed_features(multiple_issue_boards: true)
stub_licensed_features(group_issue_boards: true)
stub_licensed_features(scoped_issue_boards: true)
end
context 'user with edit permissions' do
before do
project.team << [user, :master]
project.add_master(user)
group.add_master(user)
login_as(user)
......@@ -20,8 +38,47 @@ describe 'issue board config', :js do
wait_for_requests
end
it 'edits board' do
click_button 'Edit board'
context 'new board' do
it 'creates new board' do
board_title.click
click_link 'Create new board'
page.within('.popup-dialog') do
fill_in 'board-new-name', with: 'Second board'
click_button 'Create'
end
expect(board_title).to have_content('Second board')
end
it 'creates board with filters' do
board_title.click
click_link 'Create new board'
page.within('.popup-dialog') do
fill_in 'board-new-name', with: 'Assignee-filtered board'
click_button 'Expand'
page.within('.assignee') do
click_link 'Edit'
click_link user.name
end
click_button 'Create'
end
expect(board_title).to have_content('Assignee-filtered board')
expect(page).to have_content(assigned_issue.title)
expect(page).not_to have_content(issue.title)
end
end
context 'edit board' do
let!(:milestone_two) { create(:milestone, project: project) }
it 'edits board name' do
edit_board.click
page.within('.popup-dialog') do
fill_in 'board-new-name', with: 'Testing'
......@@ -29,7 +86,135 @@ describe 'issue board config', :js do
click_button 'Save'
end
expect('.dropdown-menu-toggle', text: 'Testing').to exist
expect(board_title).to have_content('Testing')
expect(board.reload.name).to eq('Testing')
end
it 'prefills fields' do
visit project_boards_path(project_2)
edit_board.click
expect(find('.milestone .value')).to have_content(milestone.title)
expect(find('.assignee .value')).to have_content(user.name)
expect(find('.weight .value')).to have_content(2)
end
context 'milestone' do
it 'sets board milestone' do
update_board_milestone(milestone.title)
expect(page).to have_css('.js-visual-token')
expect(find('.tokens-container')).to have_content(milestone.title)
expect(page).to have_selector('.card', count: 1)
end
it 'sets board to any milestone' do
update_board_milestone('Any Milestone')
expect(page).not_to have_css('.js-visual-token')
expect(find('.tokens-container')).not_to have_content(milestone.title)
find('.card', match: :first)
expect(page).to have_selector('.board', count: 3)
expect(all('.board').first).to have_selector('.card', count: 2)
expect(all('.board').last).to have_selector('.card', count: 1)
end
it 'sets board to upcoming milestone' do
update_board_milestone('Upcoming')
expect(find('.tokens-container')).not_to have_content(milestone.title)
find('.board', match: :first)
expect(all('.board')[1]).to have_selector('.card', count: 0)
end
it 'does not display milestone in search hint' do
update_board_milestone(milestone.title)
filtered_search.click
page.within('#js-dropdown-hint') do
expect(page).to have_content('label')
expect(page).not_to have_content('milestone')
end
end
end
context 'labels' do
context 'group board' do
it 'only shows group labels in list' do
visit group_boards_path(group)
edit_board.click
page.within(".labels") do
click_link 'Edit'
page.within('.dropdown') do
expect(page).to have_content(group_label.title)
expect(page).not_to have_content(project_label.title)
end
end
end
end
end
context 'assignee' do
it 'sets board assignee' do
update_board_assignee(user.name)
expect(page).to have_css('.js-visual-token')
expect(find('.tokens-container')).to have_content(user.name)
expect(page).to have_selector('.card', count: 1)
end
it 'sets board to Any assignee' do
update_board_assignee('Any assignee')
expect(page).not_to have_css('.js-visual-token')
expect(page).to have_selector('.card', count: 3)
end
it 'does not display assignee in search hint' do
update_board_assignee(user.name)
filtered_search.click
page.within('#js-dropdown-hint') do
expect(page).to have_content('label')
expect(page).not_to have_content('assignee')
end
end
end
context 'weight' do
let!(:issue_weight_1) { create(:issue, project: project, weight: 1) }
it 'sets board weight' do
update_board_weight(1)
expect(page).to have_selector('.card', count: 1)
expect(find('.card-title').text).to have_content(issue_weight_1.title)
end
it 'sets board to Any weight' do
update_board_weight('Any weight')
expect(page).to have_selector('.card', count: 4)
end
it 'does not display weight in search hint' do
update_board_weight(1)
filtered_search.click
page.within('#js-dropdown-hint') do
expect(page).to have_content('label')
expect(page).not_to have_content('weight')
end
end
end
end
end
......@@ -39,14 +224,71 @@ describe 'issue board config', :js do
wait_for_requests
end
it 'shows board scope' do
click_button 'View scope'
it 'can view board scope' do
view_scope.click
page.within('.popup-dialog') do
expect(find('.modal-header')).to have_content('Board scope')
expect(page).not_to have_content('Board name')
expect(page).not_to have_link('Edit')
expect(page).not_to have_button('Edit')
expect(page).not_to have_button('Save')
expect(page).not_to have_button('Cancel')
end
end
end
context 'with scoped_issue_boards feature disabled' do
before do
stub_licensed_features(scoped_issue_boards: false)
project.team << [user, :master]
login_as(user)
visit project_boards_path(project)
wait_for_requests
end
it "doesn't show the input when creating a board" do
page.within '#js-multiple-boards-switcher' do
find('.dropdown-menu-toggle').click
click_link 'Create new board'
# To make sure the form is shown
expect(page).to have_field('board-new-name')
expect(page).not_to have_button('Toggle')
end
end
it "doesn't show the button to edit scope" do
expect(page).not_to have_button('View Scope')
end
end
def update_board_milestone(milestone_title)
update_board_scope('milestone', milestone_title)
end
def update_board_assignee(assignee_name)
update_board_scope('assignee', assignee_name)
end
def update_board_weight(weight)
update_board_scope('weight', weight)
end
def update_board_scope(filter, value)
edit_board.click
page.within(".#{filter}") do
click_link 'Edit'
click_link value
end
click_button 'Save'
expect(page).to have_selector('.board-list-loading')
expect(page).to_not have_selector('.board-list-loading')
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