1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Issue Detail', :js, feature_category: :team_planning do
let_it_be_with_refind(:project) { create(:project, :public) }
let(:user) { create(:user) }
let(:issue) { create(:issue, project: project, author: user) }
let(:incident) { create(:incident, project: project, author: user) }
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('h1')).to have_content(issue.title)
end
end
end
context 'when user displays the issue as an incident' do
before do
visit project_issue_path(project, incident)
wait_for_requests
end
it 'does not show design management' do
expect(page).not_to have_selector('.js-design-management')
end
end
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
context 'when issue description has task list items' do
before do
description = '- [ ] I am a task
| Table |
|-------|
| <ul><li>[ ] I am inside a table</li><ul> |'
issue.update!(description: description)
sign_in(user)
visit project_issue_path(project, issue)
end
it 'shows task actions ellipsis button when hovering over the task list item, but not within a table', :aggregate_failures do
find('li', text: 'I am a task').hover
expect(page).to have_button 'Task actions'
find('li', text: 'I am inside a table').hover
expect(page).not_to have_button 'Task actions'
end
end
context 'when issue description has xss snippet' do
before do
issue.update!(description: '![xss" onload=alert(1);//](a)')
sign_in(user)
visit project_issue_path(project, issue)
end
it 'encodes the description to prevent xss issues', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/207951' do
page.within('.issuable-details .detail-page-description') do
image = find('img.js-lazy-loaded')
expect(page).to have_selector('img', count: 1)
expect(image['onerror']).to be_nil
expect(image['src']).to end_with('/a')
end
end
end
context 'when edited by a user who is later deleted' do
let(:user_to_be_deleted) { create(:user) }
before do
project.add_developer(user_to_be_deleted)
sign_in(user_to_be_deleted)
stub_feature_flags(moved_mr_sidebar: false)
visit project_issue_path(project, issue)
wait_for_requests
click_button 'Edit title and description'
fill_in 'issuable-title', with: 'issue title'
click_button 'Save changes'
wait_for_requests
Users::DestroyService.new(user_to_be_deleted).execute(user_to_be_deleted)
sign_in(user)
visit project_issue_path(project, issue)
end
it 'shows the issue' do
page.within('.issuable-details') do
expect(find('h1')).to have_content(issue.reload.title)
end
end
end
describe 'user updates `issue_type` via the issue type dropdown' do
let_it_be(:reporter) { create(:user) }
before_all do
project.add_reporter(reporter)
end
describe 'when an issue `issue_type` is edited' do
before do
sign_in(user)
visit project_issue_path(project, issue)
wait_for_requests
end
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 }
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(incident_project_issues_path(project, issue))
end
end
end
end
describe 'when an incident `issue_type` is edited' do
before do
sign_in(user)
visit project_issue_path(project, incident)
wait_for_requests
end
context 'by non-member author' do
it 'cannot edit issuable' do
page.within('.content') do
expect(page).to have_no_button('Edit title and description')
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
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
end
def update_type_select(from, to)
click_button from
find('[data-testid="issue-type-list-item"]', text: to).click
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
end
|