2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-08-29 03:56:52 -04:00
|
|
|
require 'spec_helper'
|
2017-07-17 10:38:43 -04:00
|
|
|
|
2020-06-16 14:09:01 -04:00
|
|
|
RSpec.describe 'Issue Detail', :js do
|
2021-11-09 16:10:00 -05:00
|
|
|
let_it_be_with_refind(:project) { create(:project, :public) }
|
|
|
|
|
2017-11-06 08:46:27 -05:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:issue) { create(:issue, project: project, author: user) }
|
2021-05-19 17:12:42 -04:00
|
|
|
let(:incident) { create(:incident, project: project, author: user) }
|
2017-07-17 10:38:43 -04:00
|
|
|
|
|
|
|
context 'when user displays the issue' do
|
|
|
|
before do
|
|
|
|
visit project_issue_path(project, issue)
|
|
|
|
wait_for_requests
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows the issue' do
|
|
|
|
page.within('.issuable-details') do
|
2022-02-22 04:18:00 -05:00
|
|
|
expect(find('h1')).to have_content(issue.title)
|
2017-07-17 10:38:43 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-09-08 11:08:41 -04:00
|
|
|
context 'when user displays the issue as an incident' do
|
|
|
|
before do
|
2021-05-19 17:12:42 -04:00
|
|
|
visit project_issue_path(project, incident)
|
2020-09-08 11:08:41 -04:00
|
|
|
wait_for_requests
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not show design management' do
|
|
|
|
expect(page).not_to have_selector('.js-design-management')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-09-10 14:10:58 -04:00
|
|
|
context 'when issue description has emojis' do
|
|
|
|
let(:issue) { create(:issue, project: project, author: user, description: 'hello world :100:') }
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
visit project_issue_path(project, issue)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders gl-emoji tag' do
|
|
|
|
page.within('.description') do
|
|
|
|
expect(page).to have_selector('gl-emoji', count: 1)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-08-23 16:53:35 -04:00
|
|
|
context 'when issue description has xss snippet' do
|
|
|
|
before do
|
|
|
|
issue.update!(description: '![xss" onload=alert(1);//](a)')
|
2020-02-11 10:08:44 -05:00
|
|
|
|
2018-08-23 16:53:35 -04:00
|
|
|
sign_in(user)
|
|
|
|
visit project_issue_path(project, issue)
|
|
|
|
end
|
|
|
|
|
2020-07-08 02:09:13 -04:00
|
|
|
it 'encodes the description to prevent xss issues', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/207951' do
|
2018-08-23 16:53:35 -04:00
|
|
|
page.within('.issuable-details .detail-page-description') do
|
2020-02-11 10:08:44 -05:00
|
|
|
image = find('img.js-lazy-loaded')
|
|
|
|
|
2018-08-23 16:53:35 -04:00
|
|
|
expect(page).to have_selector('img', count: 1)
|
2020-02-11 10:08:44 -05:00
|
|
|
expect(image['onerror']).to be_nil
|
|
|
|
expect(image['src']).to end_with('/a')
|
2018-08-23 16:53:35 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-07-17 10:38:43 -04:00
|
|
|
context 'when edited by a user who is later deleted' do
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
visit project_issue_path(project, issue)
|
|
|
|
wait_for_requests
|
|
|
|
|
2021-05-19 17:12:42 -04:00
|
|
|
click_button 'Edit title and description'
|
2017-10-20 15:26:51 -04:00
|
|
|
fill_in 'issuable-title', with: 'issue title'
|
2021-05-19 17:12:42 -04:00
|
|
|
click_button 'Save changes'
|
2017-11-06 08:46:27 -05:00
|
|
|
wait_for_requests
|
2017-07-17 10:38:43 -04:00
|
|
|
|
2017-10-06 16:40:41 -04:00
|
|
|
Users::DestroyService.new(user).execute(user)
|
2017-07-17 10:38:43 -04:00
|
|
|
|
|
|
|
visit project_issue_path(project, issue)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows the issue' do
|
|
|
|
page.within('.issuable-details') do
|
2022-02-22 04:18:00 -05:00
|
|
|
expect(find('h1')).to have_content(issue.reload.title)
|
2017-07-17 10:38:43 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2021-05-19 17:12:42 -04:00
|
|
|
|
|
|
|
describe 'user updates `issue_type` via the issue type dropdown' do
|
2021-11-09 16:10:00 -05:00
|
|
|
let_it_be(:reporter) { create(:user) }
|
|
|
|
|
|
|
|
before_all do
|
|
|
|
project.add_reporter(reporter)
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'when an issue `issue_type` is edited' do
|
2021-05-19 17:12:42 -04:00
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
|
|
|
|
visit project_issue_path(project, issue)
|
|
|
|
wait_for_requests
|
|
|
|
end
|
|
|
|
|
2021-11-09 16:10:00 -05:00
|
|
|
context 'by non-member author' do
|
|
|
|
it 'cannot see Incident option' do
|
|
|
|
open_issue_edit_form
|
|
|
|
|
|
|
|
page.within('[data-testid="issuable-form"]') do
|
|
|
|
expect(page).to have_content('Issue')
|
|
|
|
expect(page).not_to have_content('Incident')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'by reporter' do
|
|
|
|
let(:user) { reporter }
|
2021-05-19 17:12:42 -04:00
|
|
|
|
2021-11-09 16:10:00 -05:00
|
|
|
it 'routes the user to the incident details page when the `issue_type` is set to incident' do
|
|
|
|
open_issue_edit_form
|
2021-05-19 17:12:42 -04:00
|
|
|
|
2021-11-09 16:10:00 -05:00
|
|
|
page.within('[data-testid="issuable-form"]') do
|
|
|
|
update_type_select('Issue', 'Incident')
|
|
|
|
|
|
|
|
expect(page).to have_current_path(project_issues_incident_path(project, issue))
|
|
|
|
end
|
2021-05-19 17:12:42 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-11-09 16:10:00 -05:00
|
|
|
describe 'when an incident `issue_type` is edited' do
|
2021-05-19 17:12:42 -04:00
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
|
|
|
|
visit project_issue_path(project, incident)
|
|
|
|
wait_for_requests
|
|
|
|
end
|
|
|
|
|
2021-11-09 16:10:00 -05:00
|
|
|
context 'by non-member author' do
|
|
|
|
it 'routes the user to the issue details page when the `issue_type` is set to issue' do
|
|
|
|
open_issue_edit_form
|
|
|
|
|
|
|
|
page.within('[data-testid="issuable-form"]') do
|
|
|
|
update_type_select('Incident', 'Issue')
|
|
|
|
|
|
|
|
expect(page).to have_current_path(project_issue_path(project, incident))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'by reporter' do
|
|
|
|
let(:user) { reporter }
|
|
|
|
|
|
|
|
it 'routes the user to the issue details page when the `issue_type` is set to issue' do
|
|
|
|
open_issue_edit_form
|
2021-05-19 17:12:42 -04:00
|
|
|
|
2021-11-09 16:10:00 -05:00
|
|
|
page.within('[data-testid="issuable-form"]') do
|
|
|
|
update_type_select('Incident', 'Issue')
|
2021-05-19 17:12:42 -04:00
|
|
|
|
2021-11-09 16:10:00 -05:00
|
|
|
expect(page).to have_current_path(project_issue_path(project, incident))
|
|
|
|
end
|
2021-05-19 17:12:42 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def update_type_select(from, to)
|
|
|
|
click_button from
|
|
|
|
click_button to
|
|
|
|
click_button 'Save changes'
|
|
|
|
|
|
|
|
wait_for_requests
|
|
|
|
end
|
|
|
|
|
|
|
|
def open_issue_edit_form
|
|
|
|
wait_for_requests
|
|
|
|
click_button 'Edit title and description'
|
|
|
|
wait_for_requests
|
|
|
|
end
|
2017-07-17 10:38:43 -04:00
|
|
|
end
|