2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-12-04 20:38:33 +05:30
|
|
|
require 'spec_helper'
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
RSpec.describe 'Issue Detail', :js do
|
2018-03-17 18:26:18 +05:30
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:project) { create(:project, :public) }
|
|
|
|
let(:issue) { create(:issue, project: project, author: user) }
|
2021-09-04 01:27:46 +05:30
|
|
|
let(:incident) { create(:incident, project: project, author: user) }
|
2017-09-10 17:25:29 +05:30
|
|
|
|
|
|
|
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
|
|
|
|
expect(find('h2')).to have_content(issue.title)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-11-24 15:15:51 +05:30
|
|
|
context 'when user displays the issue as an incident' do
|
|
|
|
before do
|
2021-09-04 01:27:46 +05:30
|
|
|
visit project_issue_path(project, incident)
|
2020-11-24 15:15:51 +05:30
|
|
|
wait_for_requests
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not show design management' do
|
|
|
|
expect(page).not_to have_selector('.js-design-management')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
context 'when issue description has xss snippet' do
|
|
|
|
before do
|
|
|
|
issue.update!(description: '![xss" onload=alert(1);//](a)')
|
2020-03-13 15:44:24 +05:30
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
sign_in(user)
|
|
|
|
visit project_issue_path(project, issue)
|
|
|
|
end
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
it 'encodes the description to prevent xss issues', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/207951' do
|
2018-11-08 19:23:39 +05:30
|
|
|
page.within('.issuable-details .detail-page-description') do
|
2020-03-13 15:44:24 +05:30
|
|
|
image = find('img.js-lazy-loaded')
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
expect(page).to have_selector('img', count: 1)
|
2020-03-13 15:44:24 +05:30
|
|
|
expect(image['onerror']).to be_nil
|
|
|
|
expect(image['src']).to end_with('/a')
|
2018-11-08 19:23:39 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
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-09-04 01:27:46 +05:30
|
|
|
click_button 'Edit title and description'
|
2018-03-17 18:26:18 +05:30
|
|
|
fill_in 'issuable-title', with: 'issue title'
|
2021-09-04 01:27:46 +05:30
|
|
|
click_button 'Save changes'
|
2018-03-17 18:26:18 +05:30
|
|
|
wait_for_requests
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
Users::DestroyService.new(user).execute(user)
|
2017-09-10 17:25:29 +05:30
|
|
|
|
|
|
|
visit project_issue_path(project, issue)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows the issue' do
|
|
|
|
page.within('.issuable-details') do
|
|
|
|
expect(find('h2')).to have_content(issue.reload.title)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2021-09-04 01:27:46 +05:30
|
|
|
|
|
|
|
describe 'user updates `issue_type` via the issue type dropdown' do
|
|
|
|
context 'when an issue `issue_type` is edited by a signed in user' do
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
|
|
|
|
visit project_issue_path(project, issue)
|
|
|
|
wait_for_requests
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'routes the user to the incident details page when the `issue_type` is set to incident' do
|
|
|
|
open_issue_edit_form
|
|
|
|
|
|
|
|
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
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when an incident `issue_type` is edited by a signed in user' do
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
|
|
|
|
visit project_issue_path(project, incident)
|
|
|
|
wait_for_requests
|
|
|
|
end
|
|
|
|
|
|
|
|
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
|
|
|
|
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-09-10 17:25:29 +05:30
|
|
|
end
|