Expose escalation reason in reviewer tools (#21929)

This commit is contained in:
Andrew Williamson 2024-02-28 11:38:34 +00:00 коммит произвёл GitHub
Родитель 4f5a49af1f
Коммит ba5fdc81a4
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
4 изменённых файлов: 24 добавлений и 7 удалений

Просмотреть файл

@ -226,12 +226,15 @@ class CinderJobChoiceField(ModelMultipleChoiceField):
)
for report in reports
)
subtext = f'Reasoning: {obj.decision_notes}' if is_escalation else ''
return format_html(
'{}{}{}<details><summary>Show {} reports</summary><ul>{}</ul></details>',
'{}{}{}<details><summary>Show detail on {} reports</summary>'
'<span>{}</span><ul>{}</ul></details>',
'[Appeal] ' if obj.is_appeal else '',
'[Escalation] ' if is_escalation else '',
format_html_join(', ', '"{}"', reasons_set),
len(reports),
subtext,
format_html_join('', '<li>{}{}</li>', messages_gen),
)

Просмотреть файл

@ -829,6 +829,7 @@ class TestReviewForm(TestCase):
cinder_job_escalated = CinderJob.objects.create(
job_id='escalated',
decision_action=CinderJob.DECISION_ACTIONS.AMO_ESCALATE_ADDON,
decision_notes='Why o why',
resolvable_in_reviewer_tools=True,
target_addon=self.addon,
)
@ -891,15 +892,18 @@ class TestReviewForm(TestCase):
content = str(form['resolve_cinder_jobs'])
doc = pq(content)
assert doc('label[for="id_resolve_cinder_jobs_0"]').text() == (
'[Escalation] "DSA: It violates Mozilla\'s Add-on Policies"'
'\nShow 1 reports\nv[<script>alert()</script>]: ddd'
'[Escalation] "DSA: It violates Mozilla\'s Add-on Policies"\n'
'Show detail on 1 reports\n'
'Reasoning: Why o why\n'
'v[<script>alert()</script>]: ddd'
)
assert '<script>alert()</script>' not in content # should be escaped
assert '&lt;script&gt;alert()&lt;/script&gt' in content # should be escaped
assert doc('label[for="id_resolve_cinder_jobs_1"]').text() == (
'[Appeal] "DSA: It violates Mozilla\'s Add-on Policies"'
'\nShow 1 reports\nv[1.2]: ccc'
'\nShow detail on 1 reports\nv[1.2]: ccc'
)
assert doc('label[for="id_resolve_cinder_jobs_2"]').text() == (
'"DSA: It violates Mozilla\'s Add-on Policies"\nShow 2 reports\naaa\nbbb'
'"DSA: It violates Mozilla\'s Add-on Policies"\n'
'Show detail on 2 reports\naaa\nbbb'
)

Просмотреть файл

@ -5542,14 +5542,14 @@ class TestReview(ReviewBase):
message='Its baaaad',
)
response = self.client.get(self.url)
self.assertNotContains(response, 'Show 1 reports')
self.assertNotContains(response, 'Show detail on 1 reports')
with (
override_switch('enable-cinder-reporting', active=True),
override_switch('enable-cinder-reviewer-tools-integration', active=True),
):
response = self.client.get(self.url)
self.assertContains(response, 'Show 1 reports')
self.assertContains(response, 'Show detail on 1 reports')
self.assertContains(response, 'Its baaaad')
@override_switch('enable-cinder-reporting', active=True)

Просмотреть файл

@ -1043,6 +1043,16 @@ form.review-form .data-toggle {
list-style: none;
}
.review-actions-section #id_resolve_cinder_jobs {
details {
margin-left: 2em;
}
span {
font-style: italic;
}
}
.review-delayed-rejection-inner {
display: inline-grid;
grid-template-areas: