debian-mirror-gitlab/spec/features/issues/user_edits_issue_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

488 lines
14 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2018-05-09 12:01:36 +05:30
require "spec_helper"
2020-06-23 00:09:42 +05:30
RSpec.describe "Issues > User edits issue", :js do
2020-03-13 15:44:24 +05:30
let_it_be(:project) { create(:project_empty_repo, :public) }
2020-11-24 15:15:51 +05:30
let_it_be(:project_with_milestones) { create(:project_empty_repo, :public) }
2020-03-13 15:44:24 +05:30
let_it_be(:user) { create(:user) }
2021-01-03 14:25:43 +05:30
let_it_be(:label_assigned) { create(:label, project: project, title: 'verisimilitude') }
let_it_be(:label_unassigned) { create(:label, project: project, title: 'syzygy') }
let_it_be(:issue) { create(:issue, project: project, author: user, assignees: [user], labels: [label_assigned]) }
2020-11-24 15:15:51 +05:30
let_it_be(:issue_with_milestones) { create(:issue, project: project_with_milestones, author: user, assignees: [user]) }
2020-03-13 15:44:24 +05:30
let_it_be(:milestone) { create(:milestone, project: project) }
2020-11-24 15:15:51 +05:30
let_it_be(:milestones) { create_list(:milestone, 25, project: project_with_milestones) }
2018-05-09 12:01:36 +05:30
2021-01-03 14:25:43 +05:30
context 'with authorized user' do
2020-03-13 15:44:24 +05:30
before do
2021-01-03 14:25:43 +05:30
project.add_developer(user)
project_with_milestones.add_developer(user)
sign_in(user)
2020-03-13 15:44:24 +05:30
end
2021-01-03 14:25:43 +05:30
context "from edit page" do
before do
2021-02-22 17:27:13 +05:30
stub_licensed_features(multiple_issue_assignees: false)
2021-01-03 14:25:43 +05:30
visit edit_project_issue_path(project, issue)
2020-03-13 15:44:24 +05:30
end
2021-01-03 14:25:43 +05:30
it "previews content" do
form = first(".gfm-form")
2020-03-13 15:44:24 +05:30
2021-01-03 14:25:43 +05:30
page.within(form) do
fill_in("Description", with: "Bug fixed :smile:")
click_button("Preview")
end
2020-03-13 15:44:24 +05:30
2021-01-03 14:25:43 +05:30
expect(form).to have_button("Write")
2022-06-21 17:19:12 +05:30
click_button("Write")
fill_in("Description", with: "/confidential")
click_button("Preview")
expect(form).to have_content('Makes this issue confidential.')
2020-03-13 15:44:24 +05:30
end
2021-01-03 14:25:43 +05:30
it 'allows user to select unassigned' do
2020-03-13 15:44:24 +05:30
visit edit_project_issue_path(project, issue)
2021-01-03 14:25:43 +05:30
expect(page).to have_content "Assignee #{user.name}"
2020-03-13 15:44:24 +05:30
2021-01-03 14:25:43 +05:30
first('.js-user-search').click
click_link 'Unassigned'
2020-03-13 15:44:24 +05:30
click_button 'Save changes'
2018-05-09 12:01:36 +05:30
2021-01-03 14:25:43 +05:30
page.within('.assignee') do
expect(page).to have_content 'None - assign yourself'
2020-03-13 15:44:24 +05:30
end
end
2021-01-03 14:25:43 +05:30
context 'with due date' do
before do
visit edit_project_issue_path(project, issue)
end
2020-03-13 15:44:24 +05:30
2021-01-03 14:25:43 +05:30
it 'saves with due date' do
date = Date.today.at_beginning_of_month.tomorrow
2020-03-13 15:44:24 +05:30
2021-01-03 14:25:43 +05:30
fill_in 'issue_title', with: 'bug 345'
fill_in 'issue_description', with: 'bug description'
find('#issuable-due-date').click
2020-03-13 15:44:24 +05:30
2021-01-03 14:25:43 +05:30
page.within '.pika-single' do
click_button date.day
end
2018-05-09 12:01:36 +05:30
2021-01-03 14:25:43 +05:30
expect(find('#issuable-due-date').value).to eq date.to_s
click_button 'Save changes'
page.within '.issuable-sidebar' do
expect(page).to have_content date.to_s(:medium)
end
end
2020-03-13 15:44:24 +05:30
2021-01-03 14:25:43 +05:30
it 'warns about version conflict' do
2021-04-29 21:17:54 +05:30
issue.update!(title: "New title")
2018-05-09 12:01:36 +05:30
2021-01-03 14:25:43 +05:30
fill_in 'issue_title', with: 'bug 345'
fill_in 'issue_description', with: 'bug description'
2020-03-13 15:44:24 +05:30
2021-01-03 14:25:43 +05:30
click_button 'Save changes'
expect(page).to have_content 'Someone edited the issue the same time you did'
2020-03-13 15:44:24 +05:30
end
end
2018-05-09 12:01:36 +05:30
end
2021-01-03 14:25:43 +05:30
context "from issue#show" do
before do
visit project_issue_path(project, issue)
end
describe 'update labels' do
it 'will not send ajax request when no data is changed' do
page.within '.labels' do
click_on 'Edit'
find('.dropdown-title button').click
expect(page).not_to have_selector('.block-loading')
expect(page).not_to have_selector('.gl-spinner')
2020-03-13 15:44:24 +05:30
end
end
2021-01-03 14:25:43 +05:30
it 'can add label to issue' do
page.within '.block.labels' do
expect(page).to have_text('verisimilitude')
expect(page).not_to have_text('syzygy')
2020-03-13 15:44:24 +05:30
2021-01-03 14:25:43 +05:30
click_on 'Edit'
2020-03-13 15:44:24 +05:30
2021-01-03 14:25:43 +05:30
wait_for_requests
click_on 'syzygy'
find('.dropdown-header-button').click
wait_for_requests
expect(page).to have_text('verisimilitude')
expect(page).to have_text('syzygy')
2020-03-13 15:44:24 +05:30
end
end
2021-01-03 14:25:43 +05:30
it 'can remove label from issue by clicking on the label `x` button' do
page.within '.block.labels' do
expect(page).to have_text('verisimilitude')
within '.gl-label' do
click_button
end
wait_for_requests
2020-03-13 15:44:24 +05:30
2021-01-03 14:25:43 +05:30
expect(page).not_to have_text('verisimilitude')
2020-03-13 15:44:24 +05:30
end
2021-01-03 14:25:43 +05:30
end
2021-01-29 00:20:46 +05:30
it 'can remove label without removing label added via quick action', :aggregate_failures do
# Add `syzygy` label with a quick action
2021-04-29 21:17:54 +05:30
fill_in 'Comment', with: '/label ~syzygy'
2021-01-29 00:20:46 +05:30
click_button 'Comment'
2022-04-04 11:22:00 +05:30
expect(page).to have_text('added syzygy label just now')
2021-01-29 00:20:46 +05:30
page.within '.block.labels' do
# Remove `verisimilitude` label
2022-08-27 11:52:29 +05:30
within '.gl-label', text: 'verisimilitude' do
2022-01-26 12:08:38 +05:30
click_button 'Remove label'
2021-01-29 00:20:46 +05:30
end
expect(page).to have_text('syzygy')
expect(page).not_to have_text('verisimilitude')
end
expect(page).to have_text('removed verisimilitude label')
expect(page).not_to have_text('removed syzygy verisimilitude labels')
expect(issue.reload.labels.map(&:title)).to contain_exactly('syzygy')
end
2021-01-03 14:25:43 +05:30
end
2020-03-13 15:44:24 +05:30
2021-01-03 14:25:43 +05:30
describe 'update assignee' do
2021-04-29 21:17:54 +05:30
context 'when GraphQL assignees widget feature flag is disabled' do
before do
stub_feature_flags(issue_assignees_widget: false)
2020-03-13 15:44:24 +05:30
end
2021-04-29 21:17:54 +05:30
context 'by authorized user' do
def close_dropdown_menu_if_visible
find('.dropdown-menu-toggle', visible: :all).tap do |toggle|
toggle.click if toggle.visible?
end
end
2021-01-03 14:25:43 +05:30
2021-04-29 21:17:54 +05:30
it 'allows user to select unassigned' do
visit project_issue_path(project, issue)
2021-01-03 14:25:43 +05:30
2021-04-29 21:17:54 +05:30
page.within('.assignee') do
expect(page).to have_content "#{user.name}"
click_link 'Edit'
click_link 'Unassigned'
2021-09-04 01:27:46 +05:30
close_dropdown_menu_if_visible
2021-04-29 21:17:54 +05:30
expect(page).to have_content 'None - assign yourself'
end
2021-01-03 14:25:43 +05:30
end
2020-03-13 15:44:24 +05:30
2021-04-29 21:17:54 +05:30
it 'allows user to select an assignee' do
issue2 = create(:issue, project: project, author: user)
visit project_issue_path(project, issue2)
2021-01-03 14:25:43 +05:30
2021-04-29 21:17:54 +05:30
page.within('.assignee') do
expect(page).to have_content "None"
end
page.within '.assignee' do
click_link 'Edit'
end
page.within '.dropdown-menu-user' do
click_link user.name
end
page.within('.assignee') do
expect(page).to have_content user.name
end
2021-01-03 14:25:43 +05:30
end
2021-04-29 21:17:54 +05:30
it 'allows user to unselect themselves' do
issue2 = create(:issue, project: project, author: user, assignees: [user])
visit project_issue_path(project, issue2)
page.within '.assignee' do
expect(page).to have_content user.name
click_link 'Edit'
click_link user.name
close_dropdown_menu_if_visible
2021-09-04 01:27:46 +05:30
page.within '[data-testid="no-value"]' do
2021-04-29 21:17:54 +05:30
expect(page).to have_content "None"
end
end
2021-01-03 14:25:43 +05:30
end
2021-04-29 21:17:54 +05:30
end
context 'by unauthorized user' do
let(:guest) { create(:user) }
2021-01-03 14:25:43 +05:30
2021-04-29 21:17:54 +05:30
before do
project.add_guest(guest)
2021-01-03 14:25:43 +05:30
end
2021-04-29 21:17:54 +05:30
it 'shows assignee text' do
sign_out(:user)
sign_in(guest)
visit project_issue_path(project, issue)
expect(page).to have_content issue.assignees.first.name
2021-01-03 14:25:43 +05:30
end
2020-03-13 15:44:24 +05:30
end
2021-04-29 21:17:54 +05:30
end
2020-03-13 15:44:24 +05:30
2021-04-29 21:17:54 +05:30
context 'when GraphQL assignees widget feature flag is enabled' do
context 'by authorized user' do
it 'allows user to select unassigned' do
visit project_issue_path(project, issue)
2020-03-13 15:44:24 +05:30
2021-04-29 21:17:54 +05:30
page.within('.assignee') do
expect(page).to have_content "#{user.name}"
2020-03-13 15:44:24 +05:30
2021-04-29 21:17:54 +05:30
click_button('Edit')
wait_for_requests
2020-03-13 15:44:24 +05:30
2021-04-29 21:17:54 +05:30
find('[data-testid="unassign"]').click
find('[data-testid="title"]').click
wait_for_requests
expect(page).to have_content 'None - assign yourself'
end
end
2020-03-13 15:44:24 +05:30
2021-04-29 21:17:54 +05:30
it 'allows user to select an assignee' do
issue2 = create(:issue, project: project, author: user)
visit project_issue_path(project, issue2)
2020-03-13 15:44:24 +05:30
2021-04-29 21:17:54 +05:30
page.within('.assignee') do
2021-01-03 14:25:43 +05:30
expect(page).to have_content "None"
2021-04-29 21:17:54 +05:30
click_button('Edit')
wait_for_requests
end
page.within '.dropdown-menu-user' do
2022-08-27 11:52:29 +05:30
click_button user.name
2021-04-29 21:17:54 +05:30
end
page.within('.assignee') do
find('[data-testid="title"]').click
wait_for_requests
expect(page).to have_content user.name
2021-01-03 14:25:43 +05:30
end
2020-03-13 15:44:24 +05:30
end
2021-04-29 21:17:54 +05:30
it 'allows user to unselect themselves' do
issue2 = create(:issue, project: project, author: user, assignees: [user])
2020-03-13 15:44:24 +05:30
2021-04-29 21:17:54 +05:30
visit project_issue_path(project, issue2)
page.within '.assignee' do
expect(page).to have_content user.name
click_button('Edit')
wait_for_requests
2022-08-27 11:52:29 +05:30
click_button user.name
2021-04-29 21:17:54 +05:30
find('[data-testid="title"]').click
wait_for_requests
expect(page).to have_content "None"
end
end
2021-01-03 14:25:43 +05:30
end
2020-03-13 15:44:24 +05:30
2021-04-29 21:17:54 +05:30
context 'by unauthorized user' do
let(:guest) { create(:user) }
2020-03-13 15:44:24 +05:30
2021-04-29 21:17:54 +05:30
before do
project.add_guest(guest)
end
it 'shows assignee text' do
sign_out(:user)
sign_in(guest)
visit project_issue_path(project, issue)
expect(page).to have_content issue.assignees.first.name
end
2021-01-03 14:25:43 +05:30
end
2020-03-13 15:44:24 +05:30
end
end
2021-01-03 14:25:43 +05:30
describe 'update milestone' do
context 'by authorized user' do
2021-09-30 23:02:18 +05:30
it 'allows user to select no milestone' do
2021-01-03 14:25:43 +05:30
visit project_issue_path(project, issue)
2021-09-30 23:02:18 +05:30
wait_for_requests
2020-03-13 15:44:24 +05:30
2021-09-30 23:02:18 +05:30
page.within('.block.milestone') do
expect(page).to have_content 'None'
click_button 'Edit'
wait_for_requests
click_button 'No milestone'
wait_for_requests
2020-03-13 15:44:24 +05:30
2021-01-03 14:25:43 +05:30
expect(page).to have_content 'None'
end
2020-03-13 15:44:24 +05:30
end
2021-01-03 14:25:43 +05:30
it 'allows user to de-select milestone' do
visit project_issue_path(project, issue)
2021-09-30 23:02:18 +05:30
wait_for_requests
2020-03-13 15:44:24 +05:30
2021-01-03 14:25:43 +05:30
page.within('.milestone') do
2021-09-30 23:02:18 +05:30
click_button 'Edit'
wait_for_requests
click_button milestone.title
2020-03-13 15:44:24 +05:30
2021-09-30 23:02:18 +05:30
page.within '[data-testid="select-milestone"]' do
2021-01-03 14:25:43 +05:30
expect(page).to have_content milestone.title
end
2020-03-13 15:44:24 +05:30
2021-09-30 23:02:18 +05:30
click_button 'Edit'
wait_for_requests
click_button 'No milestone'
2020-03-13 15:44:24 +05:30
2021-09-30 23:02:18 +05:30
page.within '[data-testid="select-milestone"]' do
2021-01-03 14:25:43 +05:30
expect(page).to have_content 'None'
end
2020-03-13 15:44:24 +05:30
end
end
2020-11-24 15:15:51 +05:30
2021-01-03 14:25:43 +05:30
it 'allows user to search milestone' do
visit project_issue_path(project_with_milestones, issue_with_milestones)
2021-09-30 23:02:18 +05:30
wait_for_requests
2020-11-24 15:15:51 +05:30
2021-01-03 14:25:43 +05:30
page.within('.milestone') do
2021-09-30 23:02:18 +05:30
click_button 'Edit'
2021-01-03 14:25:43 +05:30
wait_for_requests
# We need to enclose search string in quotes for exact match as all the milestone titles
# within tests are prefixed with `My title`.
2021-09-30 23:02:18 +05:30
find('.gl-form-input', visible: true).send_keys "\"#{milestones[0].title}\""
2021-01-03 14:25:43 +05:30
wait_for_requests
2020-11-24 15:15:51 +05:30
2021-09-30 23:02:18 +05:30
page.within '.gl-new-dropdown-contents' do
2021-01-03 14:25:43 +05:30
expect(page).to have_content milestones[0].title
end
2020-11-24 15:15:51 +05:30
end
end
end
2020-03-13 15:44:24 +05:30
2021-01-03 14:25:43 +05:30
context 'by unauthorized user' do
let(:guest) { create(:user) }
2020-03-13 15:44:24 +05:30
2021-01-03 14:25:43 +05:30
before do
project.add_guest(guest)
issue.milestone = milestone
2021-04-29 21:17:54 +05:30
issue.save!
2021-01-03 14:25:43 +05:30
end
2020-03-13 15:44:24 +05:30
2021-01-03 14:25:43 +05:30
it 'shows milestone text' do
sign_out(:user)
sign_in(guest)
2020-03-13 15:44:24 +05:30
2021-01-03 14:25:43 +05:30
visit project_issue_path(project, issue)
expect(page).to have_content milestone.title
end
2020-03-13 15:44:24 +05:30
end
end
2021-01-03 14:25:43 +05:30
context 'update due date' do
2021-06-08 01:23:25 +05:30
before do
# Due date widget uses GraphQL and needs to wait for requests to come back
# The date picker won't be rendered before requests complete
wait_for_requests
end
2021-01-03 14:25:43 +05:30
it 'adds due date to issue' do
date = Date.today.at_beginning_of_month + 2.days
2020-03-13 15:44:24 +05:30
2022-01-26 12:08:38 +05:30
page.within '[data-testid="sidebar-due-date"]' do
2021-04-29 21:17:54 +05:30
click_button 'Edit'
2021-01-03 14:25:43 +05:30
page.within '.pika-single' do
click_button date.day
end
2020-03-13 15:44:24 +05:30
2021-01-03 14:25:43 +05:30
wait_for_requests
2020-03-13 15:44:24 +05:30
2021-06-08 01:23:25 +05:30
expect(find('[data-testid="sidebar-date-value"]').text).to have_content date.strftime('%b %-d, %Y')
2021-01-03 14:25:43 +05:30
end
2020-03-13 15:44:24 +05:30
end
2021-01-03 14:25:43 +05:30
it 'removes due date from issue' do
date = Date.today.at_beginning_of_month + 2.days
2020-03-13 15:44:24 +05:30
2022-01-26 12:08:38 +05:30
page.within '[data-testid="sidebar-due-date"]' do
2021-04-29 21:17:54 +05:30
click_button 'Edit'
2020-03-13 15:44:24 +05:30
2021-01-03 14:25:43 +05:30
page.within '.pika-single' do
click_button date.day
end
wait_for_requests
expect(page).to have_no_content 'None'
2021-04-29 21:17:54 +05:30
click_button 'remove due date'
2021-01-03 14:25:43 +05:30
expect(page).to have_content 'None'
2020-03-13 15:44:24 +05:30
end
2021-01-03 14:25:43 +05:30
end
end
end
end
2020-03-13 15:44:24 +05:30
2021-01-03 14:25:43 +05:30
context 'with unauthorized user' do
before do
sign_in(user)
end
2020-03-13 15:44:24 +05:30
2021-01-03 14:25:43 +05:30
context "from issue#show" do
before do
visit project_issue_path(project, issue)
end
2020-03-13 15:44:24 +05:30
2021-01-03 14:25:43 +05:30
describe 'updating labels' do
it 'cannot edit labels' do
page.within '.block.labels' do
expect(page).not_to have_button('Edit')
end
end
it 'cannot remove label with a click as it has no `x` button' do
page.within '.block.labels' do
within '.gl-label' do
expect(page).not_to have_button
end
end
2020-03-13 15:44:24 +05:30
end
end
end
2018-05-09 12:01:36 +05:30
end
end