2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-08-29 03:56:52 -04:00
|
|
|
require 'spec_helper'
|
2017-04-19 05:04:24 -04:00
|
|
|
|
2020-06-16 14:09:01 -04:00
|
|
|
RSpec.describe 'Group milestones' do
|
2019-11-07 16:06:14 -05:00
|
|
|
let_it_be(:group) { create(:group) }
|
|
|
|
let_it_be(:project) { create(:project_empty_repo, group: group) }
|
|
|
|
let_it_be(:user) { create(:group_member, :maintainer, user: create(:user), group: group ).user }
|
2017-04-19 05:04:24 -04:00
|
|
|
|
2017-08-11 06:36:03 -04:00
|
|
|
around do |example|
|
2020-08-31 11:10:41 -04:00
|
|
|
freeze_time { example.run }
|
2017-04-19 05:04:24 -04:00
|
|
|
end
|
|
|
|
|
2017-08-11 06:36:03 -04:00
|
|
|
before do
|
|
|
|
sign_in(user)
|
2017-04-19 05:04:24 -04:00
|
|
|
end
|
|
|
|
|
2018-02-15 03:26:51 -05:00
|
|
|
context 'create a milestone', :js do
|
2017-04-19 05:04:24 -04:00
|
|
|
before do
|
|
|
|
visit new_group_milestone_path(group)
|
|
|
|
end
|
|
|
|
|
2017-10-11 05:03:19 -04:00
|
|
|
it 'renders description preview' do
|
2017-10-20 12:11:31 -04:00
|
|
|
description = find('.note-textarea')
|
2017-10-11 05:03:19 -04:00
|
|
|
|
2017-10-20 12:11:31 -04:00
|
|
|
description.native.send_keys('')
|
2017-10-11 05:03:19 -04:00
|
|
|
|
2018-10-19 07:35:33 -04:00
|
|
|
click_button('Preview')
|
2017-10-11 05:03:19 -04:00
|
|
|
|
|
|
|
preview = find('.js-md-preview')
|
|
|
|
|
|
|
|
expect(preview).to have_content('Nothing to preview.')
|
|
|
|
|
2018-10-19 07:35:33 -04:00
|
|
|
click_button('Write')
|
2017-10-11 05:03:19 -04:00
|
|
|
|
2017-10-20 12:11:31 -04:00
|
|
|
description.native.send_keys(':+1: Nice')
|
2017-10-11 05:03:19 -04:00
|
|
|
|
2018-10-19 07:35:33 -04:00
|
|
|
click_button('Preview')
|
2017-10-11 05:03:19 -04:00
|
|
|
|
|
|
|
expect(preview).to have_css('gl-emoji')
|
|
|
|
expect(find('#milestone_description', visible: false)).not_to be_visible
|
|
|
|
end
|
|
|
|
|
2017-04-19 05:04:24 -04:00
|
|
|
it 'creates milestone with start date' do
|
|
|
|
fill_in 'Title', with: 'testing'
|
|
|
|
find('#milestone_start_date').click
|
|
|
|
|
|
|
|
page.within(find('.pika-single')) do
|
|
|
|
click_button '1'
|
|
|
|
end
|
|
|
|
|
|
|
|
click_button 'Create milestone'
|
|
|
|
|
|
|
|
expect(find('.start_date')).to have_content(Date.today.at_beginning_of_month.strftime('%b %-d, %Y'))
|
|
|
|
end
|
2017-10-20 12:11:31 -04:00
|
|
|
|
|
|
|
it 'description input does not support autocomplete' do
|
|
|
|
description = find('.note-textarea')
|
|
|
|
description.native.send_keys('!')
|
|
|
|
|
|
|
|
expect(page).not_to have_selector('.atwho-view')
|
|
|
|
end
|
2017-04-19 05:04:24 -04:00
|
|
|
end
|
2017-07-07 11:08:49 -04:00
|
|
|
|
|
|
|
context 'milestones list' do
|
2018-02-15 03:26:51 -05:00
|
|
|
context 'when no milestones' do
|
|
|
|
it 'renders no milestones text' do
|
|
|
|
visit group_milestones_path(group)
|
|
|
|
expect(page).to have_content('No milestones to show')
|
|
|
|
end
|
2017-07-07 11:08:49 -04:00
|
|
|
end
|
|
|
|
|
2018-02-15 03:26:51 -05:00
|
|
|
context 'when milestones exists' do
|
2019-11-07 16:06:14 -05:00
|
|
|
let_it_be(:other_project) { create(:project_empty_repo, group: group) }
|
2018-02-15 03:26:51 -05:00
|
|
|
|
2019-11-07 16:06:14 -05:00
|
|
|
let_it_be(:active_project_milestone1) do
|
2018-02-15 03:26:51 -05:00
|
|
|
create(
|
|
|
|
:milestone,
|
|
|
|
project: project,
|
|
|
|
state: 'active',
|
|
|
|
title: 'v1.0',
|
|
|
|
due_date: '2114-08-20',
|
|
|
|
description: 'Lorem Ipsum is simply dummy text'
|
|
|
|
)
|
|
|
|
end
|
2020-11-17 10:09:28 -05:00
|
|
|
|
2019-11-07 16:06:14 -05:00
|
|
|
let_it_be(:active_project_milestone2) { create(:milestone, project: other_project, state: 'active', title: 'v1.1') }
|
|
|
|
let_it_be(:closed_project_milestone1) { create(:milestone, project: project, state: 'closed', title: 'v2.0') }
|
|
|
|
let_it_be(:closed_project_milestone2) { create(:milestone, project: other_project, state: 'closed', title: 'v2.0') }
|
|
|
|
let_it_be(:active_group_milestone) { create(:milestone, group: group, state: 'active', title: 'GL-113') }
|
|
|
|
let_it_be(:closed_group_milestone) { create(:milestone, group: group, state: 'closed') }
|
|
|
|
let_it_be(:issue) do
|
2018-02-15 03:26:51 -05:00
|
|
|
create :issue, project: project, assignees: [user], author: user, milestone: active_project_milestone1
|
|
|
|
end
|
2017-07-07 11:08:49 -04:00
|
|
|
|
2018-02-15 03:26:51 -05:00
|
|
|
before do
|
|
|
|
visit group_milestones_path(group)
|
|
|
|
end
|
2017-07-07 11:08:49 -04:00
|
|
|
|
2018-02-15 03:26:51 -05:00
|
|
|
it 'counts milestones correctly' do
|
2018-10-18 03:13:49 -04:00
|
|
|
expect(find('.top-area .active .badge').text).to eq("3")
|
|
|
|
expect(find('.top-area .closed .badge').text).to eq("3")
|
|
|
|
expect(find('.top-area .all .badge').text).to eq("6")
|
2018-02-15 03:26:51 -05:00
|
|
|
end
|
2017-08-16 03:27:32 -04:00
|
|
|
|
2020-05-28 08:08:10 -04:00
|
|
|
it 'lists group and project milestones' do
|
2018-02-15 03:26:51 -05:00
|
|
|
expect(page).to have_selector("#milestone_#{active_group_milestone.id}", count: 1)
|
2020-05-28 08:08:10 -04:00
|
|
|
expect(page).to have_selector("#milestone_#{active_project_milestone2.id}", count: 1)
|
2017-08-16 03:27:32 -04:00
|
|
|
end
|
|
|
|
|
2018-02-15 03:26:51 -05:00
|
|
|
it 'shows milestone detail and supports its edit' do
|
|
|
|
page.within(".milestones #milestone_#{active_group_milestone.id}") do
|
|
|
|
click_link(active_group_milestone.title)
|
|
|
|
end
|
|
|
|
|
|
|
|
page.within('.detail-page-header') do
|
|
|
|
click_link('Edit')
|
|
|
|
end
|
2017-08-16 03:27:32 -04:00
|
|
|
|
2018-02-15 03:26:51 -05:00
|
|
|
expect(page).to have_selector('.milestone-form')
|
2017-08-16 03:27:32 -04:00
|
|
|
end
|
|
|
|
|
2018-02-15 03:26:51 -05:00
|
|
|
it 'renders milestones' do
|
|
|
|
expect(page).to have_content('v1.0')
|
2018-12-20 06:14:33 -05:00
|
|
|
expect(page).to have_content('v1.1')
|
2018-02-15 03:26:51 -05:00
|
|
|
expect(page).to have_content('GL-113')
|
2020-05-28 08:08:10 -04:00
|
|
|
expect(page).to have_link(
|
|
|
|
'v1.0',
|
|
|
|
href: project_milestone_path(project, active_project_milestone1)
|
|
|
|
)
|
2018-02-15 03:26:51 -05:00
|
|
|
expect(page).to have_link(
|
|
|
|
'1 Issue',
|
2020-05-28 08:08:10 -04:00
|
|
|
href: project_issues_path(project, milestone_title: 'v1.0')
|
2018-02-15 03:26:51 -05:00
|
|
|
)
|
|
|
|
expect(page).to have_link(
|
|
|
|
'0 Merge Requests',
|
2020-05-28 08:08:10 -04:00
|
|
|
href: project_merge_requests_path(project, milestone_title: 'v1.0')
|
|
|
|
)
|
|
|
|
expect(page).to have_link(
|
|
|
|
'GL-113',
|
|
|
|
href: group_milestone_path(group, active_group_milestone)
|
|
|
|
)
|
|
|
|
expect(page).to have_link(
|
|
|
|
'0 Issues',
|
|
|
|
href: issues_group_path(group, milestone_title: 'GL-113')
|
|
|
|
)
|
|
|
|
expect(page).to have_link(
|
|
|
|
'0 Merge Requests',
|
|
|
|
href: merge_requests_group_path(group, milestone_title: 'GL-113')
|
2018-02-15 03:26:51 -05:00
|
|
|
)
|
|
|
|
end
|
2019-11-07 16:06:14 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'milestone tabs', :js do
|
|
|
|
context 'for a group milestone' do
|
|
|
|
let_it_be(:other_project) { create(:project_empty_repo, group: group) }
|
|
|
|
let_it_be(:milestone) { create(:milestone, group: group) }
|
2018-02-15 03:26:51 -05:00
|
|
|
|
2019-11-07 16:06:14 -05:00
|
|
|
let_it_be(:project_label) { create(:label, project: project) }
|
|
|
|
let_it_be(:other_project_label) { create(:label, project: other_project) }
|
2018-02-15 03:26:51 -05:00
|
|
|
|
2019-11-07 16:06:14 -05:00
|
|
|
let_it_be(:project_issue) { create(:labeled_issue, project: project, milestone: milestone, labels: [project_label], assignees: [create(:user)]) }
|
|
|
|
let_it_be(:other_project_issue) { create(:labeled_issue, project: other_project, milestone: milestone, labels: [other_project_label], assignees: [create(:user)]) }
|
|
|
|
|
|
|
|
let_it_be(:project_mr) { create(:merge_request, source_project: project, milestone: milestone) }
|
|
|
|
let_it_be(:other_project_mr) { create(:merge_request, source_project: other_project, milestone: milestone) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
visit group_milestone_path(group, milestone)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders the issues tab' do
|
|
|
|
within('#tab-issues') do
|
|
|
|
expect(page).to have_content project_issue.title
|
|
|
|
expect(page).to have_content other_project_issue.title
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders the merge requests tab' do
|
|
|
|
within('.js-milestone-tabs') do
|
|
|
|
click_link('Merge Requests')
|
|
|
|
end
|
|
|
|
|
|
|
|
within('#tab-merge-requests') do
|
|
|
|
expect(page).to have_content project_mr.title
|
|
|
|
expect(page).to have_content other_project_mr.title
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders the participants tab' do
|
|
|
|
within('.js-milestone-tabs') do
|
|
|
|
click_link('Participants')
|
|
|
|
end
|
|
|
|
|
|
|
|
within('#tab-participants') do
|
|
|
|
expect(page).to have_content project_issue.assignees.first.name
|
|
|
|
expect(page).to have_content other_project_issue.assignees.first.name
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders the labels tab' do
|
|
|
|
within('.js-milestone-tabs') do
|
|
|
|
click_link('Labels')
|
|
|
|
end
|
2018-02-15 03:26:51 -05:00
|
|
|
|
2019-11-07 16:06:14 -05:00
|
|
|
within('#tab-labels') do
|
|
|
|
expect(page).to have_content project_label.title
|
|
|
|
expect(page).to have_content other_project_label.title
|
2018-02-15 03:26:51 -05:00
|
|
|
end
|
|
|
|
end
|
2017-08-16 03:27:32 -04:00
|
|
|
end
|
2017-07-07 11:08:49 -04:00
|
|
|
end
|
2017-04-19 05:04:24 -04:00
|
|
|
end
|