2018-12-13 01:54:30 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-04-03 06:27:56 -04:00
|
|
|
require "spec_helper"
|
|
|
|
|
2020-06-16 14:09:01 -04:00
|
|
|
RSpec.describe "User creates issue" do
|
2020-01-16 07:08:32 -05:00
|
|
|
include DropzoneHelper
|
|
|
|
|
|
|
|
let_it_be(:project) { create(:project_empty_repo, :public) }
|
|
|
|
let_it_be(:user) { create(:user) }
|
|
|
|
|
2022-04-27 08:08:19 -04:00
|
|
|
before do
|
|
|
|
stub_feature_flags(vue_issues_list: true)
|
|
|
|
end
|
|
|
|
|
2020-01-16 07:08:32 -05:00
|
|
|
context "when unauthenticated" do
|
|
|
|
before do
|
|
|
|
sign_out(:user)
|
|
|
|
end
|
|
|
|
|
2022-04-27 08:08:19 -04:00
|
|
|
it "redirects to signin then back to new issue after signin", :js do
|
2020-01-16 07:08:32 -05:00
|
|
|
create(:issue, project: project)
|
|
|
|
|
|
|
|
visit project_issues_path(project)
|
|
|
|
|
|
|
|
page.within ".nav-controls" do
|
|
|
|
click_link "New issue"
|
|
|
|
end
|
|
|
|
|
2022-03-03 10:16:42 -05:00
|
|
|
expect(page).to have_current_path new_user_session_path, ignore_query: true
|
2020-01-16 07:08:32 -05:00
|
|
|
|
|
|
|
gitlab_sign_in(create(:user))
|
|
|
|
|
2022-03-03 10:16:42 -05:00
|
|
|
expect(page).to have_current_path new_project_issue_path(project), ignore_query: true
|
2020-01-16 07:08:32 -05:00
|
|
|
end
|
|
|
|
end
|
2018-04-03 06:27:56 -04:00
|
|
|
|
2021-06-11 14:10:13 -04:00
|
|
|
context "when signed in as guest", :js do
|
2018-04-03 06:27:56 -04:00
|
|
|
before do
|
|
|
|
project.add_guest(user)
|
|
|
|
sign_in(user)
|
|
|
|
|
|
|
|
visit(new_project_issue_path(project))
|
|
|
|
end
|
|
|
|
|
2021-06-11 14:10:13 -04:00
|
|
|
context 'available metadata' do
|
|
|
|
it 'allows guest to set issue metadata' do
|
|
|
|
page.within(".issue-form") do
|
|
|
|
expect(page).to have_content("Title")
|
|
|
|
.and have_content("Description")
|
|
|
|
.and have_content("Type")
|
|
|
|
.and have_content("Assignee")
|
|
|
|
.and have_content("Milestone")
|
|
|
|
.and have_content("Labels")
|
|
|
|
.and have_content("Due date")
|
|
|
|
.and have_content("This issue is confidential and should only be visible to team members with at least Reporter access.")
|
|
|
|
end
|
2018-04-03 06:27:56 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when previewing" do
|
|
|
|
it "previews content" do
|
|
|
|
form = first(".gfm-form")
|
|
|
|
textarea = first(".gfm-form textarea")
|
|
|
|
|
|
|
|
page.within(form) do
|
2018-10-19 07:35:33 -04:00
|
|
|
click_button("Preview")
|
2018-04-03 06:27:56 -04:00
|
|
|
|
|
|
|
preview = find(".js-md-preview") # this element is findable only when the "Preview" link is clicked.
|
|
|
|
|
|
|
|
expect(preview).to have_content("Nothing to preview.")
|
|
|
|
|
2018-10-19 07:35:33 -04:00
|
|
|
click_button("Write")
|
2018-04-03 06:27:56 -04:00
|
|
|
fill_in("Description", with: "Bug fixed :smile:")
|
2018-10-19 07:35:33 -04:00
|
|
|
click_button("Preview")
|
2018-04-03 06:27:56 -04:00
|
|
|
|
|
|
|
expect(preview).to have_css("gl-emoji")
|
|
|
|
expect(textarea).not_to be_visible
|
2022-04-07 14:08:29 -04:00
|
|
|
|
|
|
|
click_button("Write")
|
|
|
|
fill_in("Description", with: "/confidential")
|
|
|
|
click_button("Preview")
|
|
|
|
|
|
|
|
expect(form).to have_content('Makes this issue confidential.')
|
2018-04-03 06:27:56 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "with labels" do
|
2018-12-13 01:54:30 -05:00
|
|
|
let(:label_titles) { %w(bug feature enhancement) }
|
2018-04-03 06:27:56 -04:00
|
|
|
|
|
|
|
before do
|
2018-12-13 01:54:30 -05:00
|
|
|
label_titles.each do |title|
|
2018-04-03 06:27:56 -04:00
|
|
|
create(:label, project: project, title: title)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it "creates issue" do
|
|
|
|
issue_title = "500 error on profile"
|
|
|
|
|
|
|
|
fill_in("Title", with: issue_title)
|
|
|
|
click_button("Label")
|
2018-12-13 01:54:30 -05:00
|
|
|
click_link(label_titles.first)
|
2021-03-30 02:09:35 -04:00
|
|
|
click_button("Create issue")
|
2018-04-03 06:27:56 -04:00
|
|
|
|
|
|
|
expect(page).to have_content(issue_title)
|
|
|
|
.and have_content(user.name)
|
|
|
|
.and have_content(project.name)
|
2018-12-13 01:54:30 -05:00
|
|
|
.and have_content(label_titles.first)
|
2018-04-03 06:27:56 -04:00
|
|
|
end
|
|
|
|
end
|
2020-01-16 07:08:32 -05:00
|
|
|
|
|
|
|
context 'with due date', :js do
|
|
|
|
it 'saves with due date' do
|
|
|
|
date = Date.today.at_beginning_of_month
|
|
|
|
|
|
|
|
fill_in 'issue_title', with: 'bug 345'
|
|
|
|
fill_in 'issue_description', with: 'bug description'
|
|
|
|
find('#issuable-due-date').click
|
|
|
|
|
|
|
|
page.within '.pika-single' do
|
|
|
|
click_button date.day
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(find('#issuable-due-date').value).to eq date.to_s
|
|
|
|
|
2021-03-30 02:09:35 -04:00
|
|
|
click_button 'Create issue'
|
2020-01-16 07:08:32 -05:00
|
|
|
|
|
|
|
page.within '.issuable-sidebar' do
|
|
|
|
expect(page).to have_content date.to_s(:medium)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'dropzone upload file', :js do
|
|
|
|
before do
|
|
|
|
visit new_project_issue_path(project)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'uploads file when dragging into textarea' do
|
|
|
|
dropzone_file Rails.root.join('spec', 'fixtures', 'banana_sample.gif')
|
|
|
|
|
|
|
|
expect(page.find_field("issue_description").value).to have_content 'banana_sample'
|
|
|
|
end
|
|
|
|
|
|
|
|
it "doesn't add double newline to end of a single attachment markdown" do
|
|
|
|
dropzone_file Rails.root.join('spec', 'fixtures', 'banana_sample.gif')
|
|
|
|
|
|
|
|
expect(page.find_field("issue_description").value).not_to match /\n\n$/
|
|
|
|
end
|
|
|
|
|
2020-03-10 14:08:17 -04:00
|
|
|
it "cancels a file upload correctly", :capybara_ignore_server_errors do
|
2020-01-16 07:08:32 -05:00
|
|
|
slow_requests do
|
|
|
|
dropzone_file([Rails.root.join('spec', 'fixtures', 'dk.png')], 0, false)
|
|
|
|
|
|
|
|
click_button 'Cancel'
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(page).to have_button('Attach a file')
|
|
|
|
expect(page).not_to have_button('Cancel')
|
|
|
|
expect(page).not_to have_selector('.uploading-progress-container', visible: true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'form filled by URL parameters' do
|
|
|
|
let(:project) { create(:project, :public, :repository) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
project.repository.create_file(
|
|
|
|
user,
|
|
|
|
'.gitlab/issue_templates/bug.md',
|
|
|
|
'this is a test "bug" template',
|
|
|
|
message: 'added issue template',
|
|
|
|
branch_name: 'master')
|
|
|
|
|
|
|
|
visit new_project_issue_path(project, issuable_template: 'bug')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'fills in template' do
|
|
|
|
expect(find('.js-issuable-selector .dropdown-toggle-text')).to have_content('bug')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-09-04 08:08:27 -04:00
|
|
|
context 'form create handles issue creation by default' do
|
2021-11-09 16:10:00 -05:00
|
|
|
let_it_be(:project) { create(:project) }
|
2020-09-04 08:08:27 -04:00
|
|
|
|
|
|
|
before do
|
|
|
|
visit new_project_issue_path(project)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'pre-fills the issue type dropdown with issue type' do
|
2020-09-09 08:08:22 -04:00
|
|
|
expect(find('.js-issuable-type-filter-dropdown-wrap .dropdown-toggle-text')).to have_content('Issue')
|
2020-09-04 08:08:27 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not hide the milestone select' do
|
2021-08-03 14:10:02 -04:00
|
|
|
expect(page).to have_selector('.qa-issuable-milestone-dropdown') # rubocop:disable QA/SelectorUsage
|
2020-09-04 08:08:27 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'form create handles incident creation' do
|
2021-11-09 16:10:00 -05:00
|
|
|
let_it_be(:project) { create(:project) }
|
2020-09-04 08:08:27 -04:00
|
|
|
|
|
|
|
before do
|
2020-09-09 08:08:22 -04:00
|
|
|
visit new_project_issue_path(project, { issuable_template: 'incident', issue: { issue_type: 'incident' } })
|
2020-09-04 08:08:27 -04:00
|
|
|
end
|
|
|
|
|
2021-11-09 16:10:00 -05:00
|
|
|
it 'does not pre-fill the issue type dropdown with incident type' do
|
|
|
|
expect(find('.js-issuable-type-filter-dropdown-wrap .dropdown-toggle-text')).not_to have_content('Incident')
|
2020-09-04 08:08:27 -04:00
|
|
|
end
|
|
|
|
|
2021-01-15 10:10:31 -05:00
|
|
|
it 'shows the milestone select' do
|
2021-08-03 14:10:02 -04:00
|
|
|
expect(page).to have_selector('.qa-issuable-milestone-dropdown') # rubocop:disable QA/SelectorUsage
|
2020-09-04 08:08:27 -04:00
|
|
|
end
|
|
|
|
|
2021-11-09 16:10:00 -05:00
|
|
|
it 'hides the incident help text' do
|
|
|
|
expect(page).not_to have_text('A modified issue to guide the resolution of incidents.')
|
2020-09-09 08:08:22 -04:00
|
|
|
end
|
2020-09-04 08:08:27 -04:00
|
|
|
end
|
|
|
|
|
2020-01-16 07:08:32 -05:00
|
|
|
context 'suggestions', :js do
|
|
|
|
it 'displays list of related issues' do
|
|
|
|
issue = create(:issue, project: project)
|
|
|
|
create(:issue, project: project, title: 'test issue')
|
|
|
|
|
|
|
|
visit new_project_issue_path(project)
|
|
|
|
|
|
|
|
fill_in 'issue_title', with: issue.title
|
|
|
|
|
|
|
|
expect(page).to have_selector('.suggestion-item', count: 1)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'clears local storage after creating a new issue', :js do
|
|
|
|
2.times do
|
|
|
|
visit new_project_issue_path(project)
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect(page).to have_field('Title', with: '')
|
|
|
|
|
|
|
|
fill_in 'issue_title', with: 'bug 345'
|
|
|
|
fill_in 'issue_description', with: 'bug description'
|
|
|
|
|
2021-03-30 02:09:35 -04:00
|
|
|
click_button 'Create issue'
|
2020-01-16 07:08:32 -05:00
|
|
|
end
|
|
|
|
end
|
2018-04-03 06:27:56 -04:00
|
|
|
end
|
2019-03-04 06:37:14 -05:00
|
|
|
|
2021-11-09 16:10:00 -05:00
|
|
|
context 'when signed in as reporter', :js do
|
|
|
|
let_it_be(:project) { create(:project) }
|
|
|
|
|
|
|
|
before_all do
|
|
|
|
project.add_reporter(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'form create handles incident creation' do
|
|
|
|
before do
|
|
|
|
visit new_project_issue_path(project, { issuable_template: 'incident', issue: { issue_type: 'incident' } })
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'pre-fills the issue type dropdown with incident type' do
|
|
|
|
expect(find('.js-issuable-type-filter-dropdown-wrap .dropdown-toggle-text')).to have_content('Incident')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'hides the epic select' do
|
|
|
|
expect(page).not_to have_selector('.epic-dropdown-container')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows the milestone select' do
|
|
|
|
expect(page).to have_selector('.qa-issuable-milestone-dropdown') # rubocop:disable QA/SelectorUsage
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'hides the weight input' do
|
|
|
|
expect(page).not_to have_selector('.qa-issuable-weight-input') # rubocop:disable QA/SelectorUsage
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows the incident help text' do
|
|
|
|
expect(page).to have_text('A modified issue to guide the resolution of incidents.')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-03-04 06:37:14 -05:00
|
|
|
context "when signed in as user with special characters in their name" do
|
|
|
|
let(:user_special) { create(:user, name: "Jon O'Shea") }
|
|
|
|
|
|
|
|
before do
|
|
|
|
project.add_developer(user_special)
|
|
|
|
sign_in(user_special)
|
|
|
|
|
|
|
|
visit(new_project_issue_path(project))
|
|
|
|
end
|
|
|
|
|
|
|
|
it "will correctly escape user names with an apostrophe when clicking 'Assign to me'", :js do
|
|
|
|
first('.assign-to-me-link').click
|
|
|
|
|
|
|
|
expect(page).to have_content(user_special.name)
|
|
|
|
expect(page.find('input[name="issue[assignee_ids][]"]', visible: false)['data-meta']).to eq(user_special.name)
|
|
|
|
end
|
|
|
|
end
|
2018-04-03 06:27:56 -04:00
|
|
|
end
|