mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-10 11:24:10 -04:00
Allow message to be prefilled on feedback page
So that people don’t have to remember what they are supposed to be asking for and go to the effort of typing out the message.
This commit is contained in:
@@ -134,6 +134,9 @@ def feedback(ticket_type):
|
||||
abort(500, "Feedback submission failed")
|
||||
return redirect(url_for('.thanks', urgent=urgent, anonymous=anonymous))
|
||||
|
||||
if not form.feedback.data:
|
||||
form.feedback.data = request.args.get('body', '')
|
||||
|
||||
return render_template(
|
||||
'views/support/{}.html'.format(ticket_type),
|
||||
form=form,
|
||||
|
||||
@@ -85,6 +85,31 @@ def test_get_feedback_page(client, ticket_type, expected_status_code):
|
||||
assert response.status_code == expected_status_code
|
||||
|
||||
|
||||
@freeze_time('2016-12-12 12:00:00.000000')
|
||||
def test_get_feedback_page_with_prefilled_body(
|
||||
client_request,
|
||||
mocker,
|
||||
):
|
||||
mock_post = mocker.patch('app.main.views.feedback.deskpro_client.create_ticket')
|
||||
page = client_request.get(
|
||||
'main.feedback',
|
||||
ticket_type=QUESTION_TICKET_TYPE,
|
||||
body='Please send cat pictures <script>alert("foo");</script>',
|
||||
)
|
||||
assert page.select_one('textarea').text == (
|
||||
'Please send cat pictures <script>alert("foo");</script>'
|
||||
)
|
||||
client_request.post(
|
||||
'main.feedback',
|
||||
ticket_type=QUESTION_TICKET_TYPE,
|
||||
body='Please send cat pictures <script>alert("foo");</script>',
|
||||
_data={'feedback': 'blah', 'name': 'Example', 'email_address': 'test@example.com'}
|
||||
)
|
||||
message = mock_post.call_args[1]['message']
|
||||
assert message.endswith('blah')
|
||||
assert 'cat pictures' not in message
|
||||
|
||||
|
||||
@freeze_time('2016-12-12 12:00:00.000000')
|
||||
@pytest.mark.parametrize('ticket_type', [PROBLEM_TICKET_TYPE, QUESTION_TICKET_TYPE])
|
||||
def test_passed_non_logged_in_user_details_through_flow(client, mocker, ticket_type):
|
||||
|
||||
Reference in New Issue
Block a user