Commit 05059efb authored by Oswaldo Ferreira's avatar Oswaldo Ferreira

Adjust spec file naming and add tests for board creation

parent f9bfbb90
...@@ -181,7 +181,7 @@ describe 'issue board config', :js do ...@@ -181,7 +181,7 @@ describe 'issue board config', :js do
end end
it 'can filter by additional labels' do it 'can filter by additional labels' do
label_title = issue.labels.first.title
label_2_title = issue_2.labels.first.title label_2_title = issue_2.labels.first.title
visit project_boards_path(project) visit project_boards_path(project)
...@@ -268,9 +268,6 @@ describe 'issue board config', :js do ...@@ -268,9 +268,6 @@ describe 'issue board config', :js do
context 'add issue' do context 'add issue' do
it 'adds assignee' do it 'adds assignee' do
visit boards_path(filtered_board) visit boards_path(filtered_board)
end end
end end
......
require 'rails_helper' require 'rails_helper'
describe 'Scoped issue boards', :js do describe 'Scoped issue boards', :js do
include FilteredSearchHelpers
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project, :public) } 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!(:milestone) { create(:milestone, project: project) }
let!(:issue) { create(:closed_issue, project: project) } let!(:board) { create(:board, project: project, name: 'Project board') }
let!(:issue_with_milestone) { create(:closed_issue, project: project, milestone: milestone) } let!(:group_board) { create(:board, group: group, name: 'Group board') }
let!(:label) { create(:label, project: project) } let!(:filtered_board) { create(:board, project: project_2, name: 'Filtered board', milestone: milestone, assignee: user, weight: 2) }
let!(:issue_with_label) { create(:labeled_issue, :closed, project: project, labels: [label]) } let!(:issue) { create(:issue, project: project) }
let!(:issue_with_assignee) { create(:closed_issue, project: project, assignees: [user]) } let!(:issue_milestone) { create(:closed_issue, project: project, milestone: milestone) }
let!(:issue_with_weight) { create(:labeled_issue, :closed, project: project, weight: 5) } 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 before do
allow_any_instance_of(ApplicationHelper).to receive(:collapsed_sidebar?).and_return(true) allow_any_instance_of(ApplicationHelper).to receive(:collapsed_sidebar?).and_return(true)
stub_licensed_features(multiple_issue_boards: true)
project.team << [user, :master] stub_licensed_features(group_issue_boards: true)
stub_licensed_features(scoped_issue_boards: true)
sign_in(user)
end end
context 'with the feature enabled' do context 'user with edit permissions' do
before do before do
stub_licensed_features(scoped_issue_board: true) project.add_master(user)
group.add_master(user)
login_as(user)
visit project_boards_path(project)
wait_for_requests
end end
context 'new board' do context 'new board' do
before do context 'milestone' do
visit project_boards_path(project) it 'creates board filtering by milestone' do
end create_board_milestone(milestone.title)
it 'creates board with milestone' do expect(page).to have_css('.js-visual-token')
create_board_with_milestone expect(find('.tokens-container')).to have_content(milestone.title)
expect(page).to have_selector('.card', count: 1)
end
expect(find('.tokens-container')).to have_content(milestone.title) it 'creates board to filtering by Any Milestone' do
wait_for_requests create_board_milestone('Any Milestone')
find('.card', match: :first)
expect(all('.board').last).to have_selector('.card', count: 1) expect(page).to have_css('.js-visual-token')
expect(find('.tokens-container')).to have_content("")
expect(page).to have_selector('.card', count: 3)
end
end end
it 'creates board with labels' do context 'labels' do
create_board_with_labels let!(:label_1) { create(:label, project: project, name: 'Label 1') }
let!(:label_2) { create(:label, project: project, name: 'Label 2') }
let!(:issue) { create(:labeled_issue, project: project, labels: [label_1]) }
let!(:issue_2) { create(:labeled_issue, project: project, labels: [label_2]) }
let!(:issue_3) { create(:labeled_issue, project: project, labels: [label_1, label_2]) }
expect(find('.tokens-container')).to have_content(label.title) it 'creates board filtering by one label' do
wait_for_requests create_board_label(label_1.title)
find('.card', match: :first)
expect(page).to have_css('.js-visual-token')
expect(find('.tokens-container')).to have_content(label_1.title)
expect(page).to have_selector('.card', count: 2)
end
it 'creates board filtering by multiple labels' do
create_board_label([label_1.title, label_2.title])
expect(all('.board').last).to have_selector('.card', count: 1) expect(page).to have_css('.js-visual-token')
expect(find('.tokens-container')).to have_content(label_1.title)
expect(find('.tokens-container')).to have_content(label_2.title)
expect(page).to have_selector('.card', count: 1)
end
xit 'only shows group labels in list on group boards' do
visit group_boards_path(group)
wait_for_requests
expect(page).to have_css('#js-multiple-boards-switcher')
page.within '#js-multiple-boards-switcher' do
find('.dropdown-menu-toggle').click
click_link 'Create new board'
end
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
it 'creates board with assignee' do context 'assignee' do
create_board_with_assignee it 'creates board filtering by assignee' do
create_board_assignee(user.name)
expect(find('.tokens-container')).to have_content(user.name) expect(page).to have_css('.js-visual-token')
wait_for_requests expect(find('.tokens-container')).to have_content(user.name)
find('.card', match: :first) expect(page).to have_selector('.card', count: 1)
# Does not display assignee in search hint
filtered_search.click
expect(all('.board').last).to have_selector('.card', count: 1) page.within('#js-dropdown-hint') do
expect(page).to have_content('label')
expect(page).not_to have_content('assignee')
end
end
it 'creates board filtering by "Any assignee"' do
create_board_assignee('Any assignee')
expect(page).not_to have_css('.js-visual-token')
expect(page).to have_selector('.card', count: 3)
end
end end
it 'creates board with weight' do context 'weight' do
create_board_with_weight let!(:issue_weight_1) { create(:issue, project: project, weight: 1) }
expect(find('.tokens-container')).to have_content(issue_with_weight.weight) it 'creates board filtering by weight' do
wait_for_requests create_board_weight(1)
find('.card', match: :first)
expect(page).to have_selector('.card', count: 1)
expect(find('.card-title').text).to have_content(issue_weight_1.title)
# Does not display assignee in search hint
filtered_search.click
expect(all('.board').last).to have_selector('.card', count: 1) page.within('#js-dropdown-hint') do
expect(page).to have_content('label')
expect(page).not_to have_content('weight')
end
end
it 'creates board filtering by "Any weight"' do
create_board_weight('Any Weight')
expect(page).to have_selector('.card', count: 4)
end
end end
end end
xcontext 'update board' do context 'edit board' do
let!(:milestone_two) { create(:milestone, project: project) } let!(:milestone_two) { create(:milestone, project: project) }
let!(:board) { create(:board, project: project, milestone: milestone) }
before do it 'edits board name' do
visit project_boards_path(project) edit_board.click
end
it 'defaults milestone filter' do
page.within '#js-multiple-boards-switcher' do
find('.dropdown-menu-toggle').click
wait_for_requests page.within('.popup-dialog') do
fill_in 'board-new-name', with: 'Testing'
click_link board.name click_button 'Save'
end end
expect(find('.tokens-container')).to have_content(milestone.title) expect(board_title).to have_content('Testing')
expect(board.reload.name).to eq('Testing')
end
find('.card', match: :first) it 'prefills fields' do
visit project_boards_path(project_2)
expect(all('.board').last).to have_selector('.card', count: 1) 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 end
it 'sets board to any milestone' do context 'milestone' do
update_board_milestone('Any Milestone') it 'sets board milestone' do
update_board_milestone(milestone.title)
expect(page).not_to have_css('.js-visual-token') expect(page).to have_css('.js-visual-token')
expect(find('.tokens-container')).not_to have_content(milestone.title) expect(find('.tokens-container')).to have_content(milestone.title)
find('.card', match: :first) expect(page).to have_selector('.card', count: 1)
end
expect(page).to have_selector('.board', count: 3) it 'sets board to any milestone' do
expect(all('.board').last).to have_selector('.card', count: 2) update_board_milestone('Any Milestone')
end
it 'sets board to upcoming milestone' do expect(page).not_to have_css('.js-visual-token')
update_board_milestone('Upcoming') expect(find('.tokens-container')).not_to have_content(milestone.title)
expect(find('.tokens-container')).not_to have_content(milestone.title) find('.card', match: :first)
find('.board', 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
expect(all('.board')[1]).to have_selector('.card', count: 0) it 'sets board to upcoming milestone' do
end update_board_milestone('Upcoming')
it 'does not allow milestone in filter to be editted' do expect(find('.tokens-container')).not_to have_content(milestone.title)
find('.filtered-search').native.send_keys(:backspace)
page.within('.tokens-container') do find('.board', match: :first)
expect(page).to have_selector('.value')
expect(all('.board')[1]).to have_selector('.card', count: 0)
end end
end
it 'does not render milestone in hint dropdown' do it 'does not display milestone in search hint' do
find('.filtered-search').click update_board_milestone(milestone.title)
filtered_search.click
page.within('#js-dropdown-hint') do page.within('#js-dropdown-hint') do
expect(page).not_to have_button('Milestone') expect(page).to have_content('label')
expect(page).not_to have_content('milestone')
end
end end
end end
end
xcontext 'removing issue from board' do context 'labels' do
let(:label) { create(:label, project: project) } let!(:label_1) { create(:label, project: project, name: 'Label 1') }
let!(:issue) { create(:labeled_issue, project: project, labels: [label], milestone: milestone) } let!(:label_2) { create(:label, project: project, name: 'Label 2') }
let!(:board) { create(:board, project: project, milestone: milestone) } let!(:issue) { create(:labeled_issue, project: project, labels: [label_1]) }
let!(:list) { create(:list, board: board, label: label, position: 0) } let!(:issue_2) { create(:labeled_issue, project: project, labels: [label_2]) }
let!(:issue_3) { create(:labeled_issue, project: project, labels: [label_1, label_2]) }
before do it 'adds label to board' do
visit project_boards_path(project) label_title = issue.labels.first.title
end visit project_boards_path(project)
it 'removes issues milestone when removing from the board' do update_board_label(label_title)
wait_for_requests
first('.card .card-number').click expect(page).to have_css('.js-visual-token')
expect(find('.tokens-container')).to have_content(label_title)
click_button('Remove from board') expect(page).to have_selector('.card', count: 2)
wait_for_requests end
expect(issue.reload.milestone).to be_nil it 'adds multiple labels to board' do
label_title = issue.labels.first.title
label_2_title = issue_2.labels.first.title
visit project_boards_path(project)
update_board_label(label_title)
update_board_label(label_2_title)
expect(page).to have_css('.js-visual-token')
expect(find('.tokens-container')).to have_content(label_title)
expect(find('.tokens-container')).to have_content(label_2_title)
expect(page).to have_selector('.card', count: 1)
end
it 'can filter by additional labels' do
label_title = issue.labels.first.title
label_2_title = issue_2.labels.first.title
visit project_boards_path(project)
update_board_label(label_title)
input_filtered_search("label:~#{label_2_title}")
expect(page).to have_selector('.card', count: 0)
end
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 end
end
xcontext 'new issues' do context 'assignee' do
let(:label) { create(:label, project: project) } it 'sets board assignee' do
let!(:list1) { create(:list, board: board, label: label, position: 0) } update_board_assignee(user.name)
let!(:board) { create(:board, project: project, milestone: milestone) }
let!(:issue) { create(:issue, project: project) }
before do expect(page).to have_css('.js-visual-token')
visit project_boards_path(project) 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 end
it 'creates new issue with boards milestone' do context 'weight' do
wait_for_requests let!(:issue_weight_1) { create(:issue, project: project, weight: 1) }
page.within(first('.board')) do it 'sets board weight' do
find('.btn-default').click update_board_weight(1)
find('.form-control').set('testing new issue with milestone') expect(page).to have_selector('.card', count: 1)
expect(find('.card-title').text).to have_content(issue_weight_1.title)
end
click_button('Submit issue') it 'sets board to Any weight' do
update_board_weight('Any weight')
wait_for_requests expect(page).to have_selector('.card', count: 4)
end
click_link('testing new issue with milestone') 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
context 'add issue' do
it 'adds assignee' do
visit boards_path(filtered_board)
expect(page).to have_content(milestone.title)
end end
end
context 'remove issue' do
let!(:issue) { create(:labeled_issue, project: project, labels: [project_label], milestone: milestone, assignees: [user]) }
let!(:list) { create(:list, board: board, label: project_label, position: 0) }
it 'updates issue with milestone from add issues modal' do it 'removes issues milestone when removing from the board' do
visit project_boards_path(project)
wait_for_requests wait_for_requests
click_button 'Add issues' find(".card[data-issue-id='#{issue.id}']").click
page.within('.add-issues-modal') do click_button 'Remove from board'
card = find('.card', :first) wait_for_requests
expect(page).to have_selector('.card', count: 1)
card.click expect(issue.reload.milestone).to be_nil
expect(issue.reload.assignees).to be_empty
end
end
end
click_button 'Add 1 issue' context 'user without edit permissions' do
end before do
visit project_boards_path(project)
wait_for_requests
end
click_link(issue.title) it 'can view board scope' do
view_scope.click
expect(page).to have_content(milestone.title) 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 end
end end
xcontext 'with the feature disabled' do context 'with scoped_issue_boards feature disabled' do
before do before do
stub_licensed_features(issue_board_milestone: false) stub_licensed_features(scoped_issue_boards: false)
project.team << [user, :master]
login_as(user)
visit project_boards_path(project) visit project_boards_path(project)
wait_for_requests
end end
it "doesn't show the input when creating a board" do it "doesn't show the input when creating a board" do
...@@ -217,83 +409,88 @@ describe 'Scoped issue boards', :js do ...@@ -217,83 +409,88 @@ describe 'Scoped issue boards', :js do
click_link 'Create new board' click_link 'Create new board'
# To make sure the form is shown # To make sure the form is shown
expect(page).to have_selector('#board-new-name') expect(page).to have_field('board-new-name')
expect(page).not_to have_button('Milestone') expect(page).not_to have_button('Toggle')
end end
end end
it "doesn't show the option to edit the milestone" do it "doesn't show the button to edit scope" do
page.within '#js-multiple-boards-switcher' do expect(page).not_to have_button('View Scope')
find('.dropdown-menu-toggle').click
# To make sure the dropdown is open
expect(page).to have_link('Edit board name')
expect(page).not_to have_link('Edit board milestone')
end
end end
end end
def create_board_with_milestone # Create board helper methods
creating_new_board do #
find('.edit-link', match: :first).trigger('click') def create_board_milestone(milestone_title)
find('a', text: milestone.title).trigger('click') create_board_scope('milestone', milestone_title)
end
click_button 'Create' def create_board_label(label_title)
end create_board_scope('labels', label_title)
end end
def create_board_with_labels def create_board_weight(weight)
creating_new_board do create_board_scope('weight', weight)
page.all('.edit-link')[1].trigger('click') end
find('a', text: label.title).trigger('click')
click_button 'Create' def create_board_assignee(assignee_name)
end create_board_scope('assignee', assignee_name)
end end
def create_board_with_assignee # Update board helper methods
creating_new_board do #
page.all('.edit-link')[2].trigger('click') def update_board_milestone(milestone_title)
find('a', text: user.name).trigger('click') update_board_scope('milestone', milestone_title)
end
click_button 'Create' def update_board_label(label_title)
end update_board_scope('labels', label_title)
end end
def create_board_with_weight def update_board_assignee(assignee_name)
creating_new_board do update_board_scope('assignee', assignee_name)
page.all('.edit-link')[3].trigger('click') end
find('a', text: issue_with_weight.weight).trigger('click')
click_button 'Create' def update_board_weight(weight)
end update_board_scope('weight', weight)
end end
def creating_new_board def create_board_scope(filter, value)
page.within '#js-multiple-boards-switcher' do page.within '#js-multiple-boards-switcher' do
find('.dropdown-menu-toggle').click find('.dropdown-menu-toggle').click
end
click_link 'Create new board' click_link 'Create new board'
find('#board-new-name').set 'test' find('#board-new-name').set 'test'
click_button 'Expand' click_button 'Expand'
yield page.within(".#{filter}") do
click_link 'Edit'
if value.is_a?(Array)
value.each { |value| click_link value }
else
click_link value
end
end end
end
def update_board_milestone(milestone_title)
page.within '#js-multiple-boards-switcher' do
find('.dropdown-menu-toggle').click
click_link 'Edit board milestone' click_button 'Create'
expect(page).to have_selector('.board-list-loading')
expect(page).not_to have_selector('.board-list-loading')
end
click_link milestone_title def update_board_scope(filter, value)
edit_board.click
click_button 'Save' page.within(".#{filter}") do
click_link 'Edit'
click_link value
end end
click_button 'Save'
expect(page).to have_selector('.board-list-loading')
expect(page).not_to have_selector('.board-list-loading')
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