Go back to template if coming from template

Most users don’t have multiple contact blocks. So by default it should
feel like you’re just editing the one contact block, rather than
managing a collection of them. So this page skips the ‘choose’ page when
the user doesn’t yet have any contact blocks.
This commit is contained in:
Chris Hill-Scott
2019-07-08 09:29:21 +01:00
parent c709d7668e
commit 8e080d6079
3 changed files with 25 additions and 12 deletions

View File

@@ -2169,26 +2169,39 @@ def test_add_letter_contact_when_coming_from_template(
fake_uuid,
mock_get_service_letter_template,
):
data = {
'letter_contact_block': "1 Example Street"
}
page = client_request.post(
page = client_request.get(
'main.service_add_letter_contact',
service_id=SERVICE_ONE_ID,
_data=data,
from_template=fake_uuid,
_follow_redirects=True
)
assert page.select_one('.govuk-back-link')['href'] == url_for(
'main.view_template',
service_id=SERVICE_ONE_ID,
template_id=fake_uuid,
)
client_request.post(
'main.service_add_letter_contact',
service_id=SERVICE_ONE_ID,
_data={
'letter_contact_block': '1 Example Street',
},
from_template=fake_uuid,
_expected_redirect=url_for(
'main.view_template',
service_id=SERVICE_ONE_ID,
template_id=fake_uuid,
_external=True,
),
)
mock_add_letter_contact.assert_called_once_with(
SERVICE_ONE_ID,
contact_block="1 Example Street",
is_default=True
is_default=True,
)
assert page.find('h1').text == 'Set letter contact block'
@pytest.mark.parametrize('fixture, data, api_default_args', [
(no_sms_senders, {}, True),