mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-24 00:07:02 -04:00
Preserve message in session if we go out of hours
This is a real edge case, but it seems worth handling. How you’d get to this case: - it’s 5:29pm and you start to describe the problem you’re having - it’s 5:31pm and you click ‘submit’ - you’re redirected to the triage page because we’re now out of hours - you click ‘this is a serious problem’ What would be bad thing to happen: - you’re back on the message page and all the stuff you’ve written is gone What would be a good thing to happen: - we save the message in a session so that you can check it again before sending it
This commit is contained in:
@@ -254,6 +254,33 @@ def test_redirects_to_triage(
|
||||
assert response.location == expected_redirect(_external=True)
|
||||
|
||||
|
||||
def test_doesnt_lose_message_if_post_across_closing(
|
||||
logged_in_client,
|
||||
mocker,
|
||||
):
|
||||
|
||||
mocker.patch('app.main.views.feedback.has_live_services', return_value=True)
|
||||
mocker.patch('app.main.views.feedback.in_business_hours', return_value=False)
|
||||
|
||||
response = logged_in_client.post(
|
||||
url_for('main.feedback', ticket_type='problem'),
|
||||
data={'feedback': 'foo'},
|
||||
)
|
||||
with logged_in_client.session_transaction() as session:
|
||||
assert session['feedback_message'] == 'foo'
|
||||
assert response.status_code == 302
|
||||
assert response.location == url_for('.triage', _external=True)
|
||||
|
||||
response = logged_in_client.get(
|
||||
url_for('main.feedback', ticket_type='problem', severe=True)
|
||||
)
|
||||
assert response.status_code == 200
|
||||
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
|
||||
with logged_in_client.session_transaction() as session:
|
||||
assert page.find('textarea', {'name': 'feedback'}).text == 'foo'
|
||||
assert 'feedback_message' not in session
|
||||
|
||||
|
||||
@pytest.mark.parametrize('get_services_mock, expected_return_value', [
|
||||
(mock_get_services, True),
|
||||
(mock_get_services_with_no_services, False),
|
||||
|
||||
Reference in New Issue
Block a user